metanorma-ieee 1.2.10 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -3800,6 +3800,8 @@
3800
3800
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
3801
3801
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
3802
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
+
3803
3805
  <!-- external parameters -->
3804
3806
 
3805
3807
  <xsl:param xmlns:redirect="http://xml.apache.org/xalan/redirect" name="svg_images"/> <!-- svg images array -->
@@ -5546,56 +5548,9 @@
5546
5548
  </xsl:for-each>
5547
5549
  </xsl:template>
5548
5550
 
5549
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
5550
-
5551
- <xsl:variable name="updated_xml_step_move_pagebreak">
5552
-
5553
- <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5554
-
5555
- <xsl:call-template name="copyCommonElements"/>
5556
-
5557
- <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5558
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
5559
- <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5560
- <xsl:sort select="@displayorder" data-type="number"/>
5561
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5562
- </xsl:for-each>
5563
- </xsl:element>
5564
- </xsl:element>
5565
- </xsl:element>
5566
- </xsl:variable>
5567
-
5568
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5569
- <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
5570
- <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5571
- <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5572
- <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5573
- </redirect:write>
5574
- <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5575
-
5576
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5577
-
5578
- <!-- TODO: instead of
5579
- <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
5580
- in each template, add removing empty page_sequence here
5581
- -->
5582
-
5583
- <xsl:if test="$debug = 'true'">
5584
- <redirect:write file="page_sequence_preface.xml">
5585
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5586
- </redirect:write>
5587
- </xsl:if>
5588
-
5589
- <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5590
- <xsl:call-template name="deleteFile">
5591
- <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5592
- </xsl:call-template>
5593
- <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5594
- </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
5595
-
5596
5551
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
5597
5552
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
5598
- <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']"/>
5599
5554
  </xsl:template>
5600
5555
 
5601
5556
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault">
@@ -5616,8 +5571,16 @@
5616
5571
  </xsl:for-each>
5617
5572
  </xsl:template><!-- END: processMainSectionsDefault -->
5618
5573
 
5619
- <!-- Example:
5574
+ <!-- Example:
5620
5575
  <iso-standard>
5576
+ <preface>
5577
+ <page_sequence>
5578
+ <clause...
5579
+ </page_sequence>
5580
+ <page_sequence>
5581
+ <clause...
5582
+ </page_sequence>
5583
+ </preface>
5621
5584
  <sections>
5622
5585
  <page_sequence>
5623
5586
  <clause...
@@ -5634,60 +5597,200 @@
5634
5597
  </page_sequence>
5635
5598
  </iso-standard>
5636
5599
  -->
5637
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
5600
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceAndMainSectionsDefault_items">
5638
5601
 
5639
5602
  <xsl:variable name="updated_xml_step_move_pagebreak">
5640
-
5641
5603
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5642
-
5643
5604
  <xsl:call-template name="copyCommonElements"/>
5605
+ <xsl:call-template name="insertPrefaceSectionsPageSequences"/>
5606
+ <xsl:call-template name="insertMainSectionsPageSequences"/>
5607
+ </xsl:element>
5608
+ </xsl:variable>
5644
5609
 
5645
- <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5646
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
5647
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5648
- <xsl:sort select="@displayorder" data-type="number"/>
5649
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5610
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5650
5611
 
5651
- </xsl:for-each>
5652
- </xsl:element>
5612
+ <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5613
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5614
+ </redirect:write>
5615
+
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"/>
5653
5675
  </xsl:element>
5676
+ </xsl:for-each>
5677
+ </xsl:element>
5678
+
5679
+ <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5654
5680
 
5681
+ <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
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"/>
5655
5699
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
5656
- <xsl:for-each select="/*/*[local-name()='annex']">
5657
- <xsl:sort select="@displayorder" data-type="number"/>
5658
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5659
- </xsl:for-each>
5700
+ <xsl:attribute name="main_page_sequence"/>
5701
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5660
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>
5661
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"/>
5662
5720
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
5663
- <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5664
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5665
- <xsl:sort select="@displayorder" data-type="number"/>
5666
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5667
- </xsl:for-each>
5668
- </xsl:element>
5721
+ <xsl:call-template name="insertPrefaceSections"/>
5722
+ <xsl:call-template name="insertMainSections"/>
5669
5723
  </xsl:element>
5670
5724
  </xsl:element>
5671
5725
  </xsl:variable>
5672
5726
 
5673
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5674
-
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> -->
5675
5730
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5676
5731
  <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5677
5732
  </redirect:write>
5733
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5678
5734
 
5679
5735
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5680
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
+
5681
5742
  <xsl:if test="$debug = 'true'">
5682
- <redirect:write file="page_sequence_main.xml">
5683
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5743
+ <redirect:write file="page_sequence_preface_and_main.xml">
5744
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5684
5745
  </redirect:write>
5685
5746
  </xsl:if>
5686
5747
 
5748
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5687
5749
  <xsl:call-template name="deleteFile">
5688
5750
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5689
5751
  </xsl:call-template>
5690
- </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>
5691
5794
 
5692
5795
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="deleteFile">
5693
5796
  <xsl:param name="filepath"/>
@@ -5732,9 +5835,16 @@
5732
5835
  <xsl:value-of select="substring-before($text, $tag_open)"/>
5733
5836
  <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
5734
5837
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5735
- <fo:inline keep-together.within-line="always">
5736
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5737
- </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>
5738
5848
  <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
5739
5849
  <xsl:call-template name="replace_fo_inline_tags">
5740
5850
  <xsl:with-param name="tag_open" select="$tag_open"/>
@@ -6923,6 +7033,8 @@
6923
7033
  <xsl:with-param name="default">center</xsl:with-param>
6924
7034
  </xsl:call-template>
6925
7035
 
7036
+ <xsl:copy-of select="@keep-together.within-line"/>
7037
+
6926
7038
  <xsl:call-template name="refine_table-header-cell-style"/>
6927
7039
 
6928
7040
  <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
@@ -6981,6 +7093,8 @@
6981
7093
  <xsl:with-param name="default">left</xsl:with-param>
6982
7094
  </xsl:call-template>
6983
7095
 
7096
+ <xsl:copy-of select="@keep-together.within-line"/>
7097
+
6984
7098
  <xsl:call-template name="refine_table-cell-style"/>
6985
7099
 
6986
7100
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
@@ -7011,6 +7125,7 @@
7011
7125
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
7012
7126
 
7013
7127
  <fo:block xsl:use-attribute-sets="table-note-style">
7128
+ <xsl:copy-of select="@id"/>
7014
7129
 
7015
7130
  <xsl:call-template name="refine_table-note-style"/>
7016
7131
 
@@ -7104,7 +7219,7 @@
7104
7219
  <xsl:copy-of select="."/>
7105
7220
  </xsl:for-each>
7106
7221
 
7107
- <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
7222
+ <xsl:if test="following-sibling::node()[normalize-space() != ''][1][local-name() = 'fn']">
7108
7223
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
7109
7224
  </xsl:if>
7110
7225
 
@@ -7171,7 +7286,7 @@
7171
7286
  <xsl:copy-of select="node()"/>
7172
7287
  </fn>
7173
7288
  </xsl:for-each>
7174
- <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']/*">
7175
7290
  <xsl:sort select="@displayorder" data-type="number"/>
7176
7291
  <!-- commented:
7177
7292
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
@@ -7245,6 +7360,11 @@
7245
7360
 
7246
7361
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="create_fn">
7247
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>
7248
7368
 
7249
7369
  <xsl:apply-templates/>
7250
7370
  </fn>
@@ -7388,6 +7508,11 @@
7388
7508
  <xsl:call-template name="refine_fn-reference-style"/>
7389
7509
 
7390
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>
7391
7516
 
7392
7517
  <xsl:value-of select="@reference"/>
7393
7518
 
@@ -8429,7 +8554,7 @@
8429
8554
 
8430
8555
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="recursiveSmallCaps">
8431
8556
  <xsl:param name="text"/>
8432
- <xsl:param name="ratio"/>
8557
+ <xsl:param name="ratio">0.75</xsl:param>
8433
8558
  <xsl:variable name="char" select="substring($text,1,1)"/>
8434
8559
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
8435
8560
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
@@ -10535,6 +10660,8 @@
10535
10660
  </xsl:choose>
10536
10661
  </xsl:variable>
10537
10662
 
10663
+ <xsl:variable name="isPrecedingTitle" select="normalize-space(ancestor::*[local-name() = 'figure']/preceding-sibling::*[1][local-name() = 'title'] and 1 = 1)"/>
10664
+
10538
10665
  <xsl:choose>
10539
10666
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
10540
10667
  <fo:block>
@@ -10681,7 +10808,14 @@
10681
10808
  <xsl:variable name="scale_y">
10682
10809
  <xsl:choose>
10683
10810
  <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
10684
- <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)"/>
10685
10819
  </xsl:when>
10686
10820
  <xsl:otherwise>1</xsl:otherwise>
10687
10821
  </xsl:choose>
@@ -11100,7 +11234,7 @@
11100
11234
  </xsl:if>
11101
11235
 
11102
11236
  <xsl:for-each select="$contents_nodes/doc">
11103
- <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">
11104
11238
  <xsl:if test="@bundle = 'true'">
11105
11239
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
11106
11240
  </xsl:if>
@@ -12314,9 +12448,17 @@
12314
12448
 
12315
12449
  <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP">
12316
12450
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
12317
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12318
- <xsl:with-param name="fo_element" select="$fo_element"/>
12319
- </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>
12320
12462
  </fo:block-container>
12321
12463
  </fo:block-container>
12322
12464
  </xsl:when> <!-- end block -->
@@ -12849,7 +12991,22 @@
12849
12991
 
12850
12992
  <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
12851
12993
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'sections']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2">
12852
- <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>
12853
13010
  </xsl:template>
12854
13011
 
12855
13012
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="sections_element_style">
@@ -12866,8 +13023,24 @@
12866
13023
  </fo:block>
12867
13024
  </xsl:template>
12868
13025
 
12869
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
12870
- <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>
12871
13044
  </xsl:template>
12872
13045
 
12873
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 -->
@@ -14233,7 +14406,14 @@
14233
14406
  </redirect:write> -->
14234
14407
  </xsl:if>
14235
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())"/> -->
14236
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> -->
14237
14417
 
14238
14418
  </xsl:template>
14239
14419
 
@@ -14415,14 +14595,17 @@
14415
14595
  <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
14416
14596
  <!-- =========================================================================== -->
14417
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>
14418
14599
  <xsl:copy>
14419
- <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>
14420
14603
  </xsl:copy>
14421
14604
  </xsl:template>
14422
14605
 
14423
14606
  <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
14424
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">
14425
-
14608
+ <xsl:param name="page_sequence_at_top"/>
14426
14609
  <!-- <xsl:choose>
14427
14610
  <xsl:when test="ancestor::*[local-name() = 'sections']">
14428
14611
 
@@ -14446,7 +14629,9 @@
14446
14629
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
14447
14630
 
14448
14631
  <xsl:variable name="tree_">
14449
- <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>
14450
14635
  </xsl:variable>
14451
14636
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14452
14637
 
@@ -14468,12 +14653,26 @@
14468
14653
  </xsl:template>
14469
14654
 
14470
14655
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
14471
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14472
- <element pos="{position()}">
14473
- <xsl:copy-of select="@*[local-name() != 'id']"/>
14474
- <xsl:value-of select="name()"/>
14475
- </element>
14476
- </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>
14477
14676
  </xsl:template>
14478
14677
 
14479
14678
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertClosingElements">
@@ -14511,11 +14710,14 @@
14511
14710
 
14512
14711
  <!-- move full page width figures, tables at top level -->
14513
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>
14514
14714
  <xsl:choose>
14515
14715
  <xsl:when test="$layout_columns != 1">
14516
14716
 
14517
14717
  <xsl:variable name="tree_">
14518
- <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>
14519
14721
  </xsl:variable>
14520
14722
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14521
14723
 
@@ -14663,81 +14865,140 @@
14663
14865
 
14664
14866
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_separators">_.\</xsl:variable>
14665
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>
14666
14869
 
14667
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>
14668
14873
 
14669
- <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>
14670
14879
 
14671
- <!-- enclose standard's number into tag 'keep-together_within-line' -->
14672
- <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14673
- <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14674
- <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))"/>
14675
- <xsl:variable name="text_">
14676
- <xsl:choose>
14677
- <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 -->
14678
- <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
14679
- </xsl:choose>
14680
- </xsl:variable>
14681
- <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">
14682
14917
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14683
14918
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14684
- <xsl:with-param name="text" select="$text_"/>
14685
- </xsl:call-template></text></xsl:variable>
14919
+ <xsl:with-param name="text" select="$text_replaced"/>
14920
+ </xsl:call-template>
14921
+ </xsl:if>
14686
14922
 
14687
- <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>
14688
14944
 
14689
14945
  <xsl:variable name="text2">
14690
- <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()">
14691
14948
  <xsl:copy-of select="."/>
14692
- </xsl:for-each></text>
14949
+ </xsl:for-each>
14950
+ </xsl:element>
14693
14951
  </xsl:variable>
14694
14952
 
14695
14953
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14696
- <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14697
- <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14698
- <!-- add &lt; and &gt; to \S -->
14699
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14700
- <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>
14701
14954
  <xsl:variable name="text3">
14702
- <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
14703
- <xsl:choose>
14704
- <xsl:when test="self::text()">
14705
- <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))"/>
14706
- <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
14707
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14708
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14709
- <xsl:with-param name="text" select="$text_units_"/>
14710
- </xsl:call-template></text></xsl:variable>
14711
- <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
14712
- </xsl:when>
14713
- <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14714
- </xsl:choose>
14715
- </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>
14716
14975
  </xsl:variable>
14717
14976
 
14718
14977
  <xsl:choose>
14719
14978
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14720
14979
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14721
- <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14722
- <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>
14723
- <xsl:for-each select="xalan:nodeset($text3)/text/node()">
14980
+ <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()">
14724
14981
  <xsl:choose>
14725
14982
  <xsl:when test="self::text()">
14726
- <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))"/>
14727
- <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
14728
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14729
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14730
- <xsl:with-param name="text" select="$text_dots_"/>
14731
- </xsl:call-template></text></xsl:variable>
14732
- <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()"/> -->
14733
14994
  </xsl:when>
14734
14995
  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14735
14996
  </xsl:choose>
14736
14997
  </xsl:for-each>
14737
14998
  </xsl:when>
14738
- <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>
14739
15000
  </xsl:choose>
14740
-
15001
+ </xsl:if>
14741
15002
  </xsl:template>
14742
15003
 
14743
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">
@@ -15258,6 +15519,15 @@
15258
15519
  </xsl:otherwise>
15259
15520
  </xsl:choose>
15260
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>
15261
15531
  </xsl:template> <!-- addPDFUAmeta -->
15262
15532
 
15263
15533
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getId">