metanorma-itu 2.5.1 → 2.5.2

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: 615acf8f435dd85af887288f9b0f206438f0c5b8353379f121edb7d0e34c2732
4
- data.tar.gz: 584fb910f40575bed765d9b86682bbb7b8263e1cae7a6a85ba0c8c9a126dcbb9
3
+ metadata.gz: d3ecfeb1942e091d6ad7b5a7b6fdb9ebef13765a24acbd69a0149b111e8ece83
4
+ data.tar.gz: c556b6e505eb79a3b48dad7a04eb79111d8b5edc4b90fa2ee895dccb28848f9c
5
5
  SHA512:
6
- metadata.gz: fe779b6c75b234e2c0e8edecf2f35aa70912e52f8590a0605231e759c68245282d29f4c27376b9d8bfcf8f8d5aec611d785634ce51cf0118420dbc0bff234641
7
- data.tar.gz: 58b1ab38aabd1606725e49f2fc88f11b031b8f364c21112be3d0472610bee8cec37453ae6204d93989b6823de316503ea18e50c488f792e64315fa70b18eb4ea
6
+ metadata.gz: d4fc80315dbf1ee88c006dccdb75c2887315a61fdb9f6b4029bf72cd06b9033c0b697aa5720ea74371afa931369524011e82d1983ae2d1b6f0dcffc1e78c64d1
7
+ data.tar.gz: 134cf827b3c284e834f299786e4ef8b23235bcfd5b6d9e5495e2dab693e762bfff7631d9029991f4854470961bd82fd158e5bf020de5d736a3048b6111e4ae7d
@@ -8880,6 +8880,12 @@
8880
8880
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8881
8881
  <attachment filename="{@name}"/>
8882
8882
  </xsl:for-each>
8883
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8884
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8885
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8886
+ <attachment filename="{$attachment_path}"/>
8887
+ </xsl:for-each>
8888
+ </xsl:if>
8883
8889
  </xsl:variable>
8884
8890
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8885
8891
 
@@ -8892,7 +8898,7 @@
8892
8898
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8893
8899
  </xsl:when>
8894
8900
  <!-- link to the PDF attachment -->
8895
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8901
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8896
8902
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8897
8903
  </xsl:when>
8898
8904
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -9547,7 +9553,16 @@
9547
9553
  </xsl:variable>
9548
9554
  <xsl:variable name="img_src">
9549
9555
  <xsl:choose>
9550
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
9556
+ <xsl:when test="not(starts-with(@src, 'data:'))">
9557
+ <xsl:choose>
9558
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9559
+ <xsl:value-of select="@src"/>
9560
+ </xsl:when>
9561
+ <xsl:otherwise>
9562
+ <xsl:value-of select="concat($basepath, @src)"/>
9563
+ </xsl:otherwise>
9564
+ </xsl:choose>
9565
+ </xsl:when>
9551
9566
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
9552
9567
  </xsl:choose>
9553
9568
  </xsl:variable>
@@ -9560,7 +9575,7 @@
9560
9575
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
9561
9576
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
9562
9577
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
9563
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9578
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9564
9579
  <xsl:value-of select="$scale"/>
9565
9580
  </xsl:template>
9566
9581
 
@@ -9579,7 +9594,14 @@
9579
9594
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
9580
9595
  </xsl:when>
9581
9596
  <xsl:when test="not(starts-with(@src, 'data:'))">
9582
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9597
+ <xsl:choose>
9598
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9599
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9600
+ </xsl:when>
9601
+ <xsl:otherwise>
9602
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9603
+ </xsl:otherwise>
9604
+ </xsl:choose>
9583
9605
  </xsl:when>
9584
9606
  <xsl:otherwise>
9585
9607
  <xsl:value-of select="@src"/>
@@ -9601,7 +9623,14 @@
9601
9623
  </xsl:when>
9602
9624
  <xsl:when test="not(starts-with(@src, 'data:'))">
9603
9625
  <xsl:variable name="src">
9604
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9626
+ <xsl:choose>
9627
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9628
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9629
+ </xsl:when>
9630
+ <xsl:otherwise>
9631
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9632
+ </xsl:otherwise>
9633
+ </xsl:choose>
9605
9634
  </xsl:variable>
9606
9635
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9607
9636
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14417,26 +14446,37 @@
14417
14446
  </x:xmpmeta>
14418
14447
  <!-- add attachments -->
14419
14448
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
14420
- <xsl:choose>
14421
- <xsl:when test="normalize-space() != ''">
14422
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14423
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
14424
- </xsl:when>
14425
- <xsl:otherwise>
14426
- <!-- _{filename}_attachments -->
14427
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
14428
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14429
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
14430
- </xsl:otherwise>
14431
- </xsl:choose>
14449
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
14450
+
14451
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
14452
+ <xsl:attribute name="src">
14453
+ <xsl:choose>
14454
+ <xsl:when test="normalize-space() != ''">
14455
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14456
+ <xsl:value-of select="$src_attachment"/>
14457
+ </xsl:when>
14458
+ <xsl:otherwise>
14459
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14460
+ <xsl:value-of select="$url"/>
14461
+ </xsl:otherwise>
14462
+ </xsl:choose>
14463
+ </xsl:attribute>
14464
+ <xsl:if test="$description != ''">
14465
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14466
+ </xsl:if>
14467
+ </pdf:embedded-file>
14432
14468
  </xsl:for-each>
14433
14469
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
14434
14470
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
14435
14471
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
14436
14472
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
14437
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
14438
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
14439
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
14473
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
14474
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
14475
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
14476
+ <xsl:if test="$description != ''">
14477
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14478
+ </xsl:if>
14479
+ </pdf:embedded-file>
14440
14480
  </xsl:for-each>
14441
14481
  </xsl:if>
14442
14482
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14814,7 +14854,14 @@
14814
14854
  <xsl:value-of select="$src"/>
14815
14855
  </xsl:when>
14816
14856
  <xsl:otherwise>
14817
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14857
+ <xsl:choose>
14858
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14859
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14860
+ </xsl:when>
14861
+ <xsl:otherwise>
14862
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14863
+ </xsl:otherwise>
14864
+ </xsl:choose>
14818
14865
  </xsl:otherwise>
14819
14866
  </xsl:choose>
14820
14867
  </xsl:template>
@@ -8880,6 +8880,12 @@
8880
8880
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8881
8881
  <attachment filename="{@name}"/>
8882
8882
  </xsl:for-each>
8883
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8884
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8885
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8886
+ <attachment filename="{$attachment_path}"/>
8887
+ </xsl:for-each>
8888
+ </xsl:if>
8883
8889
  </xsl:variable>
8884
8890
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8885
8891
 
@@ -8892,7 +8898,7 @@
8892
8898
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8893
8899
  </xsl:when>
8894
8900
  <!-- link to the PDF attachment -->
8895
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8901
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8896
8902
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8897
8903
  </xsl:when>
8898
8904
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -9547,7 +9553,16 @@
9547
9553
  </xsl:variable>
9548
9554
  <xsl:variable name="img_src">
9549
9555
  <xsl:choose>
9550
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
9556
+ <xsl:when test="not(starts-with(@src, 'data:'))">
9557
+ <xsl:choose>
9558
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9559
+ <xsl:value-of select="@src"/>
9560
+ </xsl:when>
9561
+ <xsl:otherwise>
9562
+ <xsl:value-of select="concat($basepath, @src)"/>
9563
+ </xsl:otherwise>
9564
+ </xsl:choose>
9565
+ </xsl:when>
9551
9566
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
9552
9567
  </xsl:choose>
9553
9568
  </xsl:variable>
@@ -9560,7 +9575,7 @@
9560
9575
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
9561
9576
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
9562
9577
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
9563
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9578
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9564
9579
  <xsl:value-of select="$scale"/>
9565
9580
  </xsl:template>
9566
9581
 
@@ -9579,7 +9594,14 @@
9579
9594
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
9580
9595
  </xsl:when>
9581
9596
  <xsl:when test="not(starts-with(@src, 'data:'))">
9582
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9597
+ <xsl:choose>
9598
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9599
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9600
+ </xsl:when>
9601
+ <xsl:otherwise>
9602
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9603
+ </xsl:otherwise>
9604
+ </xsl:choose>
9583
9605
  </xsl:when>
9584
9606
  <xsl:otherwise>
9585
9607
  <xsl:value-of select="@src"/>
@@ -9601,7 +9623,14 @@
9601
9623
  </xsl:when>
9602
9624
  <xsl:when test="not(starts-with(@src, 'data:'))">
9603
9625
  <xsl:variable name="src">
9604
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9626
+ <xsl:choose>
9627
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9628
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9629
+ </xsl:when>
9630
+ <xsl:otherwise>
9631
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9632
+ </xsl:otherwise>
9633
+ </xsl:choose>
9605
9634
  </xsl:variable>
9606
9635
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9607
9636
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14417,26 +14446,37 @@
14417
14446
  </x:xmpmeta>
14418
14447
  <!-- add attachments -->
14419
14448
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
14420
- <xsl:choose>
14421
- <xsl:when test="normalize-space() != ''">
14422
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14423
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
14424
- </xsl:when>
14425
- <xsl:otherwise>
14426
- <!-- _{filename}_attachments -->
14427
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
14428
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14429
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
14430
- </xsl:otherwise>
14431
- </xsl:choose>
14449
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
14450
+
14451
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
14452
+ <xsl:attribute name="src">
14453
+ <xsl:choose>
14454
+ <xsl:when test="normalize-space() != ''">
14455
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14456
+ <xsl:value-of select="$src_attachment"/>
14457
+ </xsl:when>
14458
+ <xsl:otherwise>
14459
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14460
+ <xsl:value-of select="$url"/>
14461
+ </xsl:otherwise>
14462
+ </xsl:choose>
14463
+ </xsl:attribute>
14464
+ <xsl:if test="$description != ''">
14465
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14466
+ </xsl:if>
14467
+ </pdf:embedded-file>
14432
14468
  </xsl:for-each>
14433
14469
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
14434
14470
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
14435
14471
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
14436
14472
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
14437
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
14438
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
14439
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
14473
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
14474
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
14475
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
14476
+ <xsl:if test="$description != ''">
14477
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14478
+ </xsl:if>
14479
+ </pdf:embedded-file>
14440
14480
  </xsl:for-each>
14441
14481
  </xsl:if>
14442
14482
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14814,7 +14854,14 @@
14814
14854
  <xsl:value-of select="$src"/>
14815
14855
  </xsl:when>
14816
14856
  <xsl:otherwise>
14817
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14857
+ <xsl:choose>
14858
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14859
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14860
+ </xsl:when>
14861
+ <xsl:otherwise>
14862
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14863
+ </xsl:otherwise>
14864
+ </xsl:choose>
14818
14865
  </xsl:otherwise>
14819
14866
  </xsl:choose>
14820
14867
  </xsl:template>
@@ -8880,6 +8880,12 @@
8880
8880
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8881
8881
  <attachment filename="{@name}"/>
8882
8882
  </xsl:for-each>
8883
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8884
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8885
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8886
+ <attachment filename="{$attachment_path}"/>
8887
+ </xsl:for-each>
8888
+ </xsl:if>
8883
8889
  </xsl:variable>
8884
8890
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8885
8891
 
@@ -8892,7 +8898,7 @@
8892
8898
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8893
8899
  </xsl:when>
8894
8900
  <!-- link to the PDF attachment -->
8895
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8901
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8896
8902
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8897
8903
  </xsl:when>
8898
8904
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -9547,7 +9553,16 @@
9547
9553
  </xsl:variable>
9548
9554
  <xsl:variable name="img_src">
9549
9555
  <xsl:choose>
9550
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
9556
+ <xsl:when test="not(starts-with(@src, 'data:'))">
9557
+ <xsl:choose>
9558
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9559
+ <xsl:value-of select="@src"/>
9560
+ </xsl:when>
9561
+ <xsl:otherwise>
9562
+ <xsl:value-of select="concat($basepath, @src)"/>
9563
+ </xsl:otherwise>
9564
+ </xsl:choose>
9565
+ </xsl:when>
9551
9566
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
9552
9567
  </xsl:choose>
9553
9568
  </xsl:variable>
@@ -9560,7 +9575,7 @@
9560
9575
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
9561
9576
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
9562
9577
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
9563
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9578
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9564
9579
  <xsl:value-of select="$scale"/>
9565
9580
  </xsl:template>
9566
9581
 
@@ -9579,7 +9594,14 @@
9579
9594
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
9580
9595
  </xsl:when>
9581
9596
  <xsl:when test="not(starts-with(@src, 'data:'))">
9582
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9597
+ <xsl:choose>
9598
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9599
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9600
+ </xsl:when>
9601
+ <xsl:otherwise>
9602
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9603
+ </xsl:otherwise>
9604
+ </xsl:choose>
9583
9605
  </xsl:when>
9584
9606
  <xsl:otherwise>
9585
9607
  <xsl:value-of select="@src"/>
@@ -9601,7 +9623,14 @@
9601
9623
  </xsl:when>
9602
9624
  <xsl:when test="not(starts-with(@src, 'data:'))">
9603
9625
  <xsl:variable name="src">
9604
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9626
+ <xsl:choose>
9627
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9628
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9629
+ </xsl:when>
9630
+ <xsl:otherwise>
9631
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9632
+ </xsl:otherwise>
9633
+ </xsl:choose>
9605
9634
  </xsl:variable>
9606
9635
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9607
9636
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14417,26 +14446,37 @@
14417
14446
  </x:xmpmeta>
14418
14447
  <!-- add attachments -->
14419
14448
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
14420
- <xsl:choose>
14421
- <xsl:when test="normalize-space() != ''">
14422
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14423
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
14424
- </xsl:when>
14425
- <xsl:otherwise>
14426
- <!-- _{filename}_attachments -->
14427
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
14428
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14429
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
14430
- </xsl:otherwise>
14431
- </xsl:choose>
14449
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
14450
+
14451
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
14452
+ <xsl:attribute name="src">
14453
+ <xsl:choose>
14454
+ <xsl:when test="normalize-space() != ''">
14455
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14456
+ <xsl:value-of select="$src_attachment"/>
14457
+ </xsl:when>
14458
+ <xsl:otherwise>
14459
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14460
+ <xsl:value-of select="$url"/>
14461
+ </xsl:otherwise>
14462
+ </xsl:choose>
14463
+ </xsl:attribute>
14464
+ <xsl:if test="$description != ''">
14465
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14466
+ </xsl:if>
14467
+ </pdf:embedded-file>
14432
14468
  </xsl:for-each>
14433
14469
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
14434
14470
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
14435
14471
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
14436
14472
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
14437
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
14438
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
14439
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
14473
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
14474
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
14475
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
14476
+ <xsl:if test="$description != ''">
14477
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14478
+ </xsl:if>
14479
+ </pdf:embedded-file>
14440
14480
  </xsl:for-each>
14441
14481
  </xsl:if>
14442
14482
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14814,7 +14854,14 @@
14814
14854
  <xsl:value-of select="$src"/>
14815
14855
  </xsl:when>
14816
14856
  <xsl:otherwise>
14817
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14857
+ <xsl:choose>
14858
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14859
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14860
+ </xsl:when>
14861
+ <xsl:otherwise>
14862
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14863
+ </xsl:otherwise>
14864
+ </xsl:choose>
14818
14865
  </xsl:otherwise>
14819
14866
  </xsl:choose>
14820
14867
  </xsl:template>
@@ -8880,6 +8880,12 @@
8880
8880
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8881
8881
  <attachment filename="{@name}"/>
8882
8882
  </xsl:for-each>
8883
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
8884
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
8885
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
8886
+ <attachment filename="{$attachment_path}"/>
8887
+ </xsl:for-each>
8888
+ </xsl:if>
8883
8889
  </xsl:variable>
8884
8890
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8885
8891
 
@@ -8892,7 +8898,7 @@
8892
8898
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8893
8899
  </xsl:when>
8894
8900
  <!-- link to the PDF attachment -->
8895
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8901
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8896
8902
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8897
8903
  </xsl:when>
8898
8904
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -9547,7 +9553,16 @@
9547
9553
  </xsl:variable>
9548
9554
  <xsl:variable name="img_src">
9549
9555
  <xsl:choose>
9550
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
9556
+ <xsl:when test="not(starts-with(@src, 'data:'))">
9557
+ <xsl:choose>
9558
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9559
+ <xsl:value-of select="@src"/>
9560
+ </xsl:when>
9561
+ <xsl:otherwise>
9562
+ <xsl:value-of select="concat($basepath, @src)"/>
9563
+ </xsl:otherwise>
9564
+ </xsl:choose>
9565
+ </xsl:when>
9551
9566
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
9552
9567
  </xsl:choose>
9553
9568
  </xsl:variable>
@@ -9560,7 +9575,7 @@
9560
9575
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
9561
9576
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
9562
9577
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
9563
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9578
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
9564
9579
  <xsl:value-of select="$scale"/>
9565
9580
  </xsl:template>
9566
9581
 
@@ -9579,7 +9594,14 @@
9579
9594
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
9580
9595
  </xsl:when>
9581
9596
  <xsl:when test="not(starts-with(@src, 'data:'))">
9582
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9597
+ <xsl:choose>
9598
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9599
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9600
+ </xsl:when>
9601
+ <xsl:otherwise>
9602
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9603
+ </xsl:otherwise>
9604
+ </xsl:choose>
9583
9605
  </xsl:when>
9584
9606
  <xsl:otherwise>
9585
9607
  <xsl:value-of select="@src"/>
@@ -9601,7 +9623,14 @@
9601
9623
  </xsl:when>
9602
9624
  <xsl:when test="not(starts-with(@src, 'data:'))">
9603
9625
  <xsl:variable name="src">
9604
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9626
+ <xsl:choose>
9627
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
9628
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
9629
+ </xsl:when>
9630
+ <xsl:otherwise>
9631
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9632
+ </xsl:otherwise>
9633
+ </xsl:choose>
9605
9634
  </xsl:variable>
9606
9635
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9607
9636
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14417,26 +14446,37 @@
14417
14446
  </x:xmpmeta>
14418
14447
  <!-- add attachments -->
14419
14448
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
14420
- <xsl:choose>
14421
- <xsl:when test="normalize-space() != ''">
14422
- <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14423
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" filename="{@name}"/>
14424
- </xsl:when>
14425
- <xsl:otherwise>
14426
- <!-- _{filename}_attachments -->
14427
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
14428
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14429
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
14430
- </xsl:otherwise>
14431
- </xsl:choose>
14449
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
14450
+
14451
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}">
14452
+ <xsl:attribute name="src">
14453
+ <xsl:choose>
14454
+ <xsl:when test="normalize-space() != ''">
14455
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
14456
+ <xsl:value-of select="$src_attachment"/>
14457
+ </xsl:when>
14458
+ <xsl:otherwise>
14459
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14460
+ <xsl:value-of select="$url"/>
14461
+ </xsl:otherwise>
14462
+ </xsl:choose>
14463
+ </xsl:attribute>
14464
+ <xsl:if test="$description != ''">
14465
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14466
+ </xsl:if>
14467
+ </pdf:embedded-file>
14432
14468
  </xsl:for-each>
14433
14469
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
14434
14470
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
14435
14471
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
14436
14472
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
14437
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
14438
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
14439
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/>
14473
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
14474
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
14475
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}">
14476
+ <xsl:if test="$description != ''">
14477
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
14478
+ </xsl:if>
14479
+ </pdf:embedded-file>
14440
14480
  </xsl:for-each>
14441
14481
  </xsl:if>
14442
14482
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14814,7 +14854,14 @@
14814
14854
  <xsl:value-of select="$src"/>
14815
14855
  </xsl:when>
14816
14856
  <xsl:otherwise>
14817
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14857
+ <xsl:choose>
14858
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
14859
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
14860
+ </xsl:when>
14861
+ <xsl:otherwise>
14862
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
14863
+ </xsl:otherwise>
14864
+ </xsl:choose>
14818
14865
  </xsl:otherwise>
14819
14866
  </xsl:choose>
14820
14867
  </xsl:template>