Skip to content

Commit 483fbd4

Browse files
xslt update based on metanorma/mn-native-pdf@dcd7e74
1 parent 4ed942e commit 483fbd4

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

lib/isodoc/plateau/plateau.international-standard.xsl

+31-6
Original file line numberDiff line numberDiff line change
@@ -7878,14 +7878,16 @@
78787878
<xsl:template match="*[local-name()='link']" name="link">
78797879
<xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
78807880
<xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7881+
<xsl:variable name="isLinkToEmbeddedFile" select="normalize-space(@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target])"/>
78817882
<xsl:variable name="target">
78827883
<xsl:choose>
78837884
<xsl:when test="@updatetype = 'true'">
78847885
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
78857886
</xsl:when>
78867887
<!-- link to the PDF attachment -->
7887-
<xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
7888-
<xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7888+
<xsl:when test="$isLinkToEmbeddedFile = 'true'">
7889+
<xsl:variable name="target_file" select="java:org.metanorma.fop.Util.getFilenameFromPath(@target)"/>
7890+
<xsl:value-of select="concat('url(embedded-file:', $target_file, ')')"/>
78897891
</xsl:when>
78907892
<!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
78917893
<xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
@@ -7916,6 +7918,11 @@
79167918
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
79177919
</xsl:if>
79187920

7921+
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
7922+
<xsl:attribute name="color">inherit</xsl:attribute>
7923+
<xsl:attribute name="text-decoration">none</xsl:attribute>
7924+
</xsl:if>
7925+
79197926
<xsl:call-template name="refine_link-style"/>
79207927

79217928
<xsl:choose>
@@ -7938,6 +7945,10 @@
79387945
</xsl:otherwise>
79397946
</xsl:choose>
79407947
</fo:basic-link>
7948+
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
7949+
<!-- reserve space at right for PaperClip icon -->
7950+
<fo:inline keep-with-previous.within-line="always">        </fo:inline>
7951+
</xsl:if>
79417952
</xsl:with-param>
79427953
</xsl:call-template>
79437954
</xsl:otherwise>
@@ -13554,9 +13565,14 @@
1355413565
</x:xmpmeta>
1355513566
<!-- add attachments -->
1355613567
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13557-
<xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13558-
13559-
<pdf:embedded-file filename="{@name}">
13568+
<xsl:variable name="bibitem_attachment_" select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]"/>
13569+
<xsl:variable name="bibitem_attachment" select="xalan:nodeset($bibitem_attachment_)"/>
13570+
<xsl:variable name="description" select="normalize-space($bibitem_attachment/*[local-name() = 'formattedref'])"/>
13571+
<xsl:variable name="filename" select="java:org.metanorma.fop.Util.getFilenameFromPath(@name)"/>
13572+
<!-- Todo: need update -->
13573+
<xsl:variable name="afrelationship" select="normalize-space($bibitem_attachment//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13574+
13575+
<pdf:embedded-file filename="{$filename}" link-as-file-annotation="true">
1356013576
<xsl:attribute name="src">
1356113577
<xsl:choose>
1356213578
<xsl:when test="normalize-space() != ''">
@@ -13572,18 +13588,27 @@
1357213588
<xsl:if test="$description != ''">
1357313589
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
1357413590
</xsl:if>
13591+
<xsl:if test="$afrelationship != ''">
13592+
<xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13593+
</xsl:if>
1357513594
</pdf:embedded-file>
1357613595
</xsl:for-each>
1357713596
<!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
1357813597
<xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
1357913598
<xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
1358013599
<xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13600+
<xsl:variable name="attachment_name" select="java:org.metanorma.fop.Util.getFilenameFromPath($attachment_path)"/>
1358113601
<xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
1358213602
<xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13583-
<pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13603+
<!-- Todo: need update -->
13604+
<xsl:variable name="afrelationship" select="normalize-space(.//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13605+
<pdf:embedded-file src="{$url}" filename="{$attachment_name}" link-as-file-annotation="true">
1358413606
<xsl:if test="$description != ''">
1358513607
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
1358613608
</xsl:if>
13609+
<xsl:if test="$afrelationship != ''">
13610+
<xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13611+
</xsl:if>
1358713612
</pdf:embedded-file>
1358813613
</xsl:for-each>
1358913614
</xsl:if>

0 commit comments

Comments
 (0)