Skip to content

Commit

Permalink
Merge pull request #234 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jul 27, 2024
2 parents 981f518 + ff0a340 commit c354880
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion lib/isodoc/m3aawg/m3aawg.policy.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6716,14 +6716,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
14 changes: 13 additions & 1 deletion lib/isodoc/m3aawg/m3aawg.report.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6716,14 +6716,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 c354880

Please sign in to comment.