metanorma-bipm 2.4.9 → 2.4.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -3875,6 +3875,8 @@
3875
3875
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
3876
3876
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
3877
3877
 
3878
+ <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'])"/>
3879
+
3878
3880
  <!-- external parameters -->
3879
3881
 
3880
3882
  <xsl:param xmlns:redirect="http://xml.apache.org/xalan/redirect" name="svg_images"/> <!-- svg images array -->
@@ -5595,56 +5597,9 @@
5595
5597
  </xsl:for-each>
5596
5598
  </xsl:template>
5597
5599
 
5598
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
5599
-
5600
- <xsl:variable name="updated_xml_step_move_pagebreak">
5601
-
5602
- <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5603
-
5604
- <xsl:call-template name="copyCommonElements"/>
5605
-
5606
- <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5607
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
5608
- <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5609
- <xsl:sort select="@displayorder" data-type="number"/>
5610
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5611
- </xsl:for-each>
5612
- </xsl:element>
5613
- </xsl:element>
5614
- </xsl:element>
5615
- </xsl:variable>
5616
-
5617
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5618
- <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
5619
- <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5620
- <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5621
- <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5622
- </redirect:write>
5623
- <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5624
-
5625
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5626
-
5627
- <!-- TODO: instead of
5628
- <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
5629
- in each template, add removing empty page_sequence here
5630
- -->
5631
-
5632
- <xsl:if test="$debug = 'true'">
5633
- <redirect:write file="page_sequence_preface.xml">
5634
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5635
- </redirect:write>
5636
- </xsl:if>
5637
-
5638
- <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5639
- <xsl:call-template name="deleteFile">
5640
- <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5641
- </xsl:call-template>
5642
- <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5643
- </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
5644
-
5645
5600
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
5646
5601
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
5647
- <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography']"/>
5602
+ <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography' and local-name() != 'indexsect']"/>
5648
5603
  </xsl:template>
5649
5604
 
5650
5605
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault">
@@ -5665,8 +5620,16 @@
5665
5620
  </xsl:for-each>
5666
5621
  </xsl:template><!-- END: processMainSectionsDefault -->
5667
5622
 
5668
- <!-- Example:
5623
+ <!-- Example:
5669
5624
  <iso-standard>
5625
+ <preface>
5626
+ <page_sequence>
5627
+ <clause...
5628
+ </page_sequence>
5629
+ <page_sequence>
5630
+ <clause...
5631
+ </page_sequence>
5632
+ </preface>
5670
5633
  <sections>
5671
5634
  <page_sequence>
5672
5635
  <clause...
@@ -5683,60 +5646,200 @@
5683
5646
  </page_sequence>
5684
5647
  </iso-standard>
5685
5648
  -->
5686
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
5649
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceAndMainSectionsDefault_items">
5687
5650
 
5688
5651
  <xsl:variable name="updated_xml_step_move_pagebreak">
5689
-
5690
5652
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5691
-
5692
5653
  <xsl:call-template name="copyCommonElements"/>
5654
+ <xsl:call-template name="insertPrefaceSectionsPageSequences"/>
5655
+ <xsl:call-template name="insertMainSectionsPageSequences"/>
5656
+ </xsl:element>
5657
+ </xsl:variable>
5693
5658
 
5694
- <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5695
- <xsl:element name="page_sequence" namespace="{$namespace_full}">
5696
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5697
- <xsl:sort select="@displayorder" data-type="number"/>
5698
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5659
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5699
5660
 
5700
- </xsl:for-each>
5701
- </xsl:element>
5661
+ <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5662
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5663
+ </redirect:write>
5664
+
5665
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5666
+
5667
+ <xsl:if test="$debug = 'true'">
5668
+ <redirect:write file="page_sequence_preface_and_main.xml">
5669
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5670
+ </redirect:write>
5671
+ </xsl:if>
5672
+
5673
+ <xsl:call-template name="deleteFile">
5674
+ <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5675
+ </xsl:call-template>
5676
+ </xsl:template> <!-- END: processPrefaceAndMainSectionsDefault_items -->
5677
+
5678
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertPrefaceSectionsPageSequences">
5679
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5680
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5681
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5682
+ <xsl:sort select="@displayorder" data-type="number"/>
5683
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5684
+ </xsl:for-each>
5685
+ </xsl:element>
5686
+ </xsl:element>
5687
+ </xsl:template> <!-- END: insertPrefaceSectionsPageSequences -->
5688
+
5689
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSectionsPageSequences">
5690
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5691
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5692
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5693
+ <xsl:sort select="@displayorder" data-type="number"/>
5694
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5695
+
5696
+ </xsl:for-each>
5697
+ </xsl:element>
5698
+ </xsl:element>
5699
+
5700
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5701
+ <xsl:for-each select="/*/*[local-name()='annex']">
5702
+ <xsl:sort select="@displayorder" data-type="number"/>
5703
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5704
+ </xsl:for-each>
5705
+ </xsl:element>
5706
+
5707
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5708
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5709
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5710
+ <xsl:sort select="@displayorder" data-type="number"/>
5711
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5712
+ </xsl:for-each>
5713
+ </xsl:element>
5714
+ </xsl:element>
5715
+ </xsl:template> <!-- END: insertMainSectionsPageSequences -->
5716
+
5717
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSectionsInSeparatePageSequences">
5718
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5719
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5720
+ <xsl:sort select="@displayorder" data-type="number"/>
5721
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5722
+ <xsl:attribute name="main_page_sequence"/>
5723
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5702
5724
  </xsl:element>
5725
+ </xsl:for-each>
5726
+ </xsl:element>
5727
+
5728
+ <xsl:call-template name="insertAnnexInSeparatePageSequences"/>
5729
+
5730
+ <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5731
+
5732
+ <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5733
+ </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
5703
5734
 
5735
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertAnnexInSeparatePageSequences">
5736
+ <xsl:for-each select="/*/*[local-name()='annex']">
5737
+ <xsl:sort select="@displayorder" data-type="number"/>
5738
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5739
+ <xsl:attribute name="main_page_sequence"/>
5740
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5741
+ </xsl:element>
5742
+ </xsl:for-each>
5743
+ </xsl:template>
5744
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBibliographyInSeparatePageSequences">
5745
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5746
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5747
+ <xsl:sort select="@displayorder" data-type="number"/>
5704
5748
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
5705
- <xsl:for-each select="/*/*[local-name()='annex']">
5706
- <xsl:sort select="@displayorder" data-type="number"/>
5707
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5708
- </xsl:for-each>
5749
+ <xsl:attribute name="main_page_sequence"/>
5750
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5709
5751
  </xsl:element>
5752
+ </xsl:for-each>
5753
+ </xsl:element>
5754
+ </xsl:template>
5755
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertIndexInSeparatePageSequences">
5756
+ <xsl:for-each select="/*/*[local-name()='indexsect']">
5757
+ <xsl:sort select="@displayorder" data-type="number"/>
5758
+ <xsl:element name="page_sequence" namespace="{$namespace_full}">
5759
+ <xsl:attribute name="main_page_sequence"/>
5760
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5761
+ </xsl:element>
5762
+ </xsl:for-each>
5763
+ </xsl:template>
5710
5764
 
5765
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processAllSectionsDefault_items">
5766
+ <xsl:variable name="updated_xml_step_move_pagebreak">
5767
+ <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5768
+ <xsl:call-template name="copyCommonElements"/>
5711
5769
  <xsl:element name="page_sequence" namespace="{$namespace_full}">
5712
- <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5713
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5714
- <xsl:sort select="@displayorder" data-type="number"/>
5715
- <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/>
5716
- </xsl:for-each>
5717
- </xsl:element>
5770
+ <xsl:call-template name="insertPrefaceSections"/>
5771
+ <xsl:call-template name="insertMainSections"/>
5718
5772
  </xsl:element>
5719
5773
  </xsl:element>
5720
5774
  </xsl:variable>
5721
5775
 
5722
- <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5723
-
5776
+ <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_and_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5777
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
5778
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5724
5779
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5725
5780
  <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5726
5781
  </redirect:write>
5782
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5727
5783
 
5728
5784
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5729
5785
 
5786
+ <!-- TODO: instead of
5787
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
5788
+ in each template, add removing empty page_sequence here
5789
+ -->
5790
+
5730
5791
  <xsl:if test="$debug = 'true'">
5731
- <redirect:write file="page_sequence_main.xml">
5732
- <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5792
+ <redirect:write file="page_sequence_preface_and_main.xml">
5793
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5733
5794
  </redirect:write>
5734
5795
  </xsl:if>
5735
5796
 
5797
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5736
5798
  <xsl:call-template name="deleteFile">
5737
5799
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5738
5800
  </xsl:call-template>
5739
- </xsl:template> <!-- END: processMainSectionsDefault_items -->
5801
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5802
+ </xsl:template> <!-- END: processAllSectionsDefault_items -->
5803
+
5804
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertPrefaceSections">
5805
+ <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element -->
5806
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5807
+ <xsl:sort select="@displayorder" data-type="number"/>
5808
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5809
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5810
+ </xsl:apply-templates>
5811
+ </xsl:for-each>
5812
+ </xsl:element>
5813
+ </xsl:template>
5814
+
5815
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertMainSections">
5816
+ <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element -->
5817
+
5818
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5819
+ <xsl:sort select="@displayorder" data-type="number"/>
5820
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5821
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5822
+ </xsl:apply-templates>
5823
+
5824
+ </xsl:for-each>
5825
+ </xsl:element>
5826
+
5827
+ <xsl:for-each select="/*/*[local-name()='annex']">
5828
+ <xsl:sort select="@displayorder" data-type="number"/>
5829
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5830
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5831
+ </xsl:apply-templates>
5832
+ </xsl:for-each>
5833
+
5834
+ <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element -->
5835
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5836
+ <xsl:sort select="@displayorder" data-type="number"/>
5837
+ <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak">
5838
+ <xsl:with-param name="page_sequence_at_top">true</xsl:with-param>
5839
+ </xsl:apply-templates>
5840
+ </xsl:for-each>
5841
+ </xsl:element>
5842
+ </xsl:template>
5740
5843
 
5741
5844
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="deleteFile">
5742
5845
  <xsl:param name="filepath"/>
@@ -5781,9 +5884,16 @@
5781
5884
  <xsl:value-of select="substring-before($text, $tag_open)"/>
5782
5885
  <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
5783
5886
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5784
- <fo:inline keep-together.within-line="always">
5785
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5786
- </fo:inline>
5887
+ <xsl:choose>
5888
+ <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" -->
5889
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5890
+ </xsl:when>
5891
+ <xsl:otherwise>
5892
+ <fo:inline keep-together.within-line="always" role="SKIP">
5893
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5894
+ </fo:inline>
5895
+ </xsl:otherwise>
5896
+ </xsl:choose>
5787
5897
  <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
5788
5898
  <xsl:call-template name="replace_fo_inline_tags">
5789
5899
  <xsl:with-param name="tag_open" select="$tag_open"/>
@@ -6983,6 +7093,8 @@
6983
7093
  <xsl:with-param name="default">center</xsl:with-param>
6984
7094
  </xsl:call-template>
6985
7095
 
7096
+ <xsl:copy-of select="@keep-together.within-line"/>
7097
+
6986
7098
  <xsl:call-template name="refine_table-header-cell-style"/>
6987
7099
 
6988
7100
  <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
@@ -7041,6 +7153,8 @@
7041
7153
  <xsl:with-param name="default">left</xsl:with-param>
7042
7154
  </xsl:call-template>
7043
7155
 
7156
+ <xsl:copy-of select="@keep-together.within-line"/>
7157
+
7044
7158
  <xsl:call-template name="refine_table-cell-style"/>
7045
7159
 
7046
7160
  <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table -->
@@ -7080,6 +7194,7 @@
7080
7194
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
7081
7195
 
7082
7196
  <fo:block xsl:use-attribute-sets="table-note-style">
7197
+ <xsl:copy-of select="@id"/>
7083
7198
 
7084
7199
  <xsl:call-template name="refine_table-note-style"/>
7085
7200
 
@@ -7177,7 +7292,7 @@
7177
7292
  <xsl:copy-of select="."/>
7178
7293
  </xsl:for-each>
7179
7294
 
7180
- <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
7295
+ <xsl:if test="following-sibling::node()[normalize-space() != ''][1][local-name() = 'fn']">
7181
7296
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
7182
7297
  </xsl:if>
7183
7298
 
@@ -7244,7 +7359,7 @@
7244
7359
  <xsl:copy-of select="node()"/>
7245
7360
  </fn>
7246
7361
  </xsl:for-each>
7247
- <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']/*">
7362
+ <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']/*">
7248
7363
  <xsl:sort select="@displayorder" data-type="number"/>
7249
7364
  <!-- commented:
7250
7365
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
@@ -7322,6 +7437,11 @@
7322
7437
 
7323
7438
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="create_fn">
7324
7439
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
7440
+ <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
7441
+ <xsl:attribute name="id">
7442
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
7443
+ </xsl:attribute>
7444
+ </xsl:if>
7325
7445
 
7326
7446
  <xsl:apply-templates/>
7327
7447
  </fn>
@@ -7465,6 +7585,11 @@
7465
7585
  <xsl:call-template name="refine_fn-reference-style"/>
7466
7586
 
7467
7587
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
7588
+ <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
7589
+ <xsl:attribute name="internal-destination">
7590
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
7591
+ </xsl:attribute>
7592
+ </xsl:if>
7468
7593
 
7469
7594
  <fo:inline font-style="normal"> (</fo:inline>
7470
7595
 
@@ -8511,7 +8636,7 @@
8511
8636
 
8512
8637
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="recursiveSmallCaps">
8513
8638
  <xsl:param name="text"/>
8514
- <xsl:param name="ratio"/>
8639
+ <xsl:param name="ratio">0.75</xsl:param>
8515
8640
  <xsl:variable name="char" select="substring($text,1,1)"/>
8516
8641
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
8517
8642
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
@@ -10664,6 +10789,8 @@
10664
10789
  </xsl:choose>
10665
10790
  </xsl:variable>
10666
10791
 
10792
+ <xsl:variable name="isPrecedingTitle" select="normalize-space(ancestor::*[local-name() = 'figure']/preceding-sibling::*[1][local-name() = 'title'] and 1 = 1)"/>
10793
+
10667
10794
  <xsl:choose>
10668
10795
  <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
10669
10796
  <fo:block>
@@ -10810,7 +10937,14 @@
10810
10937
  <xsl:variable name="scale_y">
10811
10938
  <xsl:choose>
10812
10939
  <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
10813
- <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
10940
+ <xsl:variable name="height_effective_px_">
10941
+ <xsl:choose>
10942
+ <!-- title is 'keep-with-next' with following figure -->
10943
+ <xsl:when test="$isPrecedingTitle = 'true'"><xsl:value-of select="$height_effective_px - 80"/></xsl:when>
10944
+ <xsl:otherwise><xsl:value-of select="$height_effective_px"/></xsl:otherwise>
10945
+ </xsl:choose>
10946
+ </xsl:variable>
10947
+ <xsl:value-of select="$height_effective_px_ div ($svg_height * $scale_x)"/>
10814
10948
  </xsl:when>
10815
10949
  <xsl:otherwise>1</xsl:otherwise>
10816
10950
  </xsl:choose>
@@ -11229,7 +11363,7 @@
11229
11363
  </xsl:if>
11230
11364
 
11231
11365
  <xsl:for-each select="$contents_nodes/doc">
11232
- <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
11366
+ <fo:bookmark internal-destination="{contents/item[@display = 'true'][1]/@id}" starting-state="hide">
11233
11367
  <xsl:if test="@bundle = 'true'">
11234
11368
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
11235
11369
  </xsl:if>
@@ -11562,8 +11696,11 @@
11562
11696
  </xsl:template>
11563
11697
 
11564
11698
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'strong']" mode="contents_item">
11699
+ <xsl:param name="element"/>
11565
11700
  <xsl:copy>
11566
- <xsl:apply-templates mode="contents_item"/>
11701
+ <xsl:apply-templates mode="contents_item">
11702
+ <xsl:with-param name="element" select="$element"/>
11703
+ </xsl:apply-templates>
11567
11704
  </xsl:copy>
11568
11705
  </xsl:template>
11569
11706
 
@@ -11630,7 +11767,10 @@
11630
11767
 
11631
11768
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
11632
11769
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'span']" mode="contents_item">
11633
- <xsl:apply-templates mode="contents_item"/>
11770
+ <xsl:param name="element"/>
11771
+ <xsl:apply-templates mode="contents_item">
11772
+ <xsl:with-param name="element" select="$element"/>
11773
+ </xsl:apply-templates>
11634
11774
  </xsl:template>
11635
11775
 
11636
11776
  <!-- =============== -->
@@ -12453,9 +12593,17 @@
12453
12593
 
12454
12594
  <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP">
12455
12595
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
12456
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12457
- <xsl:with-param name="fo_element" select="$fo_element"/>
12458
- </xsl:apply-templates>
12596
+ <xsl:variable name="example_body">
12597
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12598
+ <xsl:with-param name="fo_element" select="$fo_element"/>
12599
+ </xsl:apply-templates>
12600
+ </xsl:variable>
12601
+ <xsl:choose>
12602
+ <xsl:when test="xalan:nodeset($example_body)/*">
12603
+ <xsl:copy-of select="$example_body"/>
12604
+ </xsl:when>
12605
+ <xsl:otherwise><fo:block/><!-- prevent empty block-container --></xsl:otherwise>
12606
+ </xsl:choose>
12459
12607
  </fo:block-container>
12460
12608
  </fo:block-container>
12461
12609
  </xsl:when> <!-- end block -->
@@ -12999,7 +13147,22 @@
12999
13147
 
13000
13148
  <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
13001
13149
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'sections']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2">
13002
- <xsl:call-template name="sections_node"/>
13150
+ <xsl:choose>
13151
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13152
+ <xsl:otherwise>
13153
+ <xsl:call-template name="sections_node"/>
13154
+ </xsl:otherwise>
13155
+ </xsl:choose>
13156
+ </xsl:template>
13157
+
13158
+ <!-- page_sequence/sections/clause -->
13159
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'sections']/*[not(@top-level)]" priority="2">
13160
+ <xsl:choose>
13161
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13162
+ <xsl:otherwise>
13163
+ <xsl:call-template name="sections_node"/>
13164
+ </xsl:otherwise>
13165
+ </xsl:choose>
13003
13166
  </xsl:template>
13004
13167
 
13005
13168
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="sections_element_style">
@@ -13016,8 +13179,24 @@
13016
13179
  </fo:block>
13017
13180
  </xsl:template>
13018
13181
 
13019
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
13020
- <xsl:call-template name="preface_node"/>
13182
+ <!-- preface/ page_sequence/clause -->
13183
+ <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']/* -->
13184
+ <xsl:choose>
13185
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13186
+ <xsl:otherwise>
13187
+ <xsl:call-template name="preface_node"/>
13188
+ </xsl:otherwise>
13189
+ </xsl:choose>
13190
+ </xsl:template>
13191
+
13192
+ <!-- page_sequence/preface/clause -->
13193
+ <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']/* -->
13194
+ <xsl:choose>
13195
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13196
+ <xsl:otherwise>
13197
+ <xsl:call-template name="preface_node"/>
13198
+ </xsl:otherwise>
13199
+ </xsl:choose>
13021
13200
  </xsl:template>
13022
13201
 
13023
13202
  <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 -->
@@ -14327,7 +14506,14 @@
14327
14506
  </redirect:write> -->
14328
14507
  </xsl:if>
14329
14508
 
14509
+ <!-- <xsl:if test="$debug = 'true'"><xsl:message>START copying updated_xml_step3</xsl:message></xsl:if>
14510
+ <xsl:variable name="startTime4" select="java:getTime(java:java.util.Date.new())"/> -->
14330
14511
  <xsl:copy-of select="$updated_xml_step3"/>
14512
+ <!-- <xsl:variable name="endTime4" select="java:getTime(java:java.util.Date.new())"/>
14513
+ <xsl:if test="$debug = 'true'">
14514
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime4 - $startTime4"/> msec.</xsl:message>
14515
+ <xsl:message>END copying updated_xml_step3</xsl:message>
14516
+ </xsl:if> -->
14331
14517
 
14332
14518
  </xsl:template>
14333
14519
 
@@ -14509,14 +14695,17 @@
14509
14695
  <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
14510
14696
  <!-- =========================================================================== -->
14511
14697
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="update_xml_step_move_pagebreak">
14698
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14512
14699
  <xsl:copy>
14513
- <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/>
14700
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak">
14701
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14702
+ </xsl:apply-templates>
14514
14703
  </xsl:copy>
14515
14704
  </xsl:template>
14516
14705
 
14517
14706
  <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
14518
14707
  <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">
14519
-
14708
+ <xsl:param name="page_sequence_at_top"/>
14520
14709
  <!-- <xsl:choose>
14521
14710
  <xsl:when test="ancestor::*[local-name() = 'sections']">
14522
14711
 
@@ -14540,7 +14729,9 @@
14540
14729
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
14541
14730
 
14542
14731
  <xsl:variable name="tree_">
14543
- <xsl:call-template name="makeAncestorsElementsTree"/>
14732
+ <xsl:call-template name="makeAncestorsElementsTree">
14733
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14734
+ </xsl:call-template>
14544
14735
  </xsl:variable>
14545
14736
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14546
14737
 
@@ -14562,12 +14753,26 @@
14562
14753
  </xsl:template>
14563
14754
 
14564
14755
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
14565
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14566
- <element pos="{position()}">
14567
- <xsl:copy-of select="@*[local-name() != 'id']"/>
14568
- <xsl:value-of select="name()"/>
14569
- </element>
14570
- </xsl:for-each>
14756
+ <xsl:param name="page_sequence_at_top"/>
14757
+
14758
+ <xsl:choose>
14759
+ <xsl:when test="$page_sequence_at_top = 'true'">
14760
+ <xsl:for-each select="ancestor::*[ancestor::*[contains(local-name(), '-standard')]]">
14761
+ <element pos="{position()}">
14762
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14763
+ <xsl:value-of select="name()"/>
14764
+ </element>
14765
+ </xsl:for-each>
14766
+ </xsl:when>
14767
+ <xsl:otherwise>
14768
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14769
+ <element pos="{position()}">
14770
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14771
+ <xsl:value-of select="name()"/>
14772
+ </element>
14773
+ </xsl:for-each>
14774
+ </xsl:otherwise>
14775
+ </xsl:choose>
14571
14776
  </xsl:template>
14572
14777
 
14573
14778
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertClosingElements">
@@ -14605,11 +14810,14 @@
14605
14810
 
14606
14811
  <!-- move full page width figures, tables at top level -->
14607
14812
  <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">
14813
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14608
14814
  <xsl:choose>
14609
14815
  <xsl:when test="$layout_columns != 1">
14610
14816
 
14611
14817
  <xsl:variable name="tree_">
14612
- <xsl:call-template name="makeAncestorsElementsTree"/>
14818
+ <xsl:call-template name="makeAncestorsElementsTree">
14819
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14820
+ </xsl:call-template>
14613
14821
  </xsl:variable>
14614
14822
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14615
14823
 
@@ -14653,81 +14861,140 @@
14653
14861
 
14654
14862
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_separators">_.\</xsl:variable>
14655
14863
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/>
14864
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_express_reference">(^([A-Za-z0-9_.\\]+)$)</xsl:variable>
14656
14865
 
14657
14866
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
14867
+ <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>
14868
+ <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>
14658
14869
 
14659
- <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">
14870
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14871
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14872
+ <!-- add &lt; and &gt; to \S -->
14873
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14874
+ <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>
14660
14875
 
14661
- <!-- enclose standard's number into tag 'keep-together_within-line' -->
14662
- <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14663
- <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
14664
- <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))"/>
14665
- <xsl:variable name="text_">
14666
- <xsl:choose>
14667
- <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 -->
14668
- <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
14669
- </xsl:choose>
14670
- </xsl:variable>
14671
- <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
14876
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14877
+ <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>
14878
+
14879
+ <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">
14880
+
14881
+ <xsl:variable name="parent" select="local-name(..)"/>
14882
+
14883
+ <xsl:if test="1 = 2"> <!-- alternative variant -->
14884
+
14885
+ <xsl:variable name="regexs">
14886
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14887
+ <xsl:if test="not(ancestor::*[local-name() = 'table'])"><regex><xsl:value-of select="$regex_standard_reference"/></regex></xsl:if>
14888
+ <!-- if EXPRESS reference -->
14889
+
14890
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14891
+ <regex><xsl:value-of select="$regex_solidus_units"/></regex>
14892
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14893
+ <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14894
+ <regex><xsl:value-of select="$regex_dots_units"/></regex>
14895
+ </xsl:if>
14896
+ </xsl:variable>
14897
+
14898
+ <xsl:variable name="regex_replacement"><xsl:text>(</xsl:text>
14899
+ <xsl:for-each select="xalan:nodeset($regexs)/regex">
14900
+ <xsl:value-of select="."/>
14901
+ <xsl:if test="position() != last()">|</xsl:if>
14902
+ </xsl:for-each>
14903
+ <xsl:text>)</xsl:text>
14904
+ </xsl:variable>
14905
+
14906
+ <!-- regex_replacement='<xsl:value-of select="$regex_replacement"/>' -->
14907
+
14908
+ <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))"/>
14909
+
14910
+ <!-- text_replaced='<xsl:value-of select="$text_replaced"/>' -->
14911
+
14912
+ <xsl:call-template name="replace_text_tags">
14672
14913
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14673
14914
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14674
- <xsl:with-param name="text" select="$text_"/>
14675
- </xsl:call-template></text></xsl:variable>
14915
+ <xsl:with-param name="text" select="$text_replaced"/>
14916
+ </xsl:call-template>
14917
+ </xsl:if>
14676
14918
 
14677
- <xsl:variable name="parent" select="local-name(..)"/>
14919
+ <xsl:if test="1 = 1">
14920
+
14921
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14922
+ <xsl:variable name="text">
14923
+ <xsl:element name="text" namespace="{$namespace_full}">
14924
+ <xsl:choose>
14925
+ <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 -->
14926
+ <xsl:otherwise>
14927
+ <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))"/>
14928
+ <!-- <xsl:value-of select="$text__"/> -->
14929
+
14930
+ <xsl:call-template name="replace_text_tags">
14931
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14932
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14933
+ <xsl:with-param name="text" select="$text_"/>
14934
+ </xsl:call-template>
14935
+
14936
+ </xsl:otherwise>
14937
+ </xsl:choose>
14938
+ </xsl:element>
14939
+ </xsl:variable>
14678
14940
 
14679
14941
  <xsl:variable name="text2">
14680
- <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
14942
+ <xsl:element name="text" namespace="{$namespace_full}">
14943
+ <xsl:for-each select="xalan:nodeset($text)/*[local-name() = 'text']/node()">
14681
14944
  <xsl:copy-of select="."/>
14682
- </xsl:for-each></text>
14945
+ </xsl:for-each>
14946
+ </xsl:element>
14683
14947
  </xsl:variable>
14684
14948
 
14685
14949
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14686
- <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14687
- <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14688
- <!-- add &lt; and &gt; to \S -->
14689
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14690
- <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>
14691
14950
  <xsl:variable name="text3">
14692
- <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
14693
- <xsl:choose>
14694
- <xsl:when test="self::text()">
14695
- <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))"/>
14696
- <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
14697
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14698
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14699
- <xsl:with-param name="text" select="$text_units_"/>
14700
- </xsl:call-template></text></xsl:variable>
14701
- <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
14702
- </xsl:when>
14703
- <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14704
- </xsl:choose>
14705
- </xsl:for-each></text>
14951
+ <xsl:element name="text" namespace="{$namespace_full}">
14952
+ <xsl:for-each select="xalan:nodeset($text2)/*[local-name() = 'text']/node()">
14953
+ <xsl:choose>
14954
+ <xsl:when test="self::text()">
14955
+ <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))"/>
14956
+ <!-- <xsl:variable name="text_units">
14957
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14958
+ <xsl:call-template name="replace_text_tags">
14959
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14960
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14961
+ <xsl:with-param name="text" select="$text_units"/>
14962
+ </xsl:call-template>
14963
+ <!-- </xsl:element>
14964
+ </xsl:variable>
14965
+ <xsl:copy-of select="xalan:nodeset($text_units)/*[local-name() = 'text']/node()"/> -->
14966
+ </xsl:when>
14967
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14968
+ </xsl:choose>
14969
+ </xsl:for-each>
14970
+ </xsl:element>
14706
14971
  </xsl:variable>
14707
14972
 
14708
14973
  <xsl:choose>
14709
14974
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14710
14975
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14711
- <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14712
- <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>
14713
- <xsl:for-each select="xalan:nodeset($text3)/text/node()">
14976
+ <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()">
14714
14977
  <xsl:choose>
14715
14978
  <xsl:when test="self::text()">
14716
- <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))"/>
14717
- <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
14718
- <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14719
- <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14720
- <xsl:with-param name="text" select="$text_dots_"/>
14721
- </xsl:call-template></text></xsl:variable>
14722
- <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
14979
+ <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))"/>
14980
+ <!-- <xsl:variable name="text_dots">
14981
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14982
+ <xsl:call-template name="replace_text_tags">
14983
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14984
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14985
+ <xsl:with-param name="text" select="$text_dots"/>
14986
+ </xsl:call-template>
14987
+ <!-- </xsl:element>
14988
+ </xsl:variable>
14989
+ <xsl:copy-of select="xalan:nodeset($text_dots)/*[local-name() = 'text']/node()"/> -->
14723
14990
  </xsl:when>
14724
14991
  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14725
14992
  </xsl:choose>
14726
14993
  </xsl:for-each>
14727
14994
  </xsl:when>
14728
- <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
14995
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"/></xsl:otherwise>
14729
14996
  </xsl:choose>
14730
-
14997
+ </xsl:if>
14731
14998
  </xsl:template>
14732
14999
 
14733
15000
  <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">
@@ -15250,6 +15517,15 @@
15250
15517
  </xsl:otherwise>
15251
15518
  </xsl:choose>
15252
15519
  </xsl:for-each>
15520
+ <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15521
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15522
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15523
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15524
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15525
+ <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15526
+ <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15527
+ </xsl:for-each>
15528
+ </xsl:if>
15253
15529
  </xsl:template> <!-- addPDFUAmeta -->
15254
15530
 
15255
15531
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getId">