@@ -12373,14 +12373,16 @@
12373
12373
<xsl:template match="*[local-name()='link']" name="link">
12374
12374
<xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
12375
12375
<xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
12376
+ <xsl:variable name="isLinkToEmbeddedFile" select="normalize-space(@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target])"/>
12376
12377
<xsl:variable name="target">
12377
12378
<xsl:choose>
12378
12379
<xsl:when test="@updatetype = 'true'">
12379
12380
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
12380
12381
</xsl:when>
12381
12382
<!-- link to the PDF attachment -->
12382
- <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
12383
- <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
12383
+ <xsl:when test="$isLinkToEmbeddedFile = 'true'">
12384
+ <xsl:variable name="target_file" select="java:org.metanorma.fop.Util.getFilenameFromPath(@target)"/>
12385
+ <xsl:value-of select="concat('url(embedded-file:', $target_file, ')')"/>
12384
12386
</xsl:when>
12385
12387
<!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
12386
12388
<xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
12411
12413
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
12412
12414
</xsl:if>
12413
12415
12416
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
12417
+ <xsl:attribute name="color">inherit</xsl:attribute>
12418
+ <xsl:attribute name="text-decoration">none</xsl:attribute>
12419
+ </xsl:if>
12420
+
12414
12421
<xsl:call-template name="refine_link-style"/>
12415
12422
12416
12423
<xsl:choose>
12433
12440
</xsl:otherwise>
12434
12441
</xsl:choose>
12435
12442
</fo:basic-link>
12443
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
12444
+ <!-- reserve space at right for PaperClip icon -->
12445
+ <fo:inline keep-with-previous.within-line="always">        </fo:inline>
12446
+ </xsl:if>
12436
12447
</xsl:with-param>
12437
12448
</xsl:call-template>
12438
12449
</xsl:otherwise>
19795
19806
</x:xmpmeta>
19796
19807
<!-- add attachments -->
19797
19808
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
19798
- <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
19809
+ <xsl:variable name="bibitem_attachment_" select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]"/>
19810
+ <xsl:variable name="bibitem_attachment" select="xalan:nodeset($bibitem_attachment_)"/>
19811
+ <xsl:variable name="description" select="normalize-space($bibitem_attachment/*[local-name() = 'formattedref'])"/>
19812
+ <xsl:variable name="filename" select="java:org.metanorma.fop.Util.getFilenameFromPath(@name)"/>
19813
+ <!-- Todo: need update -->
19814
+ <xsl:variable name="afrelationship" select="normalize-space($bibitem_attachment//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
19799
19815
19800
- <pdf:embedded-file filename="{@name }" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
19816
+ <pdf:embedded-file filename="{$filename }" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" link-as-file-annotation="true ">
19801
19817
<xsl:attribute name="src">
19802
19818
<xsl:choose>
19803
19819
<xsl:when test="normalize-space() != ''">
@@ -19813,18 +19829,27 @@
19813
19829
<xsl:if test="$description != ''">
19814
19830
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
19815
19831
</xsl:if>
19832
+ <xsl:if test="$afrelationship != ''">
19833
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
19834
+ </xsl:if>
19816
19835
</pdf:embedded-file>
19817
19836
</xsl:for-each>
19818
19837
<!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
19819
19838
<xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
19820
19839
<xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
19821
19840
<xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
19841
+ <xsl:variable name="attachment_name" select="java:org.metanorma.fop.Util.getFilenameFromPath($attachment_path)"/>
19822
19842
<xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
19823
19843
<xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
19824
- <pdf:embedded-file src="{$url}" filename="{$attachment_path}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
19844
+ <!-- Todo: need update -->
19845
+ <xsl:variable name="afrelationship" select="normalize-space(.//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
19846
+ <pdf:embedded-file src="{$url}" filename="{$attachment_name}" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" link-as-file-annotation="true">
19825
19847
<xsl:if test="$description != ''">
19826
19848
<xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
19827
19849
</xsl:if>
19850
+ <xsl:if test="$afrelationship != ''">
19851
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
19852
+ </xsl:if>
19828
19853
</pdf:embedded-file>
19829
19854
</xsl:for-each>
19830
19855
</xsl:if>
0 commit comments