metanorma-ieee 1.2.10 → 1.2.12

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"/>
5680
+
5681
+ <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5654
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>
@@ -11419,8 +11553,11 @@
11419
11553
  </xsl:template>
11420
11554
 
11421
11555
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'strong']" mode="contents_item">
11556
+ <xsl:param name="element"/>
11422
11557
  <xsl:copy>
11423
- <xsl:apply-templates mode="contents_item"/>
11558
+ <xsl:apply-templates mode="contents_item">
11559
+ <xsl:with-param name="element" select="$element"/>
11560
+ </xsl:apply-templates>
11424
11561
  </xsl:copy>
11425
11562
  </xsl:template>
11426
11563
 
@@ -11487,7 +11624,10 @@
11487
11624
 
11488
11625
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
11489
11626
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'span']" mode="contents_item">
11490
- <xsl:apply-templates mode="contents_item"/>
11627
+ <xsl:param name="element"/>
11628
+ <xsl:apply-templates mode="contents_item">
11629
+ <xsl:with-param name="element" select="$element"/>
11630
+ </xsl:apply-templates>
11491
11631
  </xsl:template>
11492
11632
 
11493
11633
  <!-- =============== -->
@@ -12314,9 +12454,17 @@
12314
12454
 
12315
12455
  <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP">
12316
12456
  <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>
12457
+ <xsl:variable name="example_body">
12458
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12459
+ <xsl:with-param name="fo_element" select="$fo_element"/>
12460
+ </xsl:apply-templates>
12461
+ </xsl:variable>
12462
+ <xsl:choose>
12463
+ <xsl:when test="xalan:nodeset($example_body)/*">
12464
+ <xsl:copy-of select="$example_body"/>
12465
+ </xsl:when>
12466
+ <xsl:otherwise><fo:block/><!-- prevent empty block-container --></xsl:otherwise>
12467
+ </xsl:choose>
12320
12468
  </fo:block-container>
12321
12469
  </fo:block-container>
12322
12470
  </xsl:when> <!-- end block -->
@@ -12849,7 +12997,22 @@
12849
12997
 
12850
12998
  <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
12851
12999
  <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"/>
13000
+ <xsl:choose>
13001
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13002
+ <xsl:otherwise>
13003
+ <xsl:call-template name="sections_node"/>
13004
+ </xsl:otherwise>
13005
+ </xsl:choose>
13006
+ </xsl:template>
13007
+
13008
+ <!-- page_sequence/sections/clause -->
13009
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'sections']/*[not(@top-level)]" priority="2">
13010
+ <xsl:choose>
13011
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13012
+ <xsl:otherwise>
13013
+ <xsl:call-template name="sections_node"/>
13014
+ </xsl:otherwise>
13015
+ </xsl:choose>
12853
13016
  </xsl:template>
12854
13017
 
12855
13018
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="sections_element_style">
@@ -12866,8 +13029,24 @@
12866
13029
  </fo:block>
12867
13030
  </xsl:template>
12868
13031
 
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"/>
13032
+ <!-- preface/ page_sequence/clause -->
13033
+ <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']/* -->
13034
+ <xsl:choose>
13035
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13036
+ <xsl:otherwise>
13037
+ <xsl:call-template name="preface_node"/>
13038
+ </xsl:otherwise>
13039
+ </xsl:choose>
13040
+ </xsl:template>
13041
+
13042
+ <!-- page_sequence/preface/clause -->
13043
+ <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']/* -->
13044
+ <xsl:choose>
13045
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13046
+ <xsl:otherwise>
13047
+ <xsl:call-template name="preface_node"/>
13048
+ </xsl:otherwise>
13049
+ </xsl:choose>
12871
13050
  </xsl:template>
12872
13051
 
12873
13052
  <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 +14412,14 @@
14233
14412
  </redirect:write> -->
14234
14413
  </xsl:if>
14235
14414
 
14415
+ <!-- <xsl:if test="$debug = 'true'"><xsl:message>START copying updated_xml_step3</xsl:message></xsl:if>
14416
+ <xsl:variable name="startTime4" select="java:getTime(java:java.util.Date.new())"/> -->
14236
14417
  <xsl:copy-of select="$updated_xml_step3"/>
14418
+ <!-- <xsl:variable name="endTime4" select="java:getTime(java:java.util.Date.new())"/>
14419
+ <xsl:if test="$debug = 'true'">
14420
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime4 - $startTime4"/> msec.</xsl:message>
14421
+ <xsl:message>END copying updated_xml_step3</xsl:message>
14422
+ </xsl:if> -->
14237
14423
 
14238
14424
  </xsl:template>
14239
14425
 
@@ -14415,14 +14601,17 @@
14415
14601
  <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
14416
14602
  <!-- =========================================================================== -->
14417
14603
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="update_xml_step_move_pagebreak">
14604
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14418
14605
  <xsl:copy>
14419
- <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/>
14606
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak">
14607
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14608
+ </xsl:apply-templates>
14420
14609
  </xsl:copy>
14421
14610
  </xsl:template>
14422
14611
 
14423
14612
  <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
14424
14613
  <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
-
14614
+ <xsl:param name="page_sequence_at_top"/>
14426
14615
  <!-- <xsl:choose>
14427
14616
  <xsl:when test="ancestor::*[local-name() = 'sections']">
14428
14617
 
@@ -14446,7 +14635,9 @@
14446
14635
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
14447
14636
 
14448
14637
  <xsl:variable name="tree_">
14449
- <xsl:call-template name="makeAncestorsElementsTree"/>
14638
+ <xsl:call-template name="makeAncestorsElementsTree">
14639
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14640
+ </xsl:call-template>
14450
14641
  </xsl:variable>
14451
14642
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14452
14643
 
@@ -14468,12 +14659,26 @@
14468
14659
  </xsl:template>
14469
14660
 
14470
14661
  <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>
14662
+ <xsl:param name="page_sequence_at_top"/>
14663
+
14664
+ <xsl:choose>
14665
+ <xsl:when test="$page_sequence_at_top = 'true'">
14666
+ <xsl:for-each select="ancestor::*[ancestor::*[contains(local-name(), '-standard')]]">
14667
+ <element pos="{position()}">
14668
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14669
+ <xsl:value-of select="name()"/>
14670
+ </element>
14671
+ </xsl:for-each>
14672
+ </xsl:when>
14673
+ <xsl:otherwise>
14674
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14675
+ <element pos="{position()}">
14676
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14677
+ <xsl:value-of select="name()"/>
14678
+ </element>
14679
+ </xsl:for-each>
14680
+ </xsl:otherwise>
14681
+ </xsl:choose>
14477
14682
  </xsl:template>
14478
14683
 
14479
14684
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertClosingElements">
@@ -14511,11 +14716,14 @@
14511
14716
 
14512
14717
  <!-- move full page width figures, tables at top level -->
14513
14718
  <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">
14719
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14514
14720
  <xsl:choose>
14515
14721
  <xsl:when test="$layout_columns != 1">
14516
14722
 
14517
14723
  <xsl:variable name="tree_">
14518
- <xsl:call-template name="makeAncestorsElementsTree"/>
14724
+ <xsl:call-template name="makeAncestorsElementsTree">
14725
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14726
+ </xsl:call-template>
14519
14727
  </xsl:variable>
14520
14728
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14521
14729
 
@@ -14663,81 +14871,140 @@
14663
14871
 
14664
14872
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_separators">_.\</xsl:variable>
14665
14873
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/>
14874
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_express_reference">(^([A-Za-z0-9_.\\]+)$)</xsl:variable>
14666
14875
 
14667
14876
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
14877
+ <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>
14878
+ <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
14879
 
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">
14880
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14881
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14882
+ <!-- add &lt; and &gt; to \S -->
14883
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14884
+ <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
14885
 
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">
14886
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14887
+ <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>
14888
+
14889
+ <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">
14890
+
14891
+ <xsl:variable name="parent" select="local-name(..)"/>
14892
+
14893
+ <xsl:if test="1 = 2"> <!-- alternative variant -->
14894
+
14895
+ <xsl:variable name="regexs">
14896
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14897
+ <xsl:if test="not(ancestor::*[local-name() = 'table'])"><regex><xsl:value-of select="$regex_standard_reference"/></regex></xsl:if>
14898
+ <!-- if EXPRESS reference -->
14899
+
14900
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14901
+ <regex><xsl:value-of select="$regex_solidus_units"/></regex>
14902
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14903
+ <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14904
+ <regex><xsl:value-of select="$regex_dots_units"/></regex>
14905
+ </xsl:if>
14906
+ </xsl:variable>
14907
+
14908
+ <xsl:variable name="regex_replacement"><xsl:text>(</xsl:text>
14909
+ <xsl:for-each select="xalan:nodeset($regexs)/regex">
14910
+ <xsl:value-of select="."/>
14911
+ <xsl:if test="position() != last()">|</xsl:if>
14912
+ </xsl:for-each>
14913
+ <xsl:text>)</xsl:text>
14914
+ </xsl:variable>
14915
+
14916
+ <!-- regex_replacement='<xsl:value-of select="$regex_replacement"/>' -->
14917
+
14918
+ <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))"/>
14919
+
14920
+ <!-- text_replaced='<xsl:value-of select="$text_replaced"/>' -->
14921
+
14922
+ <xsl:call-template name="replace_text_tags">
14682
14923
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14683
14924
  <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>
14925
+ <xsl:with-param name="text" select="$text_replaced"/>
14926
+ </xsl:call-template>
14927
+ </xsl:if>
14686
14928
 
14687
- <xsl:variable name="parent" select="local-name(..)"/>
14929
+ <xsl:if test="1 = 1">
14930
+
14931
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14932
+ <xsl:variable name="text">
14933
+ <xsl:element name="text" namespace="{$namespace_full}">
14934
+ <xsl:choose>
14935
+ <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 -->
14936
+ <xsl:otherwise>
14937
+ <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))"/>
14938
+ <!-- <xsl:value-of select="$text__"/> -->
14939
+
14940
+ <xsl:call-template name="replace_text_tags">
14941
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14942
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14943
+ <xsl:with-param name="text" select="$text_"/>
14944
+ </xsl:call-template>
14945
+
14946
+ </xsl:otherwise>
14947
+ </xsl:choose>
14948
+ </xsl:element>
14949
+ </xsl:variable>
14688
14950
 
14689
14951
  <xsl:variable name="text2">
14690
- <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
14952
+ <xsl:element name="text" namespace="{$namespace_full}">
14953
+ <xsl:for-each select="xalan:nodeset($text)/*[local-name() = 'text']/node()">
14691
14954
  <xsl:copy-of select="."/>
14692
- </xsl:for-each></text>
14955
+ </xsl:for-each>
14956
+ </xsl:element>
14693
14957
  </xsl:variable>
14694
14958
 
14695
14959
  <!-- 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
14960
  <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>
14961
+ <xsl:element name="text" namespace="{$namespace_full}">
14962
+ <xsl:for-each select="xalan:nodeset($text2)/*[local-name() = 'text']/node()">
14963
+ <xsl:choose>
14964
+ <xsl:when test="self::text()">
14965
+ <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))"/>
14966
+ <!-- <xsl:variable name="text_units">
14967
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14968
+ <xsl:call-template name="replace_text_tags">
14969
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14970
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14971
+ <xsl:with-param name="text" select="$text_units"/>
14972
+ </xsl:call-template>
14973
+ <!-- </xsl:element>
14974
+ </xsl:variable>
14975
+ <xsl:copy-of select="xalan:nodeset($text_units)/*[local-name() = 'text']/node()"/> -->
14976
+ </xsl:when>
14977
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14978
+ </xsl:choose>
14979
+ </xsl:for-each>
14980
+ </xsl:element>
14716
14981
  </xsl:variable>
14717
14982
 
14718
14983
  <xsl:choose>
14719
14984
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14720
14985
  <!-- 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()">
14986
+ <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()">
14724
14987
  <xsl:choose>
14725
14988
  <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()"/>
14989
+ <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))"/>
14990
+ <!-- <xsl:variable name="text_dots">
14991
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14992
+ <xsl:call-template name="replace_text_tags">
14993
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14994
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14995
+ <xsl:with-param name="text" select="$text_dots"/>
14996
+ </xsl:call-template>
14997
+ <!-- </xsl:element>
14998
+ </xsl:variable>
14999
+ <xsl:copy-of select="xalan:nodeset($text_dots)/*[local-name() = 'text']/node()"/> -->
14733
15000
  </xsl:when>
14734
15001
  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14735
15002
  </xsl:choose>
14736
15003
  </xsl:for-each>
14737
15004
  </xsl:when>
14738
- <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
15005
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"/></xsl:otherwise>
14739
15006
  </xsl:choose>
14740
-
15007
+ </xsl:if>
14741
15008
  </xsl:template>
14742
15009
 
14743
15010
  <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 +15525,15 @@
15258
15525
  </xsl:otherwise>
15259
15526
  </xsl:choose>
15260
15527
  </xsl:for-each>
15528
+ <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15529
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15530
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15531
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15532
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15533
+ <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15534
+ <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15535
+ </xsl:for-each>
15536
+ </xsl:if>
15261
15537
  </xsl:template> <!-- addPDFUAmeta -->
15262
15538
 
15263
15539
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getId">