metanorma-bipm 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e64338ce855335c62f1d91866164719bc27d51fba3da87c05a0a2742fd616f1
4
- data.tar.gz: 2a0b624bf5af319f0b6d07a722c2cc8548ea94d08ae51afb1251de6219ad7bd5
3
+ metadata.gz: 6f2860d170a21d818995f635d165afd1c435009e0f926b3128b65b6a8a61af84
4
+ data.tar.gz: 7ad03681383997aaaf7564c6bed4aff8b89edda2369d57bac524c7ffd8c8a868
5
5
  SHA512:
6
- metadata.gz: a6f425f80f2b93e33ae13331e3fd808f7a25f81621d54c2af65377457173621c03598886c54f0982105e44f60f1506cb40b4c7bcce76226aacb5934569808236
7
- data.tar.gz: 1bd5e4718c7e410f270c3f23d66204c0b174725b23eb467b55acc38b619066fff62e19ea28e382984558120bbaa9f0ff7349f47caf0c6d404d130ba0cfc59932
6
+ metadata.gz: 77e39b7acfef85548a41345ffbd60a7b0e3b1c1baf36fe792f0950f3c3d832d180972a67546767a6d8b42e08280352d50045d355122ccad0c1f1884fb763f2e9
7
+ data.tar.gz: bd2de69e4ab5e55b84d10972e8cd53d495d502b2606d09a3d2b23c37b981813f509465de7977ec5584768c4c01cf3943419102879d9fae9582daebd8729d8465
@@ -10025,6 +10025,12 @@
10025
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10026
10026
  <attachment filename="{@name}"/>
10027
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>
10028
10034
  </xsl:variable>
10029
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10030
10036
 
@@ -10037,7 +10043,7 @@
10037
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10038
10044
  </xsl:when>
10039
10045
  <!-- link to the PDF attachment -->
10040
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10041
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10042
10048
  </xsl:when>
10043
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10705,7 +10711,16 @@
10705
10711
  </xsl:variable>
10706
10712
  <xsl:variable name="img_src">
10707
10713
  <xsl:choose>
10708
- <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>
10709
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10710
10725
  </xsl:choose>
10711
10726
  </xsl:variable>
@@ -10718,7 +10733,7 @@
10718
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10719
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10720
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> -->
10721
- <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)"/>
10722
10737
  <xsl:value-of select="$scale"/>
10723
10738
  </xsl:template>
10724
10739
 
@@ -10737,7 +10752,14 @@
10737
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10738
10753
  </xsl:when>
10739
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10740
- <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>
10741
10763
  </xsl:when>
10742
10764
  <xsl:otherwise>
10743
10765
  <xsl:value-of select="@src"/>
@@ -10759,7 +10781,14 @@
10759
10781
  </xsl:when>
10760
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10761
10783
  <xsl:variable name="src">
10762
- <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>
10763
10792
  </xsl:variable>
10764
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10765
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -15556,26 +15585,37 @@
15556
15585
  </x:xmpmeta>
15557
15586
  <!-- add attachments -->
15558
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15559
- <xsl:choose>
15560
- <xsl:when test="normalize-space() != ''">
15561
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15562
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
15563
- </xsl:when>
15564
- <xsl:otherwise>
15565
- <!-- _{filename}_attachments -->
15566
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15567
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15568
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15569
- </xsl:otherwise>
15570
- </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>
15571
15607
  </xsl:for-each>
15572
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15573
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15574
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15575
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15576
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15577
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15578
- <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>
15579
15619
  </xsl:for-each>
15580
15620
  </xsl:if>
15581
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15953,7 +15993,14 @@
15953
15993
  <xsl:value-of select="$src"/>
15954
15994
  </xsl:when>
15955
15995
  <xsl:otherwise>
15956
- <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>
15957
16004
  </xsl:otherwise>
15958
16005
  </xsl:choose>
15959
16006
  </xsl:template>
@@ -10025,6 +10025,12 @@
10025
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10026
10026
  <attachment filename="{@name}"/>
10027
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>
10028
10034
  </xsl:variable>
10029
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10030
10036
 
@@ -10037,7 +10043,7 @@
10037
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10038
10044
  </xsl:when>
10039
10045
  <!-- link to the PDF attachment -->
10040
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10041
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10042
10048
  </xsl:when>
10043
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10705,7 +10711,16 @@
10705
10711
  </xsl:variable>
10706
10712
  <xsl:variable name="img_src">
10707
10713
  <xsl:choose>
10708
- <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>
10709
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10710
10725
  </xsl:choose>
10711
10726
  </xsl:variable>
@@ -10718,7 +10733,7 @@
10718
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10719
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10720
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> -->
10721
- <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)"/>
10722
10737
  <xsl:value-of select="$scale"/>
10723
10738
  </xsl:template>
10724
10739
 
@@ -10737,7 +10752,14 @@
10737
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10738
10753
  </xsl:when>
10739
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10740
- <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>
10741
10763
  </xsl:when>
10742
10764
  <xsl:otherwise>
10743
10765
  <xsl:value-of select="@src"/>
@@ -10759,7 +10781,14 @@
10759
10781
  </xsl:when>
10760
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10761
10783
  <xsl:variable name="src">
10762
- <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>
10763
10792
  </xsl:variable>
10764
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10765
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -15556,26 +15585,37 @@
15556
15585
  </x:xmpmeta>
15557
15586
  <!-- add attachments -->
15558
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15559
- <xsl:choose>
15560
- <xsl:when test="normalize-space() != ''">
15561
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15562
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
15563
- </xsl:when>
15564
- <xsl:otherwise>
15565
- <!-- _{filename}_attachments -->
15566
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15567
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15568
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15569
- </xsl:otherwise>
15570
- </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>
15571
15607
  </xsl:for-each>
15572
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15573
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15574
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15575
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15576
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15577
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15578
- <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>
15579
15619
  </xsl:for-each>
15580
15620
  </xsl:if>
15581
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15953,7 +15993,14 @@
15953
15993
  <xsl:value-of select="$src"/>
15954
15994
  </xsl:when>
15955
15995
  <xsl:otherwise>
15956
- <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>
15957
16004
  </xsl:otherwise>
15958
16005
  </xsl:choose>
15959
16006
  </xsl:template>
@@ -10025,6 +10025,12 @@
10025
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10026
10026
  <attachment filename="{@name}"/>
10027
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>
10028
10034
  </xsl:variable>
10029
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10030
10036
 
@@ -10037,7 +10043,7 @@
10037
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10038
10044
  </xsl:when>
10039
10045
  <!-- link to the PDF attachment -->
10040
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10041
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10042
10048
  </xsl:when>
10043
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10705,7 +10711,16 @@
10705
10711
  </xsl:variable>
10706
10712
  <xsl:variable name="img_src">
10707
10713
  <xsl:choose>
10708
- <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>
10709
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10710
10725
  </xsl:choose>
10711
10726
  </xsl:variable>
@@ -10718,7 +10733,7 @@
10718
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10719
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10720
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> -->
10721
- <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)"/>
10722
10737
  <xsl:value-of select="$scale"/>
10723
10738
  </xsl:template>
10724
10739
 
@@ -10737,7 +10752,14 @@
10737
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10738
10753
  </xsl:when>
10739
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10740
- <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>
10741
10763
  </xsl:when>
10742
10764
  <xsl:otherwise>
10743
10765
  <xsl:value-of select="@src"/>
@@ -10759,7 +10781,14 @@
10759
10781
  </xsl:when>
10760
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10761
10783
  <xsl:variable name="src">
10762
- <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>
10763
10792
  </xsl:variable>
10764
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10765
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -15556,26 +15585,37 @@
15556
15585
  </x:xmpmeta>
15557
15586
  <!-- add attachments -->
15558
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15559
- <xsl:choose>
15560
- <xsl:when test="normalize-space() != ''">
15561
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15562
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
15563
- </xsl:when>
15564
- <xsl:otherwise>
15565
- <!-- _{filename}_attachments -->
15566
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15567
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15568
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15569
- </xsl:otherwise>
15570
- </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>
15571
15607
  </xsl:for-each>
15572
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15573
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15574
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15575
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15576
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15577
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15578
- <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>
15579
15619
  </xsl:for-each>
15580
15620
  </xsl:if>
15581
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15953,7 +15993,14 @@
15953
15993
  <xsl:value-of select="$src"/>
15954
15994
  </xsl:when>
15955
15995
  <xsl:otherwise>
15956
- <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>
15957
16004
  </xsl:otherwise>
15958
16005
  </xsl:choose>
15959
16006
  </xsl:template>
@@ -10025,6 +10025,12 @@
10025
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10026
10026
  <attachment filename="{@name}"/>
10027
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>
10028
10034
  </xsl:variable>
10029
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10030
10036
 
@@ -10037,7 +10043,7 @@
10037
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10038
10044
  </xsl:when>
10039
10045
  <!-- link to the PDF attachment -->
10040
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10041
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10042
10048
  </xsl:when>
10043
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10705,7 +10711,16 @@
10705
10711
  </xsl:variable>
10706
10712
  <xsl:variable name="img_src">
10707
10713
  <xsl:choose>
10708
- <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>
10709
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10710
10725
  </xsl:choose>
10711
10726
  </xsl:variable>
@@ -10718,7 +10733,7 @@
10718
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10719
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10720
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> -->
10721
- <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)"/>
10722
10737
  <xsl:value-of select="$scale"/>
10723
10738
  </xsl:template>
10724
10739
 
@@ -10737,7 +10752,14 @@
10737
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10738
10753
  </xsl:when>
10739
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10740
- <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>
10741
10763
  </xsl:when>
10742
10764
  <xsl:otherwise>
10743
10765
  <xsl:value-of select="@src"/>
@@ -10759,7 +10781,14 @@
10759
10781
  </xsl:when>
10760
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10761
10783
  <xsl:variable name="src">
10762
- <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>
10763
10792
  </xsl:variable>
10764
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10765
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -15556,26 +15585,37 @@
15556
15585
  </x:xmpmeta>
15557
15586
  <!-- add attachments -->
15558
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15559
- <xsl:choose>
15560
- <xsl:when test="normalize-space() != ''">
15561
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15562
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
15563
- </xsl:when>
15564
- <xsl:otherwise>
15565
- <!-- _{filename}_attachments -->
15566
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15567
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15568
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15569
- </xsl:otherwise>
15570
- </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>
15571
15607
  </xsl:for-each>
15572
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15573
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15574
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15575
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15576
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15577
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15578
- <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>
15579
15619
  </xsl:for-each>
15580
15620
  </xsl:if>
15581
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15953,7 +15993,14 @@
15953
15993
  <xsl:value-of select="$src"/>
15954
15994
  </xsl:when>
15955
15995
  <xsl:otherwise>
15956
- <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>
15957
16004
  </xsl:otherwise>
15958
16005
  </xsl:choose>
15959
16006
  </xsl:template>
@@ -7934,6 +7934,12 @@
7934
7934
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7935
7935
  <attachment filename="{@name}"/>
7936
7936
  </xsl:for-each>
7937
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
7938
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
7939
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
7940
+ <attachment filename="{$attachment_path}"/>
7941
+ </xsl:for-each>
7942
+ </xsl:if>
7937
7943
  </xsl:variable>
7938
7944
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7939
7945
 
@@ -7946,7 +7952,7 @@
7946
7952
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7947
7953
  </xsl:when>
7948
7954
  <!-- link to the PDF attachment -->
7949
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7955
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
7950
7956
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7951
7957
  </xsl:when>
7952
7958
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -8595,7 +8601,16 @@
8595
8601
  </xsl:variable>
8596
8602
  <xsl:variable name="img_src">
8597
8603
  <xsl:choose>
8598
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8604
+ <xsl:when test="not(starts-with(@src, 'data:'))">
8605
+ <xsl:choose>
8606
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8607
+ <xsl:value-of select="@src"/>
8608
+ </xsl:when>
8609
+ <xsl:otherwise>
8610
+ <xsl:value-of select="concat($basepath, @src)"/>
8611
+ </xsl:otherwise>
8612
+ </xsl:choose>
8613
+ </xsl:when>
8599
8614
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8600
8615
  </xsl:choose>
8601
8616
  </xsl:variable>
@@ -8608,7 +8623,7 @@
8608
8623
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8609
8624
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8610
8625
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8611
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8626
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8612
8627
  <xsl:value-of select="$scale"/>
8613
8628
  </xsl:template>
8614
8629
 
@@ -8627,7 +8642,14 @@
8627
8642
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8628
8643
  </xsl:when>
8629
8644
  <xsl:when test="not(starts-with(@src, 'data:'))">
8630
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8645
+ <xsl:choose>
8646
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8647
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8648
+ </xsl:when>
8649
+ <xsl:otherwise>
8650
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8651
+ </xsl:otherwise>
8652
+ </xsl:choose>
8631
8653
  </xsl:when>
8632
8654
  <xsl:otherwise>
8633
8655
  <xsl:value-of select="@src"/>
@@ -8649,7 +8671,14 @@
8649
8671
  </xsl:when>
8650
8672
  <xsl:when test="not(starts-with(@src, 'data:'))">
8651
8673
  <xsl:variable name="src">
8652
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8674
+ <xsl:choose>
8675
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8676
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8677
+ </xsl:when>
8678
+ <xsl:otherwise>
8679
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8680
+ </xsl:otherwise>
8681
+ </xsl:choose>
8653
8682
  </xsl:variable>
8654
8683
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
8655
8684
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13445,26 +13474,37 @@
13445
13474
  </x:xmpmeta>
13446
13475
  <!-- add attachments -->
13447
13476
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13448
- <xsl:choose>
13449
- <xsl:when test="normalize-space() != ''">
13450
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13451
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
13452
- </xsl:when>
13453
- <xsl:otherwise>
13454
- <!-- _{filename}_attachments -->
13455
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13456
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13457
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
13458
- </xsl:otherwise>
13459
- </xsl:choose>
13477
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13478
+
13479
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
13480
+ <xsl:attribute name="src">
13481
+ <xsl:choose>
13482
+ <xsl:when test="normalize-space() != ''">
13483
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13484
+ <xsl:value-of select="$src_attachment"/>
13485
+ </xsl:when>
13486
+ <xsl:otherwise>
13487
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13488
+ <xsl:value-of select="$url"/>
13489
+ </xsl:otherwise>
13490
+ </xsl:choose>
13491
+ </xsl:attribute>
13492
+ <xsl:if test="$description != ''">
13493
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13494
+ </xsl:if>
13495
+ </pdf:embedded-file>
13460
13496
  </xsl:for-each>
13461
13497
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13462
13498
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13463
13499
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13464
13500
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13465
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13466
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13467
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
13501
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13502
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13503
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
13504
+ <xsl:if test="$description != ''">
13505
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13506
+ </xsl:if>
13507
+ </pdf:embedded-file>
13468
13508
  </xsl:for-each>
13469
13509
  </xsl:if>
13470
13510
  </xsl:template> <!-- addPDFUAmeta -->
@@ -13842,7 +13882,14 @@
13842
13882
  <xsl:value-of select="$src"/>
13843
13883
  </xsl:when>
13844
13884
  <xsl:otherwise>
13845
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
13885
+ <xsl:choose>
13886
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
13887
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
13888
+ </xsl:when>
13889
+ <xsl:otherwise>
13890
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
13891
+ </xsl:otherwise>
13892
+ </xsl:choose>
13846
13893
  </xsl:otherwise>
13847
13894
  </xsl:choose>
13848
13895
  </xsl:template>
@@ -21,7 +21,7 @@ module IsoDoc
21
21
  "bipm.#{doctype}.xsl"
22
22
  end
23
23
 
24
- def pdf_options(docxml)
24
+ def pdf_options(docxml, filename)
25
25
  n = configuration.document_namespace
26
26
  q = "//m:bipm-standard/m:bibdata/m:language[@current = 'true']"
27
27
  if docxml.root.name == "metanorma-collection" &&
@@ -1000,14 +1000,14 @@
1000
1000
  <define name="PureTextElement">
1001
1001
  <choice>
1002
1002
  <text/>
1003
- <ref name="em"/>
1004
- <ref name="strong"/>
1003
+ <ref name="pure_em"/>
1004
+ <ref name="pure_strong"/>
1005
1005
  <ref name="sub"/>
1006
1006
  <ref name="sup"/>
1007
- <ref name="tt"/>
1008
- <ref name="underline"/>
1009
- <ref name="strike"/>
1010
- <ref name="smallcap"/>
1007
+ <ref name="pure_tt"/>
1008
+ <ref name="pure_underline"/>
1009
+ <ref name="pure_strike"/>
1010
+ <ref name="pure_smallcap"/>
1011
1011
  <ref name="br"/>
1012
1012
  </choice>
1013
1013
  </define>
@@ -1031,6 +1031,13 @@
1031
1031
  </zeroOrMore>
1032
1032
  </element>
1033
1033
  </define>
1034
+ <define name="pure_em">
1035
+ <element name="em">
1036
+ <zeroOrMore>
1037
+ <ref name="PureTextElement"/>
1038
+ </zeroOrMore>
1039
+ </element>
1040
+ </define>
1034
1041
  <define name="strong">
1035
1042
  <element name="strong">
1036
1043
  <zeroOrMore>
@@ -1046,6 +1053,13 @@
1046
1053
  </zeroOrMore>
1047
1054
  </element>
1048
1055
  </define>
1056
+ <define name="pure_strong">
1057
+ <element name="strong">
1058
+ <zeroOrMore>
1059
+ <ref name="PureTextElement"/>
1060
+ </zeroOrMore>
1061
+ </element>
1062
+ </define>
1049
1063
  <define name="tt">
1050
1064
  <element name="tt">
1051
1065
  <zeroOrMore>
@@ -1060,6 +1074,13 @@
1060
1074
  </zeroOrMore>
1061
1075
  </element>
1062
1076
  </define>
1077
+ <define name="pure_tt">
1078
+ <element name="tt">
1079
+ <zeroOrMore>
1080
+ <ref name="PureTextElement"/>
1081
+ </zeroOrMore>
1082
+ </element>
1083
+ </define>
1063
1084
  <define name="keyword">
1064
1085
  <element name="keyword">
1065
1086
  <zeroOrMore>
@@ -1090,13 +1111,42 @@
1090
1111
  <zeroOrMore>
1091
1112
  <choice>
1092
1113
  <ref name="PureTextElement"/>
1114
+ <ref name="stem"/>
1115
+ <ref name="eref"/>
1116
+ <ref name="xref"/>
1117
+ <ref name="hyperlink"/>
1093
1118
  <ref name="index"/>
1094
1119
  <ref name="index-xref"/>
1095
1120
  </choice>
1096
1121
  </zeroOrMore>
1097
1122
  </element>
1098
1123
  </define>
1124
+ <define name="pure_strike">
1125
+ <element name="strike">
1126
+ <zeroOrMore>
1127
+ <ref name="PureTextElement"/>
1128
+ </zeroOrMore>
1129
+ </element>
1130
+ </define>
1099
1131
  <define name="underline">
1132
+ <element name="underline">
1133
+ <optional>
1134
+ <attribute name="style"/>
1135
+ </optional>
1136
+ <zeroOrMore>
1137
+ <choice>
1138
+ <ref name="PureTextElement"/>
1139
+ <ref name="stem"/>
1140
+ <ref name="eref"/>
1141
+ <ref name="xref"/>
1142
+ <ref name="hyperlink"/>
1143
+ <ref name="index"/>
1144
+ <ref name="index-xref"/>
1145
+ </choice>
1146
+ </zeroOrMore>
1147
+ </element>
1148
+ </define>
1149
+ <define name="pure_underline">
1100
1150
  <element name="underline">
1101
1151
  <optional>
1102
1152
  <attribute name="style"/>
@@ -1107,6 +1157,21 @@
1107
1157
  </element>
1108
1158
  </define>
1109
1159
  <define name="smallcap">
1160
+ <element name="smallcap">
1161
+ <zeroOrMore>
1162
+ <choice>
1163
+ <ref name="PureTextElement"/>
1164
+ <ref name="stem"/>
1165
+ <ref name="eref"/>
1166
+ <ref name="xref"/>
1167
+ <ref name="hyperlink"/>
1168
+ <ref name="index"/>
1169
+ <ref name="index-xref"/>
1170
+ </choice>
1171
+ </zeroOrMore>
1172
+ </element>
1173
+ </define>
1174
+ <define name="pure_smallcap">
1110
1175
  <element name="smallcap">
1111
1176
  <zeroOrMore>
1112
1177
  <ref name="PureTextElement"/>
@@ -1204,7 +1204,9 @@
1204
1204
  <optional>
1205
1205
  <ref name="formattedref"/>
1206
1206
  </optional>
1207
- <ref name="btitle"/>
1207
+ <oneOrMore>
1208
+ <ref name="btitle"/>
1209
+ </oneOrMore>
1208
1210
  <optional>
1209
1211
  <ref name="bplace"/>
1210
1212
  </optional>
@@ -662,6 +662,9 @@
662
662
  <value>LatexMath</value>
663
663
  </choice>
664
664
  </attribute>
665
+ <optional>
666
+ <attribute name="number-format"/>
667
+ </optional>
665
668
  <attribute name="block">
666
669
  <data type="boolean"/>
667
670
  </attribute>
@@ -66,6 +66,9 @@
66
66
  <ref name="MultilingualRenderingType"/>
67
67
  </attribute>
68
68
  </optional>
69
+ <optional>
70
+ <attribute name="class"/>
71
+ </optional>
69
72
  <optional>
70
73
  <ref name="reqtitle"/>
71
74
  </optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.5.0".freeze
3
+ VERSION = "2.5.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-19 00:00:00.000000000 Z
11
+ date: 2024-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic