metanorma-itu 2.5.0 → 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: 6118028edabf79b61becf238e0517a8d47887600c3edc771b27150e59def1971
4
- data.tar.gz: 1dbcdcb12bb1a85026667dbd0fa85fa7beb218165ac2b9b5123db9fa0d62db08
3
+ metadata.gz: d3ecfeb1942e091d6ad7b5a7b6fdb9ebef13765a24acbd69a0149b111e8ece83
4
+ data.tar.gz: c556b6e505eb79a3b48dad7a04eb79111d8b5edc4b90fa2ee895dccb28848f9c
5
5
  SHA512:
6
- metadata.gz: 0ef409f6253fe230b38b6913edd3e1b2dc5010cfd775782774af835e742340510da782fa9ba57b38149e433705a3662d7ed62334fdff9d722a43864be8a58328
7
- data.tar.gz: fdfe298cb20e6a4d8f8d7cd92baa4499481e7fe8eb02700a4f8da17ce37650f1089104daf95ad4b5c9b55e8190e1c72f167780477b3c95a1814bec5233e6ab14
6
+ metadata.gz: d4fc80315dbf1ee88c006dccdb75c2887315a61fdb9f6b4029bf72cd06b9033c0b697aa5720ea74371afa931369524011e82d1983ae2d1b6f0dcffc1e78c64d1
7
+ data.tar.gz: 134cf827b3c284e834f299786e4ef8b23235bcfd5b6d9e5495e2dab693e762bfff7631d9029991f4854470961bd82fd158e5bf020de5d736a3048b6111e4ae7d
@@ -222,6 +222,46 @@ h6:hover > a.anchor,
222
222
  .inline-header:hover > a.anchor {
223
223
  visibility: visible; }
224
224
 
225
+ /* collapsible snippets: collapsible before hidable */
226
+ .hidable {
227
+ max-height: 0;
228
+ overflow: hidden;
229
+ transition: max-height 0.2s ease-out; }
230
+
231
+ .collapsible {
232
+ background-color: #777;
233
+ color: white;
234
+ cursor: pointer;
235
+ padding: 12px 0;
236
+ margin: 0;
237
+ width: 100%;
238
+ border: none;
239
+ text-align: left;
240
+ outline: none;
241
+ font-size: 15px; }
242
+
243
+ .active, .collapsible:hover {
244
+ background-color: #555; }
245
+
246
+ .collapsible:after {
247
+ content: '\25bc';
248
+ color: white;
249
+ font-weight: bold;
250
+ float: right;
251
+ margin-left: 12px;
252
+ margin-right: 12px; }
253
+
254
+ .active:after {
255
+ content: "\25b2"; }
256
+
257
+ /* collapsible: */
258
+ .collapsible + .hidable {
259
+ margin-top: 0; }
260
+
261
+ .collapsible:not(.active) + .hidable {
262
+ overflow: hidden;
263
+ padding: 0; }
264
+
225
265
  #standard-band {
226
266
  background-color: #0AC442; }
227
267
 
@@ -222,6 +222,46 @@ h6:hover > a.anchor,
222
222
  .inline-header:hover > a.anchor {
223
223
  visibility: visible; }
224
224
 
225
+ /* collapsible snippets: collapsible before hidable */
226
+ .hidable {
227
+ max-height: 0;
228
+ overflow: hidden;
229
+ transition: max-height 0.2s ease-out; }
230
+
231
+ .collapsible {
232
+ background-color: #777;
233
+ color: white;
234
+ cursor: pointer;
235
+ padding: 12px 0;
236
+ margin: 0;
237
+ width: 100%;
238
+ border: none;
239
+ text-align: left;
240
+ outline: none;
241
+ font-size: 15px; }
242
+
243
+ .active, .collapsible:hover {
244
+ background-color: #555; }
245
+
246
+ .collapsible:after {
247
+ content: '\25bc';
248
+ color: white;
249
+ font-weight: bold;
250
+ float: right;
251
+ margin-left: 12px;
252
+ margin-right: 12px; }
253
+
254
+ .active:after {
255
+ content: "\25b2"; }
256
+
257
+ /* collapsible: */
258
+ .collapsible + .hidable {
259
+ margin-top: 0; }
260
+
261
+ .collapsible:not(.active) + .hidable {
262
+ overflow: hidden;
263
+ padding: 0; }
264
+
225
265
  #recommendation-band {
226
266
  background-color: #a3d88f; }
227
267
 
@@ -565,6 +605,46 @@ h6:hover > a.anchor,
565
605
  .inline-header:hover > a.anchor {
566
606
  visibility: visible; }
567
607
 
608
+ /* collapsible snippets: collapsible before hidable */
609
+ .hidable {
610
+ max-height: 0;
611
+ overflow: hidden;
612
+ transition: max-height 0.2s ease-out; }
613
+
614
+ .collapsible {
615
+ background-color: #777;
616
+ color: white;
617
+ cursor: pointer;
618
+ padding: 12px 0;
619
+ margin: 0;
620
+ width: 100%;
621
+ border: none;
622
+ text-align: left;
623
+ outline: none;
624
+ font-size: 15px; }
625
+
626
+ .active, .collapsible:hover {
627
+ background-color: #555; }
628
+
629
+ .collapsible:after {
630
+ content: '\25bc';
631
+ color: white;
632
+ font-weight: bold;
633
+ float: right;
634
+ margin-left: 12px;
635
+ margin-right: 12px; }
636
+
637
+ .active:after {
638
+ content: "\25b2"; }
639
+
640
+ /* collapsible: */
641
+ .collapsible + .hidable {
642
+ margin-top: 0; }
643
+
644
+ .collapsible:not(.active) + .hidable {
645
+ overflow: hidden;
646
+ padding: 0; }
647
+
568
648
  #recommendation-band {
569
649
  background-color: #a3d88f; }
570
650
 
@@ -4588,13 +4588,35 @@
4588
4588
  </xsl:for-each>
4589
4589
  </xsl:element>
4590
4590
 
4591
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
4591
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
4592
4592
 
4593
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
4593
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
4594
4594
 
4595
4595
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
4596
4596
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
4597
4597
 
4598
+ <xsl:template name="insertAnnexAndBibliographyInSeparatePageSequences">
4599
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
4600
+ <xsl:sort select="@displayorder" data-type="number"/>
4601
+ <xsl:choose>
4602
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
4603
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
4604
+ <xsl:attribute name="main_page_sequence"/>
4605
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
4606
+ </xsl:element>
4607
+ </xsl:when>
4608
+ <xsl:otherwise> <!-- bibliography -->
4609
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
4610
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
4611
+ <xsl:attribute name="main_page_sequence"/>
4612
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
4613
+ </xsl:element>
4614
+ </xsl:element>
4615
+ </xsl:otherwise>
4616
+ </xsl:choose>
4617
+ </xsl:for-each>
4618
+ </xsl:template>
4619
+
4598
4620
  <xsl:template name="insertAnnexInSeparatePageSequences">
4599
4621
  <xsl:for-each select="/*/*[local-name()='annex']">
4600
4622
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -8858,6 +8880,12 @@
8858
8880
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8859
8881
  <attachment filename="{@name}"/>
8860
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>
8861
8889
  </xsl:variable>
8862
8890
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8863
8891
 
@@ -8870,7 +8898,7 @@
8870
8898
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8871
8899
  </xsl:when>
8872
8900
  <!-- link to the PDF attachment -->
8873
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8901
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8874
8902
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8875
8903
  </xsl:when>
8876
8904
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -9525,7 +9553,16 @@
9525
9553
  </xsl:variable>
9526
9554
  <xsl:variable name="img_src">
9527
9555
  <xsl:choose>
9528
- <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>
9529
9566
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
9530
9567
  </xsl:choose>
9531
9568
  </xsl:variable>
@@ -9538,7 +9575,7 @@
9538
9575
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
9539
9576
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
9540
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> -->
9541
- <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)"/>
9542
9579
  <xsl:value-of select="$scale"/>
9543
9580
  </xsl:template>
9544
9581
 
@@ -9557,7 +9594,14 @@
9557
9594
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
9558
9595
  </xsl:when>
9559
9596
  <xsl:when test="not(starts-with(@src, 'data:'))">
9560
- <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>
9561
9605
  </xsl:when>
9562
9606
  <xsl:otherwise>
9563
9607
  <xsl:value-of select="@src"/>
@@ -9579,7 +9623,14 @@
9579
9623
  </xsl:when>
9580
9624
  <xsl:when test="not(starts-with(@src, 'data:'))">
9581
9625
  <xsl:variable name="src">
9582
- <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>
9583
9634
  </xsl:variable>
9584
9635
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9585
9636
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13517,10 +13568,12 @@
13517
13568
  <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
13518
13569
  <xsl:copy>
13519
13570
  <xsl:copy-of select="@*"/>
13520
- <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
13521
- <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
13522
- <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
13523
- <xsl:value-of select="."/>
13571
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
13572
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
13573
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
13574
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
13575
+ <xsl:value-of select="normalize-space(.)"/>
13576
+ </xsl:if>
13524
13577
  </xsl:if>
13525
13578
  </xsl:copy>
13526
13579
  </xsl:template>
@@ -14393,25 +14446,37 @@
14393
14446
  </x:xmpmeta>
14394
14447
  <!-- add attachments -->
14395
14448
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
14396
- <xsl:choose>
14397
- <xsl:when test="normalize-space() != ''">
14398
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
14399
- </xsl:when>
14400
- <xsl:otherwise>
14401
- <!-- _{filename}_attachments -->
14402
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
14403
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14404
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
14405
- </xsl:otherwise>
14406
- </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>
14407
14468
  </xsl:for-each>
14408
14469
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
14409
14470
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
14410
14471
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
14411
14472
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
14412
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
14413
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
14414
- <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>
14415
14480
  </xsl:for-each>
14416
14481
  </xsl:if>
14417
14482
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14789,7 +14854,14 @@
14789
14854
  <xsl:value-of select="$src"/>
14790
14855
  </xsl:when>
14791
14856
  <xsl:otherwise>
14792
- <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>
14793
14865
  </xsl:otherwise>
14794
14866
  </xsl:choose>
14795
14867
  </xsl:template>
@@ -4588,13 +4588,35 @@
4588
4588
  </xsl:for-each>
4589
4589
  </xsl:element>
4590
4590
 
4591
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
4591
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
4592
4592
 
4593
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
4593
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
4594
4594
 
4595
4595
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
4596
4596
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
4597
4597
 
4598
+ <xsl:template name="insertAnnexAndBibliographyInSeparatePageSequences">
4599
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
4600
+ <xsl:sort select="@displayorder" data-type="number"/>
4601
+ <xsl:choose>
4602
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
4603
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
4604
+ <xsl:attribute name="main_page_sequence"/>
4605
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
4606
+ </xsl:element>
4607
+ </xsl:when>
4608
+ <xsl:otherwise> <!-- bibliography -->
4609
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
4610
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
4611
+ <xsl:attribute name="main_page_sequence"/>
4612
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
4613
+ </xsl:element>
4614
+ </xsl:element>
4615
+ </xsl:otherwise>
4616
+ </xsl:choose>
4617
+ </xsl:for-each>
4618
+ </xsl:template>
4619
+
4598
4620
  <xsl:template name="insertAnnexInSeparatePageSequences">
4599
4621
  <xsl:for-each select="/*/*[local-name()='annex']">
4600
4622
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -8858,6 +8880,12 @@
8858
8880
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
8859
8881
  <attachment filename="{@name}"/>
8860
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>
8861
8889
  </xsl:variable>
8862
8890
  <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
8863
8891
 
@@ -8870,7 +8898,7 @@
8870
8898
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8871
8899
  </xsl:when>
8872
8900
  <!-- link to the PDF attachment -->
8873
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
8901
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8874
8902
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8875
8903
  </xsl:when>
8876
8904
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -9525,7 +9553,16 @@
9525
9553
  </xsl:variable>
9526
9554
  <xsl:variable name="img_src">
9527
9555
  <xsl:choose>
9528
- <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>
9529
9566
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
9530
9567
  </xsl:choose>
9531
9568
  </xsl:variable>
@@ -9538,7 +9575,7 @@
9538
9575
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
9539
9576
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
9540
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> -->
9541
- <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)"/>
9542
9579
  <xsl:value-of select="$scale"/>
9543
9580
  </xsl:template>
9544
9581
 
@@ -9557,7 +9594,14 @@
9557
9594
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
9558
9595
  </xsl:when>
9559
9596
  <xsl:when test="not(starts-with(@src, 'data:'))">
9560
- <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>
9561
9605
  </xsl:when>
9562
9606
  <xsl:otherwise>
9563
9607
  <xsl:value-of select="@src"/>
@@ -9579,7 +9623,14 @@
9579
9623
  </xsl:when>
9580
9624
  <xsl:when test="not(starts-with(@src, 'data:'))">
9581
9625
  <xsl:variable name="src">
9582
- <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>
9583
9634
  </xsl:variable>
9584
9635
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9585
9636
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -13517,10 +13568,12 @@
13517
13568
  <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
13518
13569
  <xsl:copy>
13519
13570
  <xsl:copy-of select="@*"/>
13520
- <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
13521
- <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
13522
- <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
13523
- <xsl:value-of select="."/>
13571
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
13572
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
13573
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
13574
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
13575
+ <xsl:value-of select="normalize-space(.)"/>
13576
+ </xsl:if>
13524
13577
  </xsl:if>
13525
13578
  </xsl:copy>
13526
13579
  </xsl:template>
@@ -14393,25 +14446,37 @@
14393
14446
  </x:xmpmeta>
14394
14447
  <!-- add attachments -->
14395
14448
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
14396
- <xsl:choose>
14397
- <xsl:when test="normalize-space() != ''">
14398
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
14399
- </xsl:when>
14400
- <xsl:otherwise>
14401
- <!-- _{filename}_attachments -->
14402
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
14403
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
14404
- <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
14405
- </xsl:otherwise>
14406
- </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>
14407
14468
  </xsl:for-each>
14408
14469
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
14409
14470
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
14410
14471
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
14411
14472
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
14412
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
14413
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
14414
- <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>
14415
14480
  </xsl:for-each>
14416
14481
  </xsl:if>
14417
14482
  </xsl:template> <!-- addPDFUAmeta -->
@@ -14789,7 +14854,14 @@
14789
14854
  <xsl:value-of select="$src"/>
14790
14855
  </xsl:when>
14791
14856
  <xsl:otherwise>
14792
- <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>
14793
14865
  </xsl:otherwise>
14794
14866
  </xsl:choose>
14795
14867
  </xsl:template>