metanorma-bipm 2.4.12 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6328cc0a118035ba72b346c223c4e7e28aacdf48c5baf5a40a6de7fdc05005aa
4
- data.tar.gz: bb543f02c153a0f39a5f0291104281c9b423258933dc5add261c7b57eda81de5
3
+ metadata.gz: 6f2860d170a21d818995f635d165afd1c435009e0f926b3128b65b6a8a61af84
4
+ data.tar.gz: 7ad03681383997aaaf7564c6bed4aff8b89edda2369d57bac524c7ffd8c8a868
5
5
  SHA512:
6
- metadata.gz: 8e381d7db910aff8421d57a31da740d022bc4bb235539a74439b7096f2e11760d365996a3f4cedf79925b14a1b9681feb94387271f747b1803ee7c22ba34482e
7
- data.tar.gz: bc6cd6855b001bc0f81d46d66e82e28710fa09039c82cdab897b6e45a43e28387e5217cd6e5966772a1692c2bfc719bf4b078f9f01b0e710ddbb651e2525cef8
6
+ metadata.gz: 77e39b7acfef85548a41345ffbd60a7b0e3b1c1baf36fe792f0950f3c3d832d180972a67546767a6d8b42e08280352d50045d355122ccad0c1f1884fb763f2e9
7
+ data.tar.gz: bd2de69e4ab5e55b84d10972e8cd53d495d502b2606d09a3d2b23c37b981813f509465de7977ec5584768c4c01cf3943419102879d9fae9582daebd8729d8465
@@ -5725,13 +5725,35 @@
5725
5725
  </xsl:for-each>
5726
5726
  </xsl:element>
5727
5727
 
5728
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5728
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
5729
5729
 
5730
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5730
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
5731
5731
 
5732
5732
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5733
5733
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
5734
5734
 
5735
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexAndBibliographyInSeparatePageSequences">
5736
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
5737
+ <xsl:sort select="@displayorder" data-type="number"/>
5738
+ <xsl:choose>
5739
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
5740
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5741
+ <xsl:attribute name="main_page_sequence"/>
5742
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5743
+ </xsl:element>
5744
+ </xsl:when>
5745
+ <xsl:otherwise> <!-- bibliography -->
5746
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5747
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5748
+ <xsl:attribute name="main_page_sequence"/>
5749
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5750
+ </xsl:element>
5751
+ </xsl:element>
5752
+ </xsl:otherwise>
5753
+ </xsl:choose>
5754
+ </xsl:for-each>
5755
+ </xsl:template>
5756
+
5735
5757
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
5736
5758
  <xsl:for-each select="/*/*[local-name()='annex']">
5737
5759
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -10003,6 +10025,12 @@
10003
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10004
10026
  <attachment filename="{@name}"/>
10005
10027
  </xsl:for-each>
10028
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
10029
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
10030
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
10031
+ <attachment filename="{$attachment_path}"/>
10032
+ </xsl:for-each>
10033
+ </xsl:if>
10006
10034
  </xsl:variable>
10007
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10008
10036
 
@@ -10015,7 +10043,7 @@
10015
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10016
10044
  </xsl:when>
10017
10045
  <!-- link to the PDF attachment -->
10018
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10019
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10020
10048
  </xsl:when>
10021
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10683,7 +10711,16 @@
10683
10711
  </xsl:variable>
10684
10712
  <xsl:variable name="img_src">
10685
10713
  <xsl:choose>
10686
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
10714
+ <xsl:when test="not(starts-with(@src, 'data:'))">
10715
+ <xsl:choose>
10716
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10717
+ <xsl:value-of select="@src"/>
10718
+ </xsl:when>
10719
+ <xsl:otherwise>
10720
+ <xsl:value-of select="concat($basepath, @src)"/>
10721
+ </xsl:otherwise>
10722
+ </xsl:choose>
10723
+ </xsl:when>
10687
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10688
10725
  </xsl:choose>
10689
10726
  </xsl:variable>
@@ -10696,7 +10733,7 @@
10696
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10697
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10698
10735
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
10699
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10736
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10700
10737
  <xsl:value-of select="$scale"/>
10701
10738
  </xsl:template>
10702
10739
 
@@ -10715,7 +10752,14 @@
10715
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10716
10753
  </xsl:when>
10717
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10718
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10755
+ <xsl:choose>
10756
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10757
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10758
+ </xsl:when>
10759
+ <xsl:otherwise>
10760
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10761
+ </xsl:otherwise>
10762
+ </xsl:choose>
10719
10763
  </xsl:when>
10720
10764
  <xsl:otherwise>
10721
10765
  <xsl:value-of select="@src"/>
@@ -10737,7 +10781,14 @@
10737
10781
  </xsl:when>
10738
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10739
10783
  <xsl:variable name="src">
10740
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10784
+ <xsl:choose>
10785
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10786
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10787
+ </xsl:when>
10788
+ <xsl:otherwise>
10789
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10790
+ </xsl:otherwise>
10791
+ </xsl:choose>
10741
10792
  </xsl:variable>
10742
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10743
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14656,10 +14707,12 @@
14656
14707
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
14657
14708
  <xsl:copy>
14658
14709
  <xsl:copy-of select="@*"/>
14659
- <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14660
- <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14661
- <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14662
- <xsl:value-of select="."/>
14710
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
14711
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14712
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14713
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14714
+ <xsl:value-of select="normalize-space(.)"/>
14715
+ </xsl:if>
14663
14716
  </xsl:if>
14664
14717
  </xsl:copy>
14665
14718
  </xsl:template>
@@ -15532,25 +15585,37 @@
15532
15585
  </x:xmpmeta>
15533
15586
  <!-- add attachments -->
15534
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15535
- <xsl:choose>
15536
- <xsl:when test="normalize-space() != ''">
15537
- <pdf:embedded-file src="{.}" filename="{@name}"/>
15538
- </xsl:when>
15539
- <xsl:otherwise>
15540
- <!-- _{filename}_attachments -->
15541
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15542
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15543
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15544
- </xsl:otherwise>
15545
- </xsl:choose>
15588
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
15589
+
15590
+ <pdf:embedded-file filename="{@name}">
15591
+ <xsl:attribute name="src">
15592
+ <xsl:choose>
15593
+ <xsl:when test="normalize-space() != ''">
15594
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15595
+ <xsl:value-of select="$src_attachment"/>
15596
+ </xsl:when>
15597
+ <xsl:otherwise>
15598
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15599
+ <xsl:value-of select="$url"/>
15600
+ </xsl:otherwise>
15601
+ </xsl:choose>
15602
+ </xsl:attribute>
15603
+ <xsl:if test="$description != ''">
15604
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15605
+ </xsl:if>
15606
+ </pdf:embedded-file>
15546
15607
  </xsl:for-each>
15547
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15548
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15549
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15550
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15551
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15552
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15553
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15612
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
15613
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
15614
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
15615
+ <xsl:if test="$description != ''">
15616
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15617
+ </xsl:if>
15618
+ </pdf:embedded-file>
15554
15619
  </xsl:for-each>
15555
15620
  </xsl:if>
15556
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15928,7 +15993,14 @@
15928
15993
  <xsl:value-of select="$src"/>
15929
15994
  </xsl:when>
15930
15995
  <xsl:otherwise>
15931
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
15996
+ <xsl:choose>
15997
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
15998
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
15999
+ </xsl:when>
16000
+ <xsl:otherwise>
16001
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
16002
+ </xsl:otherwise>
16003
+ </xsl:choose>
15932
16004
  </xsl:otherwise>
15933
16005
  </xsl:choose>
15934
16006
  </xsl:template>
@@ -5725,13 +5725,35 @@
5725
5725
  </xsl:for-each>
5726
5726
  </xsl:element>
5727
5727
 
5728
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5728
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
5729
5729
 
5730
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5730
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
5731
5731
 
5732
5732
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5733
5733
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
5734
5734
 
5735
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexAndBibliographyInSeparatePageSequences">
5736
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
5737
+ <xsl:sort select="@displayorder" data-type="number"/>
5738
+ <xsl:choose>
5739
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
5740
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5741
+ <xsl:attribute name="main_page_sequence"/>
5742
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5743
+ </xsl:element>
5744
+ </xsl:when>
5745
+ <xsl:otherwise> <!-- bibliography -->
5746
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5747
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5748
+ <xsl:attribute name="main_page_sequence"/>
5749
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5750
+ </xsl:element>
5751
+ </xsl:element>
5752
+ </xsl:otherwise>
5753
+ </xsl:choose>
5754
+ </xsl:for-each>
5755
+ </xsl:template>
5756
+
5735
5757
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
5736
5758
  <xsl:for-each select="/*/*[local-name()='annex']">
5737
5759
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -10003,6 +10025,12 @@
10003
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10004
10026
  <attachment filename="{@name}"/>
10005
10027
  </xsl:for-each>
10028
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
10029
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
10030
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
10031
+ <attachment filename="{$attachment_path}"/>
10032
+ </xsl:for-each>
10033
+ </xsl:if>
10006
10034
  </xsl:variable>
10007
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10008
10036
 
@@ -10015,7 +10043,7 @@
10015
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10016
10044
  </xsl:when>
10017
10045
  <!-- link to the PDF attachment -->
10018
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10019
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10020
10048
  </xsl:when>
10021
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10683,7 +10711,16 @@
10683
10711
  </xsl:variable>
10684
10712
  <xsl:variable name="img_src">
10685
10713
  <xsl:choose>
10686
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
10714
+ <xsl:when test="not(starts-with(@src, 'data:'))">
10715
+ <xsl:choose>
10716
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10717
+ <xsl:value-of select="@src"/>
10718
+ </xsl:when>
10719
+ <xsl:otherwise>
10720
+ <xsl:value-of select="concat($basepath, @src)"/>
10721
+ </xsl:otherwise>
10722
+ </xsl:choose>
10723
+ </xsl:when>
10687
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10688
10725
  </xsl:choose>
10689
10726
  </xsl:variable>
@@ -10696,7 +10733,7 @@
10696
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10697
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10698
10735
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
10699
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10736
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10700
10737
  <xsl:value-of select="$scale"/>
10701
10738
  </xsl:template>
10702
10739
 
@@ -10715,7 +10752,14 @@
10715
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10716
10753
  </xsl:when>
10717
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10718
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10755
+ <xsl:choose>
10756
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10757
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10758
+ </xsl:when>
10759
+ <xsl:otherwise>
10760
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10761
+ </xsl:otherwise>
10762
+ </xsl:choose>
10719
10763
  </xsl:when>
10720
10764
  <xsl:otherwise>
10721
10765
  <xsl:value-of select="@src"/>
@@ -10737,7 +10781,14 @@
10737
10781
  </xsl:when>
10738
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10739
10783
  <xsl:variable name="src">
10740
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10784
+ <xsl:choose>
10785
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10786
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10787
+ </xsl:when>
10788
+ <xsl:otherwise>
10789
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10790
+ </xsl:otherwise>
10791
+ </xsl:choose>
10741
10792
  </xsl:variable>
10742
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10743
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14656,10 +14707,12 @@
14656
14707
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
14657
14708
  <xsl:copy>
14658
14709
  <xsl:copy-of select="@*"/>
14659
- <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14660
- <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14661
- <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14662
- <xsl:value-of select="."/>
14710
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
14711
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14712
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14713
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14714
+ <xsl:value-of select="normalize-space(.)"/>
14715
+ </xsl:if>
14663
14716
  </xsl:if>
14664
14717
  </xsl:copy>
14665
14718
  </xsl:template>
@@ -15532,25 +15585,37 @@
15532
15585
  </x:xmpmeta>
15533
15586
  <!-- add attachments -->
15534
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15535
- <xsl:choose>
15536
- <xsl:when test="normalize-space() != ''">
15537
- <pdf:embedded-file src="{.}" filename="{@name}"/>
15538
- </xsl:when>
15539
- <xsl:otherwise>
15540
- <!-- _{filename}_attachments -->
15541
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15542
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15543
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15544
- </xsl:otherwise>
15545
- </xsl:choose>
15588
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
15589
+
15590
+ <pdf:embedded-file filename="{@name}">
15591
+ <xsl:attribute name="src">
15592
+ <xsl:choose>
15593
+ <xsl:when test="normalize-space() != ''">
15594
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15595
+ <xsl:value-of select="$src_attachment"/>
15596
+ </xsl:when>
15597
+ <xsl:otherwise>
15598
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15599
+ <xsl:value-of select="$url"/>
15600
+ </xsl:otherwise>
15601
+ </xsl:choose>
15602
+ </xsl:attribute>
15603
+ <xsl:if test="$description != ''">
15604
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15605
+ </xsl:if>
15606
+ </pdf:embedded-file>
15546
15607
  </xsl:for-each>
15547
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15548
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15549
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15550
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15551
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15552
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15553
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15612
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
15613
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
15614
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
15615
+ <xsl:if test="$description != ''">
15616
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15617
+ </xsl:if>
15618
+ </pdf:embedded-file>
15554
15619
  </xsl:for-each>
15555
15620
  </xsl:if>
15556
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15928,7 +15993,14 @@
15928
15993
  <xsl:value-of select="$src"/>
15929
15994
  </xsl:when>
15930
15995
  <xsl:otherwise>
15931
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
15996
+ <xsl:choose>
15997
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
15998
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
15999
+ </xsl:when>
16000
+ <xsl:otherwise>
16001
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
16002
+ </xsl:otherwise>
16003
+ </xsl:choose>
15932
16004
  </xsl:otherwise>
15933
16005
  </xsl:choose>
15934
16006
  </xsl:template>