7878
7878
<xsl:template match="*[local-name()='link']" name="link">
7879
7879
<xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7880
7880
<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])"/>
7881
7882
<xsl:variable name="target">
7882
7883
<xsl:choose>
7883
7884
<xsl:when test="@updatetype = 'true'">
7884
7885
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7885
7886
</xsl:when>
7886
7887
<!-- 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, ')')"/>
7889
7891
</xsl:when>
7890
7892
<!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
7891
7893
<xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
7916
7918
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
7917
7919
</xsl:if>
7918
7920
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
+
7919
7926
<xsl:call-template name="refine_link-style"/>
7920
7927
7921
7928
<xsl:choose>
7938
7945
</xsl:otherwise>
7939
7946
</xsl:choose>
7940
7947
</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>
7941
7952
</xsl:with-param>
7942
7953
</xsl:call-template>
7943
7954
</xsl:otherwise>
13554
13565
</x:xmpmeta>
13555
13566
<!-- add attachments -->
13556
13567
<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">
13560
13576
<xsl:attribute name="src">
13561
13577
<xsl:choose>
13562
13578
<xsl:when test="normalize-space() != ''">
@@ -13572,18 +13588,27 @@
13572
13588
<xsl:if test="$description != ''">
13573
13589
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13574
13590
</xsl:if>
13591
+ <xsl:if test="$afrelationship != ''">
13592
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13593
+ </xsl:if>
13575
13594
</pdf:embedded-file>
13576
13595
</xsl:for-each>
13577
13596
<!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13578
13597
<xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13579
13598
<xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13580
13599
<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)"/>
13581
13601
<xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13582
13602
<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">
13584
13606
<xsl:if test="$description != ''">
13585
13607
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13586
13608
</xsl:if>
13609
+ <xsl:if test="$afrelationship != ''">
13610
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13611
+ </xsl:if>
13587
13612
</pdf:embedded-file>
13588
13613
</xsl:for-each>
13589
13614
</xsl:if>
0 commit comments