Skip to content

Commit

Permalink
Merge pull request #740 from metanorma/update/attachments
Browse files Browse the repository at this point in the history
common.xsl updated for attachment description, #739
  • Loading branch information
Intelligent2013 committed Sep 1, 2024
2 parents de37ce0 + 9d7e282 commit 75ed94d
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions xslt_src/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -19726,26 +19726,37 @@
</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() != ''">
<xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#x0d;&#x0a;|&#x0d;|&#x0a;)', '')"/> <!-- remove line breaks -->
<pdf:embedded-file src="{$src_attachment}" filename="{@name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"/>
</xsl:when>
<xsl:otherwise>
<!-- _{filename}_attachments -->
<!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
<pdf:embedded-file src="{$url}" filename="{@name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"/>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>

<pdf:embedded-file filename="{@name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="normalize-space() != ''">
<xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#x0d;&#x0a;|&#x0d;|&#x0a;)', '')"/> <!-- remove line breaks -->
<xsl:value-of select="$src_attachment"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
<xsl:value-of select="$url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:if test="$description != ''">
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
</xsl:if>
</pdf:embedded-file>
</xsl:for-each>
<!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
<xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
<xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
<xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
<xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
<!-- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/> -->
<pdf:embedded-file src="{$url}" filename="{$attachment_path}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"/>
<xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
<pdf:embedded-file src="{$url}" filename="{$attachment_path}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
<xsl:if test="$description != ''">
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
</xsl:if>
</pdf:embedded-file>
</xsl:for-each>
</xsl:if>
</xsl:template> <!-- addPDFUAmeta -->
Expand Down

0 comments on commit 75ed94d

Please sign in to comment.