metanorma-ogc 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8103,6 +8103,12 @@
8103
8103
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8104
8104
  <attachment filename="{@name}"/>
8105
8105
  </xsl:for-each>
8106
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8107
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8108
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8109
+ <attachment filename="{$attachment_path}"/>
8110
+ </xsl:for-each>
8111
+ </xsl:if>
8106
8112
  </xsl:variable>
8107
8113
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8108
8114
 
@@ -8115,7 +8121,7 @@
8115
8121
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8116
8122
  </xsl:when>
8117
8123
  <!-- link to the PDF attachment -->
8118
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8124
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8119
8125
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8120
8126
  </xsl:when>
8121
8127
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -8770,7 +8776,16 @@
8770
8776
  </xsl:variable>
8771
8777
  <xsl:variable name="img_src">
8772
8778
  <xsl:choose>
8773
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8779
+ <xsl:when test="not(starts-with(@src, 'data:'))">
8780
+ <xsl:choose>
8781
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8782
+ <xsl:value-of select="@src"/>
8783
+ </xsl:when>
8784
+ <xsl:otherwise>
8785
+ <xsl:value-of select="concat($basepath, @src)"/>
8786
+ </xsl:otherwise>
8787
+ </xsl:choose>
8788
+ </xsl:when>
8774
8789
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8775
8790
  </xsl:choose>
8776
8791
  </xsl:variable>
@@ -8783,7 +8798,7 @@
8783
8798
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8784
8799
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8785
8800
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8786
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8801
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8787
8802
  <xsl:value-of select="$scale"/>
8788
8803
  </xsl:template>
8789
8804
 
@@ -8802,7 +8817,14 @@
8802
8817
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8803
8818
  </xsl:when>
8804
8819
  <xsl:when test="not(starts-with(@src, 'data:'))">
8805
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8820
+ <xsl:choose>
8821
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8822
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8823
+ </xsl:when>
8824
+ <xsl:otherwise>
8825
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8826
+ </xsl:otherwise>
8827
+ </xsl:choose>
8806
8828
  </xsl:when>
8807
8829
  <xsl:otherwise>
8808
8830
  <xsl:value-of select="@src"/>
@@ -8824,7 +8846,14 @@
8824
8846
  </xsl:when>
8825
8847
  <xsl:when test="not(starts-with(@src, 'data:'))">
8826
8848
  <xsl:variable name="src">
8827
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8849
+ <xsl:choose>
8850
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8851
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8852
+ </xsl:when>
8853
+ <xsl:otherwise>
8854
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8855
+ </xsl:otherwise>
8856
+ </xsl:choose>
8828
8857
  </xsl:variable>
8829
8858
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
8830
8859
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13659,26 +13688,37 @@
13659
13688
  </x:xmpmeta>
13660
13689
  <!-- add attachments -->
13661
13690
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13662
- <xsl:choose>
13663
- <xsl:when test="normalize-space() != ''">
13664
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13665
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
13666
- </xsl:when>
13667
- <xsl:otherwise>
13668
- <!-- _{filename}_attachments -->
13669
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13670
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13671
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
13672
- </xsl:otherwise>
13673
- </xsl:choose>
13691
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13692
+
13693
+ <pdf:embedded-file filename="{@name}">
13694
+ <xsl:attribute name="src">
13695
+ <xsl:choose>
13696
+ <xsl:when test="normalize-space() != ''">
13697
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13698
+ <xsl:value-of select="$src_attachment"/>
13699
+ </xsl:when>
13700
+ <xsl:otherwise>
13701
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13702
+ <xsl:value-of select="$url"/>
13703
+ </xsl:otherwise>
13704
+ </xsl:choose>
13705
+ </xsl:attribute>
13706
+ <xsl:if test="$description != ''">
13707
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13708
+ </xsl:if>
13709
+ </pdf:embedded-file>
13674
13710
  </xsl:for-each>
13675
13711
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13676
13712
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13677
13713
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13678
13714
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13679
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13680
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13681
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
13715
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13716
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13717
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13718
+ <xsl:if test="$description != ''">
13719
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13720
+ </xsl:if>
13721
+ </pdf:embedded-file>
13682
13722
  </xsl:for-each>
13683
13723
  </xsl:if>
13684
13724
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14056,7 +14096,14 @@
14056
14096
  <xsl:value-of select="$src"/>
14057
14097
  </xsl:when>
14058
14098
  <xsl:otherwise>
14059
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14099
+ <xsl:choose>
14100
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14101
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14102
+ </xsl:when>
14103
+ <xsl:otherwise>
14104
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14105
+ </xsl:otherwise>
14106
+ </xsl:choose>
14060
14107
  </xsl:otherwise>
14061
14108
  </xsl:choose>
14062
14109
  </xsl:template>
@@ -8103,6 +8103,12 @@
8103
8103
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8104
8104
  <attachment filename="{@name}"/>
8105
8105
  </xsl:for-each>
8106
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8107
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8108
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8109
+ <attachment filename="{$attachment_path}"/>
8110
+ </xsl:for-each>
8111
+ </xsl:if>
8106
8112
  </xsl:variable>
8107
8113
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8108
8114
 
@@ -8115,7 +8121,7 @@
8115
8121
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8116
8122
  </xsl:when>
8117
8123
  <!-- link to the PDF attachment -->
8118
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8124
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8119
8125
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8120
8126
  </xsl:when>
8121
8127
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -8770,7 +8776,16 @@
8770
8776
  </xsl:variable>
8771
8777
  <xsl:variable name="img_src">
8772
8778
  <xsl:choose>
8773
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8779
+ <xsl:when test="not(starts-with(@src, 'data:'))">
8780
+ <xsl:choose>
8781
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8782
+ <xsl:value-of select="@src"/>
8783
+ </xsl:when>
8784
+ <xsl:otherwise>
8785
+ <xsl:value-of select="concat($basepath, @src)"/>
8786
+ </xsl:otherwise>
8787
+ </xsl:choose>
8788
+ </xsl:when>
8774
8789
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8775
8790
  </xsl:choose>
8776
8791
  </xsl:variable>
@@ -8783,7 +8798,7 @@
8783
8798
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8784
8799
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8785
8800
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8786
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8801
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8787
8802
  <xsl:value-of select="$scale"/>
8788
8803
  </xsl:template>
8789
8804
 
@@ -8802,7 +8817,14 @@
8802
8817
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8803
8818
  </xsl:when>
8804
8819
  <xsl:when test="not(starts-with(@src, 'data:'))">
8805
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8820
+ <xsl:choose>
8821
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8822
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8823
+ </xsl:when>
8824
+ <xsl:otherwise>
8825
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8826
+ </xsl:otherwise>
8827
+ </xsl:choose>
8806
8828
  </xsl:when>
8807
8829
  <xsl:otherwise>
8808
8830
  <xsl:value-of select="@src"/>
@@ -8824,7 +8846,14 @@
8824
8846
  </xsl:when>
8825
8847
  <xsl:when test="not(starts-with(@src, 'data:'))">
8826
8848
  <xsl:variable name="src">
8827
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8849
+ <xsl:choose>
8850
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8851
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8852
+ </xsl:when>
8853
+ <xsl:otherwise>
8854
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8855
+ </xsl:otherwise>
8856
+ </xsl:choose>
8828
8857
  </xsl:variable>
8829
8858
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
8830
8859
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13659,26 +13688,37 @@
13659
13688
  </x:xmpmeta>
13660
13689
  <!-- add attachments -->
13661
13690
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13662
- <xsl:choose>
13663
- <xsl:when test="normalize-space() != ''">
13664
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13665
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
13666
- </xsl:when>
13667
- <xsl:otherwise>
13668
- <!-- _{filename}_attachments -->
13669
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13670
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13671
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
13672
- </xsl:otherwise>
13673
- </xsl:choose>
13691
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13692
+
13693
+ <pdf:embedded-file filename="{@name}">
13694
+ <xsl:attribute name="src">
13695
+ <xsl:choose>
13696
+ <xsl:when test="normalize-space() != ''">
13697
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13698
+ <xsl:value-of select="$src_attachment"/>
13699
+ </xsl:when>
13700
+ <xsl:otherwise>
13701
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13702
+ <xsl:value-of select="$url"/>
13703
+ </xsl:otherwise>
13704
+ </xsl:choose>
13705
+ </xsl:attribute>
13706
+ <xsl:if test="$description != ''">
13707
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13708
+ </xsl:if>
13709
+ </pdf:embedded-file>
13674
13710
  </xsl:for-each>
13675
13711
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13676
13712
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13677
13713
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13678
13714
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13679
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13680
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13681
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
13715
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13716
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13717
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13718
+ <xsl:if test="$description != ''">
13719
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13720
+ </xsl:if>
13721
+ </pdf:embedded-file>
13682
13722
  </xsl:for-each>
13683
13723
  </xsl:if>
13684
13724
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14056,7 +14096,14 @@
14056
14096
  <xsl:value-of select="$src"/>
14057
14097
  </xsl:when>
14058
14098
  <xsl:otherwise>
14059
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14099
+ <xsl:choose>
14100
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14101
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14102
+ </xsl:when>
14103
+ <xsl:otherwise>
14104
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14105
+ </xsl:otherwise>
14106
+ </xsl:choose>
14060
14107
  </xsl:otherwise>
14061
14108
  </xsl:choose>
14062
14109
  </xsl:template>
@@ -8103,6 +8103,12 @@
8103
8103
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8104
8104
  <attachment filename="{@name}"/>
8105
8105
  </xsl:for-each>
8106
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8107
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8108
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8109
+ <attachment filename="{$attachment_path}"/>
8110
+ </xsl:for-each>
8111
+ </xsl:if>
8106
8112
  </xsl:variable>
8107
8113
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8108
8114
 
@@ -8115,7 +8121,7 @@
8115
8121
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8116
8122
  </xsl:when>
8117
8123
  <!-- link to the PDF attachment -->
8118
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8124
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8119
8125
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8120
8126
  </xsl:when>
8121
8127
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -8770,7 +8776,16 @@
8770
8776
  </xsl:variable>
8771
8777
  <xsl:variable name="img_src">
8772
8778
  <xsl:choose>
8773
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8779
+ <xsl:when test="not(starts-with(@src, 'data:'))">
8780
+ <xsl:choose>
8781
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8782
+ <xsl:value-of select="@src"/>
8783
+ </xsl:when>
8784
+ <xsl:otherwise>
8785
+ <xsl:value-of select="concat($basepath, @src)"/>
8786
+ </xsl:otherwise>
8787
+ </xsl:choose>
8788
+ </xsl:when>
8774
8789
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8775
8790
  </xsl:choose>
8776
8791
  </xsl:variable>
@@ -8783,7 +8798,7 @@
8783
8798
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8784
8799
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8785
8800
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8786
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8801
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8787
8802
  <xsl:value-of select="$scale"/>
8788
8803
  </xsl:template>
8789
8804
 
@@ -8802,7 +8817,14 @@
8802
8817
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8803
8818
  </xsl:when>
8804
8819
  <xsl:when test="not(starts-with(@src, 'data:'))">
8805
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8820
+ <xsl:choose>
8821
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8822
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8823
+ </xsl:when>
8824
+ <xsl:otherwise>
8825
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8826
+ </xsl:otherwise>
8827
+ </xsl:choose>
8806
8828
  </xsl:when>
8807
8829
  <xsl:otherwise>
8808
8830
  <xsl:value-of select="@src"/>
@@ -8824,7 +8846,14 @@
8824
8846
  </xsl:when>
8825
8847
  <xsl:when test="not(starts-with(@src, 'data:'))">
8826
8848
  <xsl:variable name="src">
8827
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8849
+ <xsl:choose>
8850
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8851
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8852
+ </xsl:when>
8853
+ <xsl:otherwise>
8854
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8855
+ </xsl:otherwise>
8856
+ </xsl:choose>
8828
8857
  </xsl:variable>
8829
8858
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
8830
8859
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13659,26 +13688,37 @@
13659
13688
  </x:xmpmeta>
13660
13689
  <!-- add attachments -->
13661
13690
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13662
- <xsl:choose>
13663
- <xsl:when test="normalize-space() != ''">
13664
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13665
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
13666
- </xsl:when>
13667
- <xsl:otherwise>
13668
- <!-- _{filename}_attachments -->
13669
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13670
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13671
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
13672
- </xsl:otherwise>
13673
- </xsl:choose>
13691
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13692
+
13693
+ <pdf:embedded-file filename="{@name}">
13694
+ <xsl:attribute name="src">
13695
+ <xsl:choose>
13696
+ <xsl:when test="normalize-space() != ''">
13697
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13698
+ <xsl:value-of select="$src_attachment"/>
13699
+ </xsl:when>
13700
+ <xsl:otherwise>
13701
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13702
+ <xsl:value-of select="$url"/>
13703
+ </xsl:otherwise>
13704
+ </xsl:choose>
13705
+ </xsl:attribute>
13706
+ <xsl:if test="$description != ''">
13707
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13708
+ </xsl:if>
13709
+ </pdf:embedded-file>
13674
13710
  </xsl:for-each>
13675
13711
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13676
13712
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13677
13713
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13678
13714
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13679
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13680
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13681
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
13715
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13716
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13717
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13718
+ <xsl:if test="$description != ''">
13719
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13720
+ </xsl:if>
13721
+ </pdf:embedded-file>
13682
13722
  </xsl:for-each>
13683
13723
  </xsl:if>
13684
13724
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14056,7 +14096,14 @@
14056
14096
  <xsl:value-of select="$src"/>
14057
14097
  </xsl:when>
14058
14098
  <xsl:otherwise>
14059
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14099
+ <xsl:choose>
14100
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14101
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14102
+ </xsl:when>
14103
+ <xsl:otherwise>
14104
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14105
+ </xsl:otherwise>
14106
+ </xsl:choose>
14060
14107
  </xsl:otherwise>
14061
14108
  </xsl:choose>
14062
14109
  </xsl:template>
@@ -8103,6 +8103,12 @@
8103
8103
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8104
8104
  <attachment filename="{@name}"/>
8105
8105
  </xsl:for-each>
8106
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8107
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8108
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8109
+ <attachment filename="{$attachment_path}"/>
8110
+ </xsl:for-each>
8111
+ </xsl:if>
8106
8112
  </xsl:variable>
8107
8113
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8108
8114
 
@@ -8115,7 +8121,7 @@
8115
8121
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8116
8122
  </xsl:when>
8117
8123
  <!-- link to the PDF attachment -->
8118
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8124
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8119
8125
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8120
8126
  </xsl:when>
8121
8127
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -8770,7 +8776,16 @@
8770
8776
  </xsl:variable>
8771
8777
  <xsl:variable name="img_src">
8772
8778
  <xsl:choose>
8773
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8779
+ <xsl:when test="not(starts-with(@src, 'data:'))">
8780
+ <xsl:choose>
8781
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8782
+ <xsl:value-of select="@src"/>
8783
+ </xsl:when>
8784
+ <xsl:otherwise>
8785
+ <xsl:value-of select="concat($basepath, @src)"/>
8786
+ </xsl:otherwise>
8787
+ </xsl:choose>
8788
+ </xsl:when>
8774
8789
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8775
8790
  </xsl:choose>
8776
8791
  </xsl:variable>
@@ -8783,7 +8798,7 @@
8783
8798
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8784
8799
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8785
8800
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8786
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8801
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8787
8802
  <xsl:value-of select="$scale"/>
8788
8803
  </xsl:template>
8789
8804
 
@@ -8802,7 +8817,14 @@
8802
8817
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8803
8818
  </xsl:when>
8804
8819
  <xsl:when test="not(starts-with(@src, 'data:'))">
8805
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8820
+ <xsl:choose>
8821
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8822
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8823
+ </xsl:when>
8824
+ <xsl:otherwise>
8825
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8826
+ </xsl:otherwise>
8827
+ </xsl:choose>
8806
8828
  </xsl:when>
8807
8829
  <xsl:otherwise>
8808
8830
  <xsl:value-of select="@src"/>
@@ -8824,7 +8846,14 @@
8824
8846
  </xsl:when>
8825
8847
  <xsl:when test="not(starts-with(@src, 'data:'))">
8826
8848
  <xsl:variable name="src">
8827
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8849
+ <xsl:choose>
8850
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
8851
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
8852
+ </xsl:when>
8853
+ <xsl:otherwise>
8854
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8855
+ </xsl:otherwise>
8856
+ </xsl:choose>
8828
8857
  </xsl:variable>
8829
8858
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
8830
8859
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13659,26 +13688,37 @@
13659
13688
  </x:xmpmeta>
13660
13689
  <!-- add attachments -->
13661
13690
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13662
- <xsl:choose>
13663
- <xsl:when test="normalize-space() != ''">
13664
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13665
- <pdf:embedded-file src="{$src_attachment}" filename="{@name}"/>
13666
- </xsl:when>
13667
- <xsl:otherwise>
13668
- <!-- _{filename}_attachments -->
13669
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13670
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13671
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
13672
- </xsl:otherwise>
13673
- </xsl:choose>
13691
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13692
+
13693
+ <pdf:embedded-file filename="{@name}">
13694
+ <xsl:attribute name="src">
13695
+ <xsl:choose>
13696
+ <xsl:when test="normalize-space() != ''">
13697
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
13698
+ <xsl:value-of select="$src_attachment"/>
13699
+ </xsl:when>
13700
+ <xsl:otherwise>
13701
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13702
+ <xsl:value-of select="$url"/>
13703
+ </xsl:otherwise>
13704
+ </xsl:choose>
13705
+ </xsl:attribute>
13706
+ <xsl:if test="$description != ''">
13707
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13708
+ </xsl:if>
13709
+ </pdf:embedded-file>
13674
13710
  </xsl:for-each>
13675
13711
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13676
13712
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13677
13713
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13678
13714
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13679
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
13680
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
13681
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
13715
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13716
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13717
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13718
+ <xsl:if test="$description != ''">
13719
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13720
+ </xsl:if>
13721
+ </pdf:embedded-file>
13682
13722
  </xsl:for-each>
13683
13723
  </xsl:if>
13684
13724
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14056,7 +14096,14 @@
14056
14096
  <xsl:value-of select="$src"/>
14057
14097
  </xsl:when>
14058
14098
  <xsl:otherwise>
14059
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14099
+ <xsl:choose>
14100
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14101
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14102
+ </xsl:when>
14103
+ <xsl:otherwise>
14104
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14105
+ </xsl:otherwise>
14106
+ </xsl:choose>
14060
14107
  </xsl:otherwise>
14061
14108
  </xsl:choose>
14062
14109
  </xsl:template>