Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xslt update based on metanorma/mn-native-pdf@4de7291a80809950ae1a8558eae657e6bef03110 #1120

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions lib/isodoc/iso/iso.amendment.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4153,6 +4153,8 @@
<xsl:param name="svg_images"/> <!-- svg images array -->
<xsl:variable name="images" select="document($svg_images)"/>
<xsl:param name="basepath"/> <!-- base path for images -->
<xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
<xsl:param name="inputxml_filename"/> <!-- input xml file name -->
<xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
<xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
<xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
Expand Down Expand Up @@ -4205,6 +4207,20 @@
<xsl:call-template name="getLang"/>
</xsl:variable>

<xsl:variable name="inputxml_filename_prefix">
<xsl:choose>
<xsl:when test="contains($inputxml_filename, '.presentation.xml')">
<xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
</xsl:when>
<xsl:when test="contains($inputxml_filename, '.xml')">
<xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$inputxml_filename"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
Expand Down Expand Up @@ -10090,6 +10106,12 @@
<xsl:when test="@updatetype = 'true'">
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
</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__, ')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(@target)"/>
</xsl:otherwise>
Expand Down Expand Up @@ -14978,10 +15000,10 @@

<xsl:template name="addPDFUAmeta">
<pdf:catalog>
<pdf:dictionary type="normal" key="ViewerPreferences">
<pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
</pdf:dictionary>
</pdf:catalog>
<pdf:dictionary type="normal" key="ViewerPreferences">
<pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
</pdf:dictionary>
</pdf:catalog>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about="">
Expand Down Expand Up @@ -15033,6 +15055,19 @@
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<!-- add attachments -->
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
<xsl:choose>
<xsl:when test="normalize-space() != ''">
<pdf:embedded-file src="{.}" filename="{@name}"/>
</xsl:when>
<xsl:otherwise>
<!-- _{filename}_attachments -->
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
<pdf:embedded-file src="{$url}" filename="{@name}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template> <!-- addPDFUAmeta -->

<xsl:template name="getId">
Expand Down
43 changes: 39 additions & 4 deletions lib/isodoc/iso/iso.international-standard.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4153,6 +4153,8 @@
<xsl:param name="svg_images"/> <!-- svg images array -->
<xsl:variable name="images" select="document($svg_images)"/>
<xsl:param name="basepath"/> <!-- base path for images -->
<xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
<xsl:param name="inputxml_filename"/> <!-- input xml file name -->
<xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
<xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
<xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
Expand Down Expand Up @@ -4205,6 +4207,20 @@
<xsl:call-template name="getLang"/>
</xsl:variable>

<xsl:variable name="inputxml_filename_prefix">
<xsl:choose>
<xsl:when test="contains($inputxml_filename, '.presentation.xml')">
<xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
</xsl:when>
<xsl:when test="contains($inputxml_filename, '.xml')">
<xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$inputxml_filename"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
Expand Down Expand Up @@ -10090,6 +10106,12 @@
<xsl:when test="@updatetype = 'true'">
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
</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__, ')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(@target)"/>
</xsl:otherwise>
Expand Down Expand Up @@ -14978,10 +15000,10 @@

<xsl:template name="addPDFUAmeta">
<pdf:catalog>
<pdf:dictionary type="normal" key="ViewerPreferences">
<pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
</pdf:dictionary>
</pdf:catalog>
<pdf:dictionary type="normal" key="ViewerPreferences">
<pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
</pdf:dictionary>
</pdf:catalog>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about="">
Expand Down Expand Up @@ -15033,6 +15055,19 @@
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<!-- add attachments -->
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
<xsl:choose>
<xsl:when test="normalize-space() != ''">
<pdf:embedded-file src="{.}" filename="{@name}"/>
</xsl:when>
<xsl:otherwise>
<!-- _{filename}_attachments -->
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
<pdf:embedded-file src="{$url}" filename="{@name}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template> <!-- addPDFUAmeta -->

<xsl:template name="getId">
Expand Down
Loading