Skip to content

Commit 75ed94d

Browse files
Merge pull request #740 from metanorma/update/attachments
common.xsl updated for attachment description, #739
2 parents de37ce0 + 9d7e282 commit 75ed94d

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

xslt_src/common.xsl

+25-14
Original file line numberDiff line numberDiff line change
@@ -19726,26 +19726,37 @@
1972619726
</x:xmpmeta>
1972719727
<!-- add attachments -->
1972819728
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
19729-
<xsl:choose>
19730-
<xsl:when test="normalize-space() != ''">
19731-
<xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#x0d;&#x0a;|&#x0d;|&#x0a;)', '')"/> <!-- remove line breaks -->
19732-
<pdf:embedded-file src="{$src_attachment}" filename="{@name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"/>
19733-
</xsl:when>
19734-
<xsl:otherwise>
19735-
<!-- _{filename}_attachments -->
19736-
<!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
19737-
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
19738-
<pdf:embedded-file src="{$url}" filename="{@name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"/>
19739-
</xsl:otherwise>
19740-
</xsl:choose>
19729+
<xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
19730+
19731+
<pdf:embedded-file filename="{@name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
19732+
<xsl:attribute name="src">
19733+
<xsl:choose>
19734+
<xsl:when test="normalize-space() != ''">
19735+
<xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#x0d;&#x0a;|&#x0d;|&#x0a;)', '')"/> <!-- remove line breaks -->
19736+
<xsl:value-of select="$src_attachment"/>
19737+
</xsl:when>
19738+
<xsl:otherwise>
19739+
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
19740+
<xsl:value-of select="$url"/>
19741+
</xsl:otherwise>
19742+
</xsl:choose>
19743+
</xsl:attribute>
19744+
<xsl:if test="$description != ''">
19745+
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
19746+
</xsl:if>
19747+
</pdf:embedded-file>
1974119748
</xsl:for-each>
1974219749
<!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
1974319750
<xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
1974419751
<xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
1974519752
<xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
1974619753
<xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
19747-
<!-- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/> -->
19748-
<pdf:embedded-file src="{$url}" filename="{$attachment_path}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"/>
19754+
<xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
19755+
<pdf:embedded-file src="{$url}" filename="{$attachment_path}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
19756+
<xsl:if test="$description != ''">
19757+
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
19758+
</xsl:if>
19759+
</pdf:embedded-file>
1974919760
</xsl:for-each>
1975019761
</xsl:if>
1975119762
</xsl:template> <!-- addPDFUAmeta -->

0 commit comments

Comments
 (0)