metanorma-bipm 2.4.12 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5725,13 +5725,35 @@
5725
5725
  </xsl:for-each>
5726
5726
  </xsl:element>
5727
5727
 
5728
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5728
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
5729
5729
 
5730
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5730
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
5731
5731
 
5732
5732
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5733
5733
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
5734
5734
 
5735
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexAndBibliographyInSeparatePageSequences">
5736
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
5737
+ <xsl:sort select="@displayorder" data-type="number"/>
5738
+ <xsl:choose>
5739
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
5740
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5741
+ <xsl:attribute name="main_page_sequence"/>
5742
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5743
+ </xsl:element>
5744
+ </xsl:when>
5745
+ <xsl:otherwise> <!-- bibliography -->
5746
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5747
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5748
+ <xsl:attribute name="main_page_sequence"/>
5749
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5750
+ </xsl:element>
5751
+ </xsl:element>
5752
+ </xsl:otherwise>
5753
+ </xsl:choose>
5754
+ </xsl:for-each>
5755
+ </xsl:template>
5756
+
5735
5757
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
5736
5758
  <xsl:for-each select="/*/*[local-name()='annex']">
5737
5759
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -10003,6 +10025,12 @@
10003
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10004
10026
  <attachment filename="{@name}"/>
10005
10027
  </xsl:for-each>
10028
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
10029
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
10030
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
10031
+ <attachment filename="{$attachment_path}"/>
10032
+ </xsl:for-each>
10033
+ </xsl:if>
10006
10034
  </xsl:variable>
10007
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10008
10036
 
@@ -10015,7 +10043,7 @@
10015
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10016
10044
  </xsl:when>
10017
10045
  <!-- link to the PDF attachment -->
10018
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10019
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10020
10048
  </xsl:when>
10021
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10683,7 +10711,16 @@
10683
10711
  </xsl:variable>
10684
10712
  <xsl:variable name="img_src">
10685
10713
  <xsl:choose>
10686
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
10714
+ <xsl:when test="not(starts-with(@src, 'data:'))">
10715
+ <xsl:choose>
10716
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10717
+ <xsl:value-of select="@src"/>
10718
+ </xsl:when>
10719
+ <xsl:otherwise>
10720
+ <xsl:value-of select="concat($basepath, @src)"/>
10721
+ </xsl:otherwise>
10722
+ </xsl:choose>
10723
+ </xsl:when>
10687
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10688
10725
  </xsl:choose>
10689
10726
  </xsl:variable>
@@ -10696,7 +10733,7 @@
10696
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10697
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10698
10735
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
10699
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10736
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10700
10737
  <xsl:value-of select="$scale"/>
10701
10738
  </xsl:template>
10702
10739
 
@@ -10715,7 +10752,14 @@
10715
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10716
10753
  </xsl:when>
10717
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10718
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10755
+ <xsl:choose>
10756
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10757
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10758
+ </xsl:when>
10759
+ <xsl:otherwise>
10760
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10761
+ </xsl:otherwise>
10762
+ </xsl:choose>
10719
10763
  </xsl:when>
10720
10764
  <xsl:otherwise>
10721
10765
  <xsl:value-of select="@src"/>
@@ -10737,7 +10781,14 @@
10737
10781
  </xsl:when>
10738
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10739
10783
  <xsl:variable name="src">
10740
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10784
+ <xsl:choose>
10785
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10786
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10787
+ </xsl:when>
10788
+ <xsl:otherwise>
10789
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10790
+ </xsl:otherwise>
10791
+ </xsl:choose>
10741
10792
  </xsl:variable>
10742
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10743
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14656,10 +14707,12 @@
14656
14707
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
14657
14708
  <xsl:copy>
14658
14709
  <xsl:copy-of select="@*"/>
14659
- <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14660
- <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14661
- <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14662
- <xsl:value-of select="."/>
14710
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
14711
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14712
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14713
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14714
+ <xsl:value-of select="normalize-space(.)"/>
14715
+ </xsl:if>
14663
14716
  </xsl:if>
14664
14717
  </xsl:copy>
14665
14718
  </xsl:template>
@@ -15532,25 +15585,37 @@
15532
15585
  </x:xmpmeta>
15533
15586
  <!-- add attachments -->
15534
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15535
- <xsl:choose>
15536
- <xsl:when test="normalize-space() != ''">
15537
- <pdf:embedded-file src="{.}" filename="{@name}"/>
15538
- </xsl:when>
15539
- <xsl:otherwise>
15540
- <!-- _{filename}_attachments -->
15541
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15542
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15543
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15544
- </xsl:otherwise>
15545
- </xsl:choose>
15588
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
15589
+
15590
+ <pdf:embedded-file filename="{@name}">
15591
+ <xsl:attribute name="src">
15592
+ <xsl:choose>
15593
+ <xsl:when test="normalize-space() != ''">
15594
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15595
+ <xsl:value-of select="$src_attachment"/>
15596
+ </xsl:when>
15597
+ <xsl:otherwise>
15598
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15599
+ <xsl:value-of select="$url"/>
15600
+ </xsl:otherwise>
15601
+ </xsl:choose>
15602
+ </xsl:attribute>
15603
+ <xsl:if test="$description != ''">
15604
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15605
+ </xsl:if>
15606
+ </pdf:embedded-file>
15546
15607
  </xsl:for-each>
15547
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15548
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15549
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15550
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15551
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15552
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15553
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15612
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
15613
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
15614
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
15615
+ <xsl:if test="$description != ''">
15616
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15617
+ </xsl:if>
15618
+ </pdf:embedded-file>
15554
15619
  </xsl:for-each>
15555
15620
  </xsl:if>
15556
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15928,7 +15993,14 @@
15928
15993
  <xsl:value-of select="$src"/>
15929
15994
  </xsl:when>
15930
15995
  <xsl:otherwise>
15931
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
15996
+ <xsl:choose>
15997
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
15998
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
15999
+ </xsl:when>
16000
+ <xsl:otherwise>
16001
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
16002
+ </xsl:otherwise>
16003
+ </xsl:choose>
15932
16004
  </xsl:otherwise>
15933
16005
  </xsl:choose>
15934
16006
  </xsl:template>
@@ -5725,13 +5725,35 @@
5725
5725
  </xsl:for-each>
5726
5726
  </xsl:element>
5727
5727
 
5728
- <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5728
+ <xsl:call-template name="insertAnnexAndBibliographyInSeparatePageSequences"/>
5729
5729
 
5730
- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5730
+ <!-- <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> -->
5731
5731
 
5732
5732
  <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5733
5733
  </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
5734
5734
 
5735
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexAndBibliographyInSeparatePageSequences">
5736
+ <xsl:for-each select="/*/*[local-name()='annex'] | /*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]] | /*/*[local-name()='indexsect']">
5737
+ <xsl:sort select="@displayorder" data-type="number"/>
5738
+ <xsl:choose>
5739
+ <xsl:when test="local-name() = 'annex' or local-name() = 'indexsect'">
5740
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5741
+ <xsl:attribute name="main_page_sequence"/>
5742
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5743
+ </xsl:element>
5744
+ </xsl:when>
5745
+ <xsl:otherwise> <!-- bibliography -->
5746
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5747
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5748
+ <xsl:attribute name="main_page_sequence"/>
5749
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5750
+ </xsl:element>
5751
+ </xsl:element>
5752
+ </xsl:otherwise>
5753
+ </xsl:choose>
5754
+ </xsl:for-each>
5755
+ </xsl:template>
5756
+
5735
5757
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
5736
5758
  <xsl:for-each select="/*/*[local-name()='annex']">
5737
5759
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -10003,6 +10025,12 @@
10003
10025
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
10004
10026
  <attachment filename="{@name}"/>
10005
10027
  </xsl:for-each>
10028
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
10029
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
10030
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
10031
+ <attachment filename="{$attachment_path}"/>
10032
+ </xsl:for-each>
10033
+ </xsl:if>
10006
10034
  </xsl:variable>
10007
10035
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
10008
10036
 
@@ -10015,7 +10043,7 @@
10015
10043
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
10016
10044
  </xsl:when>
10017
10045
  <!-- link to the PDF attachment -->
10018
- <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
10046
+ <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
10019
10047
  <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
10020
10048
  </xsl:when>
10021
10049
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
@@ -10683,7 +10711,16 @@
10683
10711
  </xsl:variable>
10684
10712
  <xsl:variable name="img_src">
10685
10713
  <xsl:choose>
10686
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
10714
+ <xsl:when test="not(starts-with(@src, 'data:'))">
10715
+ <xsl:choose>
10716
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10717
+ <xsl:value-of select="@src"/>
10718
+ </xsl:when>
10719
+ <xsl:otherwise>
10720
+ <xsl:value-of select="concat($basepath, @src)"/>
10721
+ </xsl:otherwise>
10722
+ </xsl:choose>
10723
+ </xsl:when>
10687
10724
  <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
10688
10725
  </xsl:choose>
10689
10726
  </xsl:variable>
@@ -10696,7 +10733,7 @@
10696
10733
  <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
10697
10734
  <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
10698
10735
  <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
10699
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10736
+ <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/>
10700
10737
  <xsl:value-of select="$scale"/>
10701
10738
  </xsl:template>
10702
10739
 
@@ -10715,7 +10752,14 @@
10715
10752
  <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10716
10753
  </xsl:when>
10717
10754
  <xsl:when test="not(starts-with(@src, 'data:'))">
10718
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10755
+ <xsl:choose>
10756
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10757
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10758
+ </xsl:when>
10759
+ <xsl:otherwise>
10760
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10761
+ </xsl:otherwise>
10762
+ </xsl:choose>
10719
10763
  </xsl:when>
10720
10764
  <xsl:otherwise>
10721
10765
  <xsl:value-of select="@src"/>
@@ -10737,7 +10781,14 @@
10737
10781
  </xsl:when>
10738
10782
  <xsl:when test="not(starts-with(@src, 'data:'))">
10739
10783
  <xsl:variable name="src">
10740
- <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10784
+ <xsl:choose>
10785
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
10786
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
10787
+ </xsl:when>
10788
+ <xsl:otherwise>
10789
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10790
+ </xsl:otherwise>
10791
+ </xsl:choose>
10741
10792
  </xsl:variable>
10742
10793
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
10743
10794
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -14656,10 +14707,12 @@
14656
14707
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
14657
14708
  <xsl:copy>
14658
14709
  <xsl:copy-of select="@*"/>
14659
- <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14660
- <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14661
- <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14662
- <xsl:value-of select="."/>
14710
+ <xsl:if test="1 = 2"> <!-- remove attachment/text(), because attachments added in the template 'addPDFUAmeta' before applying 'update_xml_step1' -->
14711
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
14712
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
14713
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
14714
+ <xsl:value-of select="normalize-space(.)"/>
14715
+ </xsl:if>
14663
14716
  </xsl:if>
14664
14717
  </xsl:copy>
14665
14718
  </xsl:template>
@@ -15532,25 +15585,37 @@
15532
15585
  </x:xmpmeta>
15533
15586
  <!-- add attachments -->
15534
15587
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
15535
- <xsl:choose>
15536
- <xsl:when test="normalize-space() != ''">
15537
- <pdf:embedded-file src="{.}" filename="{@name}"/>
15538
- </xsl:when>
15539
- <xsl:otherwise>
15540
- <!-- _{filename}_attachments -->
15541
- <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
15542
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15543
- <pdf:embedded-file src="{$url}" filename="{@name}"/>
15544
- </xsl:otherwise>
15545
- </xsl:choose>
15588
+ <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
15589
+
15590
+ <pdf:embedded-file filename="{@name}">
15591
+ <xsl:attribute name="src">
15592
+ <xsl:choose>
15593
+ <xsl:when test="normalize-space() != ''">
15594
+ <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks -->
15595
+ <xsl:value-of select="$src_attachment"/>
15596
+ </xsl:when>
15597
+ <xsl:otherwise>
15598
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
15599
+ <xsl:value-of select="$url"/>
15600
+ </xsl:otherwise>
15601
+ </xsl:choose>
15602
+ </xsl:attribute>
15603
+ <xsl:if test="$description != ''">
15604
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15605
+ </xsl:if>
15606
+ </pdf:embedded-file>
15546
15607
  </xsl:for-each>
15547
15608
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15548
15609
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15549
15610
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15550
15611
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15551
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15552
- <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15553
- <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15612
+ <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
15613
+ <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
15614
+ <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
15615
+ <xsl:if test="$description != ''">
15616
+ <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
15617
+ </xsl:if>
15618
+ </pdf:embedded-file>
15554
15619
  </xsl:for-each>
15555
15620
  </xsl:if>
15556
15621
  </xsl:template> <!-- addPDFUAmeta -->
@@ -15928,7 +15993,14 @@
15928
15993
  <xsl:value-of select="$src"/>
15929
15994
  </xsl:when>
15930
15995
  <xsl:otherwise>
15931
- <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
15996
+ <xsl:choose>
15997
+ <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
15998
+ <xsl:value-of select="concat('url(file:///', @src, ')')"/>
15999
+ </xsl:when>
16000
+ <xsl:otherwise>
16001
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
16002
+ </xsl:otherwise>
16003
+ </xsl:choose>
15932
16004
  </xsl:otherwise>
15933
16005
  </xsl:choose>
15934
16006
  </xsl:template>
@@ -229,6 +229,46 @@ h6:hover > a.anchor,
229
229
  .inline-header:hover > a.anchor {
230
230
  visibility: visible; }
231
231
 
232
+ /* collapsible snippets: collapsible before hidable */
233
+ .hidable {
234
+ max-height: 0;
235
+ overflow: hidden;
236
+ transition: max-height 0.2s ease-out; }
237
+
238
+ .collapsible {
239
+ background-color: #777;
240
+ color: white;
241
+ cursor: pointer;
242
+ padding: 12px 0;
243
+ margin: 0;
244
+ width: 100%;
245
+ border: none;
246
+ text-align: left;
247
+ outline: none;
248
+ font-size: 15px; }
249
+
250
+ .active, .collapsible:hover {
251
+ background-color: #555; }
252
+
253
+ .collapsible:after {
254
+ content: '\25bc';
255
+ color: white;
256
+ font-weight: bold;
257
+ float: right;
258
+ margin-left: 12px;
259
+ margin-right: 12px; }
260
+
261
+ .active:after {
262
+ content: "\25b2"; }
263
+
264
+ /* collapsible: */
265
+ .collapsible + .hidable {
266
+ margin-top: 0; }
267
+
268
+ .collapsible:not(.active) + .hidable {
269
+ overflow: hidden;
270
+ padding: 0; }
271
+
232
272
  #brochure-band {
233
273
  background-color: #0AC442; }
234
274