Skip to content

Commit

Permalink
Merge pull request #725 from metanorma/fix/attachments
Browse files Browse the repository at this point in the history
common.xsl updated for PDF attachments, metanorma/metanorma-standoc#900
  • Loading branch information
Intelligent2013 committed Jul 27, 2024
2 parents bc4cb31 + 0d1af74 commit 978534b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion xslt_src/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12331,14 +12331,26 @@

<xsl:template match="*[local-name()='localityStack']"/>

<xsl:variable name="pdfAttachmentsList_">
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
<attachment filename="{@name}"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>

<xsl:template match="*[local-name()='link']" name="link">
<xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
<xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
<xsl:variable name="target">
<xsl:choose>
<xsl:when test="@updatetype = 'true'">
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
</xsl:when>
<!-- link to the PDF attachment -->
<xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
<xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
</xsl:when>
<xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
<!-- link to the PDF attachment -->
<xsl:variable name="target_" select="translate(@target, '\', '/')"/>
<xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
<xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
Expand Down

0 comments on commit 978534b

Please sign in to comment.