metanorma-ieee 1.2.9 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,9 +7,6 @@
7
7
 
8
8
  <!-- mandatory variable -->
9
9
 
10
- <!-- mandatory variable -->
11
- <xsl:variable name="namespace_full">https://www.metanorma.org/ns/ieee</xsl:variable>
12
-
13
10
  <!-- mandatory variable -->
14
11
  <xsl:variable name="debug">false</xsl:variable>
15
12
 
@@ -2657,9 +2654,10 @@
2657
2654
  </xsl:choose>
2658
2655
  </xsl:variable> -->
2659
2656
  <xsl:element name="{$element-name}">
2660
- <xsl:call-template name="setTextAlignment">
2661
- <xsl:with-param name="default">justify</xsl:with-param>
2657
+ <xsl:call-template name="setBlockAttributes">
2658
+ <xsl:with-param name="text_align_default">justify</xsl:with-param>
2662
2659
  </xsl:call-template>
2660
+
2663
2661
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute><!-- 8pt -->
2664
2662
  <xsl:if test="($current_template = 'whitepaper' or $current_template = 'icap-whitepaper' or $current_template = 'industry-connection-report') and (ancestor::ieee:sections or ancestor::ieee:annex)">
2665
2663
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
@@ -3800,7 +3798,9 @@
3800
3798
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="ieee:xref"/>
3801
3799
 
3802
3800
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
3803
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
3801
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
3802
+
3803
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="document_scheme" select="normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'document-scheme']/*[local-name() = 'value'])"/>
3804
3804
 
3805
3805
  <!-- external parameters -->
3806
3806
 
@@ -5548,41 +5548,9 @@
5548
5548
  </xsl:for-each>
5549
5549
  </xsl:template>
5550
5550
 
5551
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
5552
-
5553
- <xsl:variable name="updated_xml_step_move_pagebreak_">
5554
-
5555
- <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5556
-
5557
- <xsl:call-template name="copyCommonElements"/>
5558
-
5559
- <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5560
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
5561
- <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5562
- <xsl:sort select="@displayorder" data-type="number"/>
5563
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5564
- </xsl:for-each>
5565
- </xsl:element>
5566
- </xsl:element>
5567
- </xsl:element>
5568
- </xsl:variable>
5569
-
5570
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5571
-
5572
- <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5573
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
5574
- </redirect:write>
5575
-
5576
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5577
-
5578
- <xsl:call-template name="deleteFile">
5579
- <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5580
- </xsl:call-template>
5581
- </xsl:template>
5582
-
5583
5551
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
5584
5552
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
5585
- <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography']"/>
5553
+ <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography' and local-name() != 'indexsect']"/>
5586
5554
  </xsl:template>
5587
5555
 
5588
5556
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault">
@@ -5603,38 +5571,16 @@
5603
5571
  </xsl:for-each>
5604
5572
  </xsl:template><!-- END: processMainSectionsDefault -->
5605
5573
 
5606
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
5607
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5608
- <xsl:sort select="@displayorder" data-type="number"/>
5609
- <xsl:variable name="flatxml">
5610
- <xsl:apply-templates select="." mode="flatxml"/>
5611
- </xsl:variable>
5612
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
5613
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
5614
-
5615
- </xsl:for-each>
5616
-
5617
- <xsl:for-each select="/*/*[local-name()='annex']">
5618
- <xsl:sort select="@displayorder" data-type="number"/>
5619
- <xsl:variable name="flatxml">
5620
- <xsl:apply-templates select="." mode="flatxml"/>
5621
- </xsl:variable>
5622
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
5623
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
5624
- </xsl:for-each>
5625
-
5626
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5627
- <xsl:sort select="@displayorder" data-type="number"/>
5628
- <xsl:variable name="flatxml">
5629
- <xsl:apply-templates select="." mode="flatxml"/>
5630
- </xsl:variable>
5631
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
5632
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
5633
- </xsl:for-each>
5634
- </xsl:template>
5635
-
5636
5574
  <!-- Example:
5637
5575
  <iso-standard>
5576
+ <preface>
5577
+ <page_sequence>
5578
+ <clause...
5579
+ </page_sequence>
5580
+ <page_sequence>
5581
+ <clause...
5582
+ </page_sequence>
5583
+ </preface>
5638
5584
  <sections>
5639
5585
  <page_sequence>
5640
5586
  <clause...
@@ -5651,54 +5597,200 @@
5651
5597
  </page_sequence>
5652
5598
  </iso-standard>
5653
5599
  -->
5654
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
5655
-
5656
- <xsl:variable name="updated_xml_step_move_pagebreak_">
5600
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceAndMainSectionsDefault_items">
5657
5601
 
5602
+ <xsl:variable name="updated_xml_step_move_pagebreak">
5658
5603
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5659
-
5660
5604
  <xsl:call-template name="copyCommonElements"/>
5605
+ <xsl:call-template name="insertPrefaceSectionsPageSequences"/>
5606
+ <xsl:call-template name="insertMainSectionsPageSequences"/>
5607
+ </xsl:element>
5608
+ </xsl:variable>
5609
+
5610
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5661
5611
 
5662
- <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5663
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
5664
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5665
- <xsl:sort select="@displayorder" data-type="number"/>
5666
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5612
+ <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5613
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5614
+ </redirect:write>
5667
5615
 
5668
- </xsl:for-each>
5669
- </xsl:element>
5616
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5617
+
5618
+ <xsl:if test="$debug = 'true'">
5619
+ <redirect:write file="page_sequence_preface_and_main.xml">
5620
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5621
+ </redirect:write>
5622
+ </xsl:if>
5623
+
5624
+ <xsl:call-template name="deleteFile">
5625
+ <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5626
+ </xsl:call-template>
5627
+ </xsl:template> <!-- END: processPrefaceAndMainSectionsDefault_items -->
5628
+
5629
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertPrefaceSectionsPageSequences">
5630
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5631
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5632
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5633
+ <xsl:sort select="@displayorder" data-type="number"/>
5634
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5635
+ </xsl:for-each>
5636
+ </xsl:element>
5637
+ </xsl:element>
5638
+ </xsl:template> <!-- END: insertPrefaceSectionsPageSequences -->
5639
+
5640
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSectionsPageSequences">
5641
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5642
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5643
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5644
+ <xsl:sort select="@displayorder" data-type="number"/>
5645
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5646
+
5647
+ </xsl:for-each>
5648
+ </xsl:element>
5649
+ </xsl:element>
5650
+
5651
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5652
+ <xsl:for-each select="/*/*[local-name()='annex']">
5653
+ <xsl:sort select="@displayorder" data-type="number"/>
5654
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5655
+ </xsl:for-each>
5656
+ </xsl:element>
5657
+
5658
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5659
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5660
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5661
+ <xsl:sort select="@displayorder" data-type="number"/>
5662
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5663
+ </xsl:for-each>
5664
+ </xsl:element>
5665
+ </xsl:element>
5666
+ </xsl:template> <!-- END: insertMainSectionsPageSequences -->
5667
+
5668
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSectionsInSeparatePageSequences">
5669
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5670
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5671
+ <xsl:sort select="@displayorder" data-type="number"/>
5672
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5673
+ <xsl:attribute name="main_page_sequence"/>
5674
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5670
5675
  </xsl:element>
5676
+ </xsl:for-each>
5677
+ </xsl:element>
5678
+
5679
+ <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5680
+
5681
+ <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5671
5682
 
5683
+ <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5684
+ </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
5685
+
5686
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
5687
+ <xsl:for-each select="/*/*[local-name()='annex']">
5688
+ <xsl:sort select="@displayorder" data-type="number"/>
5689
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5690
+ <xsl:attribute name="main_page_sequence"/>
5691
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5692
+ </xsl:element>
5693
+ </xsl:for-each>
5694
+ </xsl:template>
5695
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBibliographyInSeparatePageSequences">
5696
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5697
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5698
+ <xsl:sort select="@displayorder" data-type="number"/>
5672
5699
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
5673
- <xsl:for-each select="/*/*[local-name()='annex']">
5674
- <xsl:sort select="@displayorder" data-type="number"/>
5675
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5676
- </xsl:for-each>
5700
+ <xsl:attribute name="main_page_sequence"/>
5701
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5677
5702
  </xsl:element>
5703
+ </xsl:for-each>
5704
+ </xsl:element>
5705
+ </xsl:template>
5706
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertIndexInSeparatePageSequences">
5707
+ <xsl:for-each select="/*/*[local-name()='indexsect']">
5708
+ <xsl:sort select="@displayorder" data-type="number"/>
5709
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5710
+ <xsl:attribute name="main_page_sequence"/>
5711
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5712
+ </xsl:element>
5713
+ </xsl:for-each>
5714
+ </xsl:template>
5678
5715
 
5716
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processAllSectionsDefault_items">
5717
+ <xsl:variable name="updated_xml_step_move_pagebreak">
5718
+ <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5719
+ <xsl:call-template name="copyCommonElements"/>
5679
5720
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
5680
- <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5681
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5682
- <xsl:sort select="@displayorder" data-type="number"/>
5683
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5684
- </xsl:for-each>
5685
- </xsl:element>
5721
+ <xsl:call-template name="insertPrefaceSections"/>
5722
+ <xsl:call-template name="insertMainSections"/>
5686
5723
  </xsl:element>
5687
5724
  </xsl:element>
5688
5725
  </xsl:variable>
5689
5726
 
5690
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5691
-
5727
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_and_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5728
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
5729
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5692
5730
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5693
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
5731
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5694
5732
  </redirect:write>
5733
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5695
5734
 
5696
5735
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5697
5736
 
5737
+ <!-- TODO: instead of
5738
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
5739
+ in each template, add removing empty page_sequence here
5740
+ -->
5741
+
5742
+ <xsl:if test="$debug = 'true'">
5743
+ <redirect:write file="page_sequence_preface_and_main.xml">
5744
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5745
+ </redirect:write>
5746
+ </xsl:if>
5747
+
5748
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5698
5749
  <xsl:call-template name="deleteFile">
5699
5750
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5700
5751
  </xsl:call-template>
5701
- </xsl:template> <!-- END: processMainSectionsDefault_items -->
5752
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5753
+ </xsl:template> <!-- END: processAllSectionsDefault_items -->
5754
+
5755
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertPrefaceSections">
5756
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5757
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5758
+ <xsl:sort select="@displayorder" data-type="number"/>
5759
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5760
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5761
+ </xsl:apply-templates>
5762
+ </xsl:for-each>
5763
+ </xsl:element>
5764
+ </xsl:template>
5765
+
5766
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSections">
5767
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5768
+
5769
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5770
+ <xsl:sort select="@displayorder" data-type="number"/>
5771
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5772
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5773
+ </xsl:apply-templates>
5774
+
5775
+ </xsl:for-each>
5776
+ </xsl:element>
5777
+
5778
+ <xsl:for-each select="/*/*[local-name()='annex']">
5779
+ <xsl:sort select="@displayorder" data-type="number"/>
5780
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5781
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5782
+ </xsl:apply-templates>
5783
+ </xsl:for-each>
5784
+
5785
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5786
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5787
+ <xsl:sort select="@displayorder" data-type="number"/>
5788
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5789
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5790
+ </xsl:apply-templates>
5791
+ </xsl:for-each>
5792
+ </xsl:element>
5793
+ </xsl:template>
5702
5794
 
5703
5795
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="deleteFile">
5704
5796
  <xsl:param name="filepath"/>
@@ -5707,6 +5799,14 @@
5707
5799
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
5708
5800
  </xsl:template>
5709
5801
 
5802
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
5803
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
5804
+ <xsl:choose>
5805
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
5806
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
5807
+ </xsl:choose>
5808
+ </xsl:template>
5809
+
5710
5810
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5711
5811
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
5712
5812
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
@@ -5735,9 +5835,16 @@
5735
5835
  <xsl:value-of select="substring-before($text, $tag_open)"/>
5736
5836
  <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
5737
5837
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5738
- <fo:inline keep-together.within-line="always">
5739
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5740
- </fo:inline>
5838
+ <xsl:choose>
5839
+ <xsl:when test="local-name(..) = 'keep-together_within-line'"> <!-- prevent two nested <fo:inline keep-together.within-line="always"><fo:inline keep-together.within-line="always" -->
5840
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5841
+ </xsl:when>
5842
+ <xsl:otherwise>
5843
+ <fo:inline keep-together.within-line="always" role="SKIP">
5844
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5845
+ </fo:inline>
5846
+ </xsl:otherwise>
5847
+ </xsl:choose>
5741
5848
  <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
5742
5849
  <xsl:call-template name="replace_fo_inline_tags">
5743
5850
  <xsl:with-param name="tag_open" select="$tag_open"/>
@@ -6044,7 +6151,9 @@
6044
6151
 
6045
6152
  <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'][not(@type = 'units')] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
6046
6153
  <xsl:if test="$isNoteOrFnExist = 'true'">
6047
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
6154
+
6155
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
6156
+
6048
6157
  </xsl:if>
6049
6158
 
6050
6159
  <xsl:choose>
@@ -6101,13 +6210,14 @@
6101
6210
  </fo:table>
6102
6211
 
6103
6212
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
6104
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
6105
- <xsl:call-template name="insertTableFooterInSeparateTable">
6106
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
6107
- <xsl:with-param name="colwidths" select="$colwidths"/>
6108
- <xsl:with-param name="colgroup" select="$colgroup"/>
6109
- </xsl:call-template>
6110
- </xsl:for-each>
6213
+
6214
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
6215
+ <xsl:call-template name="insertTableFooterInSeparateTable">
6216
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
6217
+ <xsl:with-param name="colwidths" select="$colwidths"/>
6218
+ <xsl:with-param name="colgroup" select="$colgroup"/>
6219
+ </xsl:call-template>
6220
+ </xsl:for-each>
6111
6221
 
6112
6222
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
6113
6223
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -6461,8 +6571,10 @@
6461
6571
  <width_min><xsl:value-of select="@width_min"/></width_min>
6462
6572
  <e><xsl:value-of select="$d * $W div $D"/></e>
6463
6573
  <!-- set the column's width to the minimum width plus d times W over D. -->
6574
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
6575
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
6464
6576
  <column divider="100">
6465
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
6577
+ <xsl:value-of select="$column_width"/>
6466
6578
  </column>
6467
6579
  </xsl:for-each>
6468
6580
 
@@ -6921,8 +7033,26 @@
6921
7033
  <xsl:with-param name="default">center</xsl:with-param>
6922
7034
  </xsl:call-template>
6923
7035
 
7036
+ <xsl:copy-of select="@keep-together.within-line"/>
7037
+
6924
7038
  <xsl:call-template name="refine_table-header-cell-style"/>
6925
7039
 
7040
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
7041
+ <!-- <xsl:choose>
7042
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
7043
+ <fo:block-container reference-orientation="270">
7044
+ <fo:block role="SKIP" text-align="start">
7045
+ <xsl:apply-templates />
7046
+ </fo:block>
7047
+ </fo:block-container>
7048
+ </xsl:when>
7049
+ <xsl:otherwise>
7050
+ <fo:block role="SKIP">
7051
+ <xsl:apply-templates />
7052
+ </fo:block>
7053
+ </xsl:otherwise>
7054
+ </xsl:choose> -->
7055
+
6926
7056
  <fo:block role="SKIP">
6927
7057
  <xsl:apply-templates/>
6928
7058
  </fo:block>
@@ -6963,6 +7093,8 @@
6963
7093
  <xsl:with-param name="default">left</xsl:with-param>
6964
7094
  </xsl:call-template>
6965
7095
 
7096
+ <xsl:copy-of select="@keep-together.within-line"/>
7097
+
6966
7098
  <xsl:call-template name="refine_table-cell-style"/>
6967
7099
 
6968
7100
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
@@ -6993,6 +7125,7 @@
6993
7125
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
6994
7126
 
6995
7127
  <fo:block xsl:use-attribute-sets="table-note-style">
7128
+ <xsl:copy-of select="@id"/>
6996
7129
 
6997
7130
  <xsl:call-template name="refine_table-note-style"/>
6998
7131
 
@@ -7086,7 +7219,7 @@
7086
7219
  <xsl:copy-of select="."/>
7087
7220
  </xsl:for-each>
7088
7221
 
7089
- <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
7222
+ <xsl:if test="following-sibling::node()[normalize-space() != ''][1][local-name() = 'fn']">
7090
7223
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
7091
7224
  </xsl:if>
7092
7225
 
@@ -7153,7 +7286,7 @@
7153
7286
  <xsl:copy-of select="node()"/>
7154
7287
  </fn>
7155
7288
  </xsl:for-each>
7156
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*">
7289
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*">
7157
7290
  <xsl:sort select="@displayorder" data-type="number"/>
7158
7291
  <!-- commented:
7159
7292
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
@@ -7227,6 +7360,11 @@
7227
7360
 
7228
7361
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="create_fn">
7229
7362
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
7363
+ <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
7364
+ <xsl:attribute name="id">
7365
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
7366
+ </xsl:attribute>
7367
+ </xsl:if>
7230
7368
 
7231
7369
  <xsl:apply-templates/>
7232
7370
  </fn>
@@ -7370,6 +7508,11 @@
7370
7508
  <xsl:call-template name="refine_fn-reference-style"/>
7371
7509
 
7372
7510
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
7511
+ <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
7512
+ <xsl:attribute name="internal-destination">
7513
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
7514
+ </xsl:attribute>
7515
+ </xsl:if>
7373
7516
 
7374
7517
  <xsl:value-of select="@reference"/>
7375
7518
 
@@ -8411,7 +8554,7 @@
8411
8554
 
8412
8555
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="recursiveSmallCaps">
8413
8556
  <xsl:param name="text"/>
8414
- <xsl:param name="ratio"/>
8557
+ <xsl:param name="ratio">0.75</xsl:param>
8415
8558
  <xsl:variable name="char" select="substring($text,1,1)"/>
8416
8559
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
8417
8560
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
@@ -10418,6 +10561,15 @@
10418
10561
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
10419
10562
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
10420
10563
  </xsl:when>
10564
+ <!-- in WebP format, then convert image into PNG -->
10565
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
10566
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
10567
+ <xsl:value-of select="$src_png"/>
10568
+ </xsl:when>
10569
+ <xsl:when test="not(starts-with(@src, 'data:')) and (java:endsWith(java:java.lang.String.new(@src), '.webp') or java:endsWith(java:java.lang.String.new(@src), '.WEBP'))">
10570
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
10571
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10572
+ </xsl:when>
10421
10573
  <xsl:when test="not(starts-with(@src, 'data:'))">
10422
10574
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10423
10575
  </xsl:when>
@@ -10508,6 +10660,8 @@
10508
10660
  </xsl:choose>
10509
10661
  </xsl:variable>
10510
10662
 
10663
+ <xsl:variable name="isPrecedingTitle" select="normalize-space(ancestor::*[local-name() = 'figure']/preceding-sibling::*[1][local-name() = 'title'] and 1 = 1)"/>
10664
+
10511
10665
  <xsl:choose>
10512
10666
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
10513
10667
  <fo:block>
@@ -10654,7 +10808,14 @@
10654
10808
  <xsl:variable name="scale_y">
10655
10809
  <xsl:choose>
10656
10810
  <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
10657
- <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
10811
+ <xsl:variable name="height_effective_px_">
10812
+ <xsl:choose>
10813
+ <!-- title is 'keep-with-next' with following figure -->
10814
+ <xsl:when test="$isPrecedingTitle = 'true'"><xsl:value-of select="$height_effective_px - 80"/></xsl:when>
10815
+ <xsl:otherwise><xsl:value-of select="$height_effective_px"/></xsl:otherwise>
10816
+ </xsl:choose>
10817
+ </xsl:variable>
10818
+ <xsl:value-of select="$height_effective_px_ div ($svg_height * $scale_x)"/>
10658
10819
  </xsl:when>
10659
10820
  <xsl:otherwise>1</xsl:otherwise>
10660
10821
  </xsl:choose>
@@ -11073,7 +11234,7 @@
11073
11234
  </xsl:if>
11074
11235
 
11075
11236
  <xsl:for-each select="$contents_nodes/doc">
11076
- <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
11237
+ <fo:bookmark internal-destination="{contents/item[@display = 'true'][1]/@id}" starting-state="hide">
11077
11238
  <xsl:if test="@bundle = 'true'">
11078
11239
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
11079
11240
  </xsl:if>
@@ -12287,9 +12448,17 @@
12287
12448
 
12288
12449
  <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP">
12289
12450
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
12290
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12291
- <xsl:with-param name="fo_element" select="$fo_element"/>
12292
- </xsl:apply-templates>
12451
+ <xsl:variable name="example_body">
12452
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12453
+ <xsl:with-param name="fo_element" select="$fo_element"/>
12454
+ </xsl:apply-templates>
12455
+ </xsl:variable>
12456
+ <xsl:choose>
12457
+ <xsl:when test="xalan:nodeset($example_body)/*">
12458
+ <xsl:copy-of select="$example_body"/>
12459
+ </xsl:when>
12460
+ <xsl:otherwise><fo:block/><!-- prevent empty block-container --></xsl:otherwise>
12461
+ </xsl:choose>
12293
12462
  </fo:block-container>
12294
12463
  </fo:block-container>
12295
12464
  </xsl:when> <!-- end block -->
@@ -12822,7 +12991,22 @@
12822
12991
 
12823
12992
  <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
12824
12993
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'sections']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2">
12825
- <xsl:call-template name="sections_node"/>
12994
+ <xsl:choose>
12995
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
12996
+ <xsl:otherwise>
12997
+ <xsl:call-template name="sections_node"/>
12998
+ </xsl:otherwise>
12999
+ </xsl:choose>
13000
+ </xsl:template>
13001
+
13002
+ <!-- page_sequence/sections/clause -->
13003
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'sections']/*[not(@top-level)]" priority="2">
13004
+ <xsl:choose>
13005
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13006
+ <xsl:otherwise>
13007
+ <xsl:call-template name="sections_node"/>
13008
+ </xsl:otherwise>
13009
+ </xsl:choose>
12826
13010
  </xsl:template>
12827
13011
 
12828
13012
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="sections_element_style">
@@ -12839,8 +13023,24 @@
12839
13023
  </fo:block>
12840
13024
  </xsl:template>
12841
13025
 
12842
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
12843
- <xsl:call-template name="preface_node"/>
13026
+ <!-- preface/ page_sequence/clause -->
13027
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
13028
+ <xsl:choose>
13029
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13030
+ <xsl:otherwise>
13031
+ <xsl:call-template name="preface_node"/>
13032
+ </xsl:otherwise>
13033
+ </xsl:choose>
13034
+ </xsl:template>
13035
+
13036
+ <!-- page_sequence/preface/clause -->
13037
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'preface']/*[not(@top-level)]" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
13038
+ <xsl:choose>
13039
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13040
+ <xsl:otherwise>
13041
+ <xsl:call-template name="preface_node"/>
13042
+ </xsl:otherwise>
13043
+ </xsl:choose>
12844
13044
  </xsl:template>
12845
13045
 
12846
13046
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
@@ -14141,6 +14341,82 @@
14141
14341
  <!-- ===================================== -->
14142
14342
  <!-- Update xml -->
14143
14343
  <!-- ===================================== -->
14344
+
14345
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
14346
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
14347
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
14348
+
14349
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
14350
+ <xsl:variable name="updated_xml_step1">
14351
+ <xsl:if test="$table_if = 'false'">
14352
+ <xsl:apply-templates mode="update_xml_step1"/>
14353
+ </xsl:if>
14354
+ </xsl:variable>
14355
+
14356
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
14357
+ <xsl:if test="$debug = 'true'">
14358
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
14359
+ <xsl:message>END updated_xml_step1</xsl:message>
14360
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
14361
+ <xsl:copy-of select="$updated_xml_step1"/>
14362
+ </redirect:write> -->
14363
+ </xsl:if>
14364
+
14365
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
14366
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
14367
+
14368
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
14369
+ <xsl:variable name="updated_xml_step2">
14370
+
14371
+ <xsl:if test="$table_if = 'false'">
14372
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step1)" mode="update_xml_step2"/>
14373
+ </xsl:if>
14374
+
14375
+ </xsl:variable>
14376
+
14377
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
14378
+ <xsl:if test="$debug = 'true'">
14379
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
14380
+ <xsl:message>END updated_xml_step2</xsl:message>
14381
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
14382
+ <xsl:copy-of select="$updated_xml_step2"/>
14383
+ </redirect:write> -->
14384
+ </xsl:if>
14385
+
14386
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
14387
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
14388
+
14389
+ <xsl:variable name="updated_xml_step3">
14390
+ <xsl:choose>
14391
+ <xsl:when test="$table_if = 'false'">
14392
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
14393
+ </xsl:when>
14394
+ <xsl:otherwise>
14395
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
14396
+ </xsl:otherwise>
14397
+ </xsl:choose>
14398
+ </xsl:variable>
14399
+
14400
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
14401
+ <xsl:if test="$debug = 'true'">
14402
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
14403
+ <xsl:message>END updated_xml_step3</xsl:message>
14404
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
14405
+ <xsl:copy-of select="$updated_xml_step3"/>
14406
+ </redirect:write> -->
14407
+ </xsl:if>
14408
+
14409
+ <!-- <xsl:if test="$debug = 'true'"><xsl:message>START copying updated_xml_step3</xsl:message></xsl:if>
14410
+ <xsl:variable name="startTime4" select="java:getTime(java:java.util.Date.new())"/> -->
14411
+ <xsl:copy-of select="$updated_xml_step3"/>
14412
+ <!-- <xsl:variable name="endTime4" select="java:getTime(java:java.util.Date.new())"/>
14413
+ <xsl:if test="$debug = 'true'">
14414
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime4 - $startTime4"/> msec.</xsl:message>
14415
+ <xsl:message>END copying updated_xml_step3</xsl:message>
14416
+ </xsl:if> -->
14417
+
14418
+ </xsl:template>
14419
+
14144
14420
  <!-- =========================================================================== -->
14145
14421
  <!-- STEP1: -->
14146
14422
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -14319,14 +14595,17 @@
14319
14595
  <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
14320
14596
  <!-- =========================================================================== -->
14321
14597
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="update_xml_step_move_pagebreak">
14598
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14322
14599
  <xsl:copy>
14323
- <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/>
14600
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak">
14601
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14602
+ </xsl:apply-templates>
14324
14603
  </xsl:copy>
14325
14604
  </xsl:template>
14326
14605
 
14327
14606
  <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
14328
14607
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'pagebreak'][not(following-sibling::*[1][local-name() = 'pagebreak'])]" mode="update_xml_step_move_pagebreak">
14329
-
14608
+ <xsl:param name="page_sequence_at_top"/>
14330
14609
  <!-- <xsl:choose>
14331
14610
  <xsl:when test="ancestor::*[local-name() = 'sections']">
14332
14611
 
@@ -14340,7 +14619,7 @@
14340
14619
 
14341
14620
  <!-- determine pagebreak is last element before </fo:flow> or not -->
14342
14621
  <xsl:variable name="isLast">
14343
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14622
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14344
14623
  <xsl:if test="following-sibling::*">false</xsl:if>
14345
14624
  </xsl:for-each>
14346
14625
  </xsl:variable>
@@ -14350,7 +14629,9 @@
14350
14629
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
14351
14630
 
14352
14631
  <xsl:variable name="tree_">
14353
- <xsl:call-template name="makeAncestorsElementsTree"/>
14632
+ <xsl:call-template name="makeAncestorsElementsTree">
14633
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14634
+ </xsl:call-template>
14354
14635
  </xsl:variable>
14355
14636
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14356
14637
 
@@ -14362,7 +14643,7 @@
14362
14643
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
14363
14644
 
14364
14645
  <!-- create a new page_sequence (opening elements) -->
14365
- <xsl:text disable-output-escaping="yes">&lt;page_sequence namespace="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
14646
+ <xsl:text disable-output-escaping="yes">&lt;page_sequence xmlns="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
14366
14647
 
14367
14648
  <xsl:call-template name="insertOpeningElements">
14368
14649
  <xsl:with-param name="tree" select="$tree"/>
@@ -14372,12 +14653,26 @@
14372
14653
  </xsl:template>
14373
14654
 
14374
14655
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
14375
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14376
- <element pos="{position()}">
14377
- <xsl:copy-of select="@*[local-name() != 'id']"/>
14378
- <xsl:value-of select="name()"/>
14379
- </element>
14380
- </xsl:for-each>
14656
+ <xsl:param name="page_sequence_at_top"/>
14657
+
14658
+ <xsl:choose>
14659
+ <xsl:when test="$page_sequence_at_top = 'true'">
14660
+ <xsl:for-each select="ancestor::*[ancestor::*[contains(local-name(), '-standard')]]">
14661
+ <element pos="{position()}">
14662
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14663
+ <xsl:value-of select="name()"/>
14664
+ </element>
14665
+ </xsl:for-each>
14666
+ </xsl:when>
14667
+ <xsl:otherwise>
14668
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14669
+ <element pos="{position()}">
14670
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14671
+ <xsl:value-of select="name()"/>
14672
+ </element>
14673
+ </xsl:for-each>
14674
+ </xsl:otherwise>
14675
+ </xsl:choose>
14381
14676
  </xsl:template>
14382
14677
 
14383
14678
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertClosingElements">
@@ -14415,11 +14710,14 @@
14415
14710
 
14416
14711
  <!-- move full page width figures, tables at top level -->
14417
14712
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'figure' or local-name() = 'table'][normalize-space(@width) != 'text-width']" mode="update_xml_step_move_pagebreak">
14713
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14418
14714
  <xsl:choose>
14419
14715
  <xsl:when test="$layout_columns != 1">
14420
14716
 
14421
14717
  <xsl:variable name="tree_">
14422
- <xsl:call-template name="makeAncestorsElementsTree"/>
14718
+ <xsl:call-template name="makeAncestorsElementsTree">
14719
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14720
+ </xsl:call-template>
14423
14721
  </xsl:variable>
14424
14722
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14425
14723
 
@@ -14567,81 +14865,140 @@
14567
14865
 
14568
14866
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_separators">_.\</xsl:variable>
14569
14867
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/>
14868
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_express_reference">(^([A-Za-z0-9_.\\]+)$)</xsl:variable>
14570
14869
 
14571
14870
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
14871
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14872
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14572
14873
 
14573
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
14874
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14875
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14876
+ <!-- add &lt; and &gt; to \S -->
14877
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14878
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable>
14574
14879
 
14575
- <!-- enclose standard's number into tag 'keep-together_within-line' -->
14576
- <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14577
- <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14578
- <xsl:variable name="text__" select="java:replaceAll(java:java.lang.String.new(.), $regex_standard_reference, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14579
- <xsl:variable name="text_">
14580
- <xsl:choose>
14581
- <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when> <!-- no need enclose standard's number into tag 'keep-together_within-line' in table cells -->
14582
- <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
14583
- </xsl:choose>
14584
- </xsl:variable>
14585
- <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
14880
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14881
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
14882
+
14883
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') or normalize-space() = '' )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
14884
+
14885
+ <xsl:variable name="parent" select="local-name(..)"/>
14886
+
14887
+ <xsl:if test="1 = 2"> <!-- alternative variant -->
14888
+
14889
+ <xsl:variable name="regexs">
14890
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14891
+ <xsl:if test="not(ancestor::*[local-name() = 'table'])"><regex><xsl:value-of select="$regex_standard_reference"/></regex></xsl:if>
14892
+ <!-- if EXPRESS reference -->
14893
+
14894
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14895
+ <regex><xsl:value-of select="$regex_solidus_units"/></regex>
14896
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14897
+ <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14898
+ <regex><xsl:value-of select="$regex_dots_units"/></regex>
14899
+ </xsl:if>
14900
+ </xsl:variable>
14901
+
14902
+ <xsl:variable name="regex_replacement"><xsl:text>(</xsl:text>
14903
+ <xsl:for-each select="xalan:nodeset($regexs)/regex">
14904
+ <xsl:value-of select="."/>
14905
+ <xsl:if test="position() != last()">|</xsl:if>
14906
+ </xsl:for-each>
14907
+ <xsl:text>)</xsl:text>
14908
+ </xsl:variable>
14909
+
14910
+ <!-- regex_replacement='<xsl:value-of select="$regex_replacement"/>' -->
14911
+
14912
+ <xsl:variable name="text_replaced" select="java:replaceAll(java:java.lang.String.new(.), $regex_replacement, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14913
+
14914
+ <!-- text_replaced='<xsl:value-of select="$text_replaced"/>' -->
14915
+
14916
+ <xsl:call-template name="replace_text_tags">
14586
14917
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14587
14918
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14588
- <xsl:with-param name="text" select="$text_"/>
14589
- </xsl:call-template></text></xsl:variable>
14919
+ <xsl:with-param name="text" select="$text_replaced"/>
14920
+ </xsl:call-template>
14921
+ </xsl:if>
14590
14922
 
14591
- <xsl:variable name="parent" select="local-name(..)"/>
14923
+ <xsl:if test="1 = 1">
14924
+
14925
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14926
+ <xsl:variable name="text">
14927
+ <xsl:element name="text" namespace="{$namespace_full}">
14928
+ <xsl:choose>
14929
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when> <!-- no need enclose standard's number into tag 'keep-together_within-line' in table cells -->
14930
+ <xsl:otherwise>
14931
+ <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.), $regex_standard_reference, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14932
+ <!-- <xsl:value-of select="$text__"/> -->
14933
+
14934
+ <xsl:call-template name="replace_text_tags">
14935
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14936
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14937
+ <xsl:with-param name="text" select="$text_"/>
14938
+ </xsl:call-template>
14939
+
14940
+ </xsl:otherwise>
14941
+ </xsl:choose>
14942
+ </xsl:element>
14943
+ </xsl:variable>
14592
14944
 
14593
14945
  <xsl:variable name="text2">
14594
- <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
14946
+ <xsl:element name="text" namespace="{$namespace_full}">
14947
+ <xsl:for-each select="xalan:nodeset($text)/*[local-name() = 'text']/node()">
14595
14948
  <xsl:copy-of select="."/>
14596
- </xsl:for-each></text>
14949
+ </xsl:for-each>
14950
+ </xsl:element>
14597
14951
  </xsl:variable>
14598
14952
 
14599
14953
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14600
- <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14601
- <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14602
- <!-- add &lt; and &gt; to \S -->
14603
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14604
- <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable>
14605
14954
  <xsl:variable name="text3">
14606
- <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
14607
- <xsl:choose>
14608
- <xsl:when test="self::text()">
14609
- <xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14610
- <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
14611
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14612
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14613
- <xsl:with-param name="text" select="$text_units_"/>
14614
- </xsl:call-template></text></xsl:variable>
14615
- <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
14616
- </xsl:when>
14617
- <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14618
- </xsl:choose>
14619
- </xsl:for-each></text>
14955
+ <xsl:element name="text" namespace="{$namespace_full}">
14956
+ <xsl:for-each select="xalan:nodeset($text2)/*[local-name() = 'text']/node()">
14957
+ <xsl:choose>
14958
+ <xsl:when test="self::text()">
14959
+ <xsl:variable name="text_units" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14960
+ <!-- <xsl:variable name="text_units">
14961
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14962
+ <xsl:call-template name="replace_text_tags">
14963
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14964
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14965
+ <xsl:with-param name="text" select="$text_units"/>
14966
+ </xsl:call-template>
14967
+ <!-- </xsl:element>
14968
+ </xsl:variable>
14969
+ <xsl:copy-of select="xalan:nodeset($text_units)/*[local-name() = 'text']/node()"/> -->
14970
+ </xsl:when>
14971
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14972
+ </xsl:choose>
14973
+ </xsl:for-each>
14974
+ </xsl:element>
14620
14975
  </xsl:variable>
14621
14976
 
14622
14977
  <xsl:choose>
14623
14978
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14624
14979
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14625
- <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14626
- <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
14627
- <xsl:for-each select="xalan:nodeset($text3)/text/node()">
14980
+ <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()">
14628
14981
  <xsl:choose>
14629
14982
  <xsl:when test="self::text()">
14630
- <xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14631
- <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
14632
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14633
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14634
- <xsl:with-param name="text" select="$text_dots_"/>
14635
- </xsl:call-template></text></xsl:variable>
14636
- <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
14983
+ <xsl:variable name="text_dots" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
14984
+ <!-- <xsl:variable name="text_dots">
14985
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14986
+ <xsl:call-template name="replace_text_tags">
14987
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14988
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14989
+ <xsl:with-param name="text" select="$text_dots"/>
14990
+ </xsl:call-template>
14991
+ <!-- </xsl:element>
14992
+ </xsl:variable>
14993
+ <xsl:copy-of select="xalan:nodeset($text_dots)/*[local-name() = 'text']/node()"/> -->
14637
14994
  </xsl:when>
14638
14995
  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14639
14996
  </xsl:choose>
14640
14997
  </xsl:for-each>
14641
14998
  </xsl:when>
14642
- <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
14999
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"/></xsl:otherwise>
14643
15000
  </xsl:choose>
14644
-
15001
+ </xsl:if>
14645
15002
  </xsl:template>
14646
15003
 
14647
15004
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
@@ -14657,7 +15014,7 @@
14657
15014
  <xsl:value-of select="substring-before($text, $tag_open)"/>
14658
15015
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
14659
15016
 
14660
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
15017
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
14661
15018
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
14662
15019
  </xsl:element>
14663
15020
 
@@ -15162,6 +15519,15 @@
15162
15519
  </xsl:otherwise>
15163
15520
  </xsl:choose>
15164
15521
  </xsl:for-each>
15522
+ <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15523
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15524
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15525
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15526
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15527
+ <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15528
+ <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15529
+ </xsl:for-each>
15530
+ </xsl:if>
15165
15531
  </xsl:template> <!-- addPDFUAmeta -->
15166
15532
 
15167
15533
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getId">
@@ -15477,7 +15843,10 @@
15477
15843
  <xsl:call-template name="setTextAlignment">
15478
15844
  <xsl:with-param name="default" select="$text_align_default"/>
15479
15845
  </xsl:call-template>
15846
+ <xsl:call-template name="setKeepAttributes"/>
15847
+ </xsl:template>
15480
15848
 
15849
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
15481
15850
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
15482
15851
  <!-- Example: keep-lines-together="true" -->
15483
15852
  <xsl:if test="@keep-lines-together = 'true'">
@@ -15489,6 +15858,72 @@
15489
15858
  </xsl:if>
15490
15859
  </xsl:template>
15491
15860
 
15861
+ <!-- insert cover page image -->
15862
+ <!-- background cover image -->
15863
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
15864
+ <xsl:param name="number">1</xsl:param>
15865
+ <xsl:param name="name">coverpage-image</xsl:param>
15866
+ <xsl:variable name="num" select="number($number)"/>
15867
+ <!-- background image -->
15868
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
15869
+ <fo:block>
15870
+ <xsl:for-each select="/*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = $name][1]/*[local-name() = 'value']/*[local-name() = 'image'][$num]">
15871
+ <xsl:choose>
15872
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
15873
+ <fo:instream-foreign-object fox:alt-text="Image Front">
15874
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
15875
+ <xsl:call-template name="getSVG"/>
15876
+ </fo:instream-foreign-object>
15877
+ </xsl:when>
15878
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
15879
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
15880
+ </xsl:when>
15881
+ <xsl:otherwise> <!-- bitmap image -->
15882
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
15883
+ <xsl:if test="$coverimage_src != ''">
15884
+ <xsl:variable name="coverpage">
15885
+ <xsl:call-template name="getImageURL">
15886
+ <xsl:with-param name="src" select="$coverimage_src"/>
15887
+ </xsl:call-template>
15888
+ </xsl:variable>
15889
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
15890
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
15891
+ </xsl:if>
15892
+ </xsl:otherwise>
15893
+ </xsl:choose>
15894
+ </xsl:for-each>
15895
+ </fo:block>
15896
+ </fo:block-container>
15897
+ </xsl:template>
15898
+
15899
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
15900
+ <xsl:param name="src"/>
15901
+ <xsl:choose>
15902
+ <xsl:when test="starts-with($src, 'data:image')">
15903
+ <xsl:value-of select="$src"/>
15904
+ </xsl:when>
15905
+ <xsl:otherwise>
15906
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
15907
+ </xsl:otherwise>
15908
+ </xsl:choose>
15909
+ </xsl:template>
15910
+
15911
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
15912
+ <xsl:choose>
15913
+ <xsl:when test="*[local-name() = 'svg']">
15914
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
15915
+ </xsl:when>
15916
+ <xsl:otherwise>
15917
+ <xsl:variable name="svg_content" select="document(@src)"/>
15918
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
15919
+ <xsl:apply-templates select="." mode="svg_update"/>
15920
+ </xsl:for-each>
15921
+ </xsl:otherwise>
15922
+ </xsl:choose>
15923
+ </xsl:template>
15924
+
15925
+ <!-- END: insert cover page image -->
15926
+
15492
15927
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
15493
15928
  <xsl:param name="number"/>
15494
15929
  <xsl:param name="first"/>