metanorma-bipm 2.4.9 → 2.4.10

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"/>
5703
5729
 
5730
+ <xsl:call-template name="insertBibliographyInSeparatePageSequences"/>
5731
+
5732
+ <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> -->
5733
+ </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences -->
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>
@@ -12453,9 +12587,17 @@
12453
12587
 
12454
12588
  <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP">
12455
12589
  <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>
12590
+ <xsl:variable name="example_body">
12591
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
12592
+ <xsl:with-param name="fo_element" select="$fo_element"/>
12593
+ </xsl:apply-templates>
12594
+ </xsl:variable>
12595
+ <xsl:choose>
12596
+ <xsl:when test="xalan:nodeset($example_body)/*">
12597
+ <xsl:copy-of select="$example_body"/>
12598
+ </xsl:when>
12599
+ <xsl:otherwise><fo:block/><!-- prevent empty block-container --></xsl:otherwise>
12600
+ </xsl:choose>
12459
12601
  </fo:block-container>
12460
12602
  </fo:block-container>
12461
12603
  </xsl:when> <!-- end block -->
@@ -12999,7 +13141,22 @@
12999
13141
 
13000
13142
  <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" -->
13001
13143
  <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"/>
13144
+ <xsl:choose>
13145
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13146
+ <xsl:otherwise>
13147
+ <xsl:call-template name="sections_node"/>
13148
+ </xsl:otherwise>
13149
+ </xsl:choose>
13150
+ </xsl:template>
13151
+
13152
+ <!-- page_sequence/sections/clause -->
13153
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'page_sequence']/*[local-name() = 'sections']/*[not(@top-level)]" priority="2">
13154
+ <xsl:choose>
13155
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13156
+ <xsl:otherwise>
13157
+ <xsl:call-template name="sections_node"/>
13158
+ </xsl:otherwise>
13159
+ </xsl:choose>
13003
13160
  </xsl:template>
13004
13161
 
13005
13162
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="sections_element_style">
@@ -13016,8 +13173,24 @@
13016
13173
  </fo:block>
13017
13174
  </xsl:template>
13018
13175
 
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"/>
13176
+ <!-- preface/ page_sequence/clause -->
13177
+ <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']/* -->
13178
+ <xsl:choose>
13179
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13180
+ <xsl:otherwise>
13181
+ <xsl:call-template name="preface_node"/>
13182
+ </xsl:otherwise>
13183
+ </xsl:choose>
13184
+ </xsl:template>
13185
+
13186
+ <!-- page_sequence/preface/clause -->
13187
+ <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']/* -->
13188
+ <xsl:choose>
13189
+ <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/>
13190
+ <xsl:otherwise>
13191
+ <xsl:call-template name="preface_node"/>
13192
+ </xsl:otherwise>
13193
+ </xsl:choose>
13021
13194
  </xsl:template>
13022
13195
 
13023
13196
  <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 +14500,14 @@
14327
14500
  </redirect:write> -->
14328
14501
  </xsl:if>
14329
14502
 
14503
+ <!-- <xsl:if test="$debug = 'true'"><xsl:message>START copying updated_xml_step3</xsl:message></xsl:if>
14504
+ <xsl:variable name="startTime4" select="java:getTime(java:java.util.Date.new())"/> -->
14330
14505
  <xsl:copy-of select="$updated_xml_step3"/>
14506
+ <!-- <xsl:variable name="endTime4" select="java:getTime(java:java.util.Date.new())"/>
14507
+ <xsl:if test="$debug = 'true'">
14508
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime4 - $startTime4"/> msec.</xsl:message>
14509
+ <xsl:message>END copying updated_xml_step3</xsl:message>
14510
+ </xsl:if> -->
14331
14511
 
14332
14512
  </xsl:template>
14333
14513
 
@@ -14509,14 +14689,17 @@
14509
14689
  <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' -->
14510
14690
  <!-- =========================================================================== -->
14511
14691
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="@*|node()" mode="update_xml_step_move_pagebreak">
14692
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14512
14693
  <xsl:copy>
14513
- <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/>
14694
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak">
14695
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14696
+ </xsl:apply-templates>
14514
14697
  </xsl:copy>
14515
14698
  </xsl:template>
14516
14699
 
14517
14700
  <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags -->
14518
14701
  <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
-
14702
+ <xsl:param name="page_sequence_at_top"/>
14520
14703
  <!-- <xsl:choose>
14521
14704
  <xsl:when test="ancestor::*[local-name() = 'sections']">
14522
14705
 
@@ -14540,7 +14723,9 @@
14540
14723
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
14541
14724
 
14542
14725
  <xsl:variable name="tree_">
14543
- <xsl:call-template name="makeAncestorsElementsTree"/>
14726
+ <xsl:call-template name="makeAncestorsElementsTree">
14727
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14728
+ </xsl:call-template>
14544
14729
  </xsl:variable>
14545
14730
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14546
14731
 
@@ -14562,12 +14747,26 @@
14562
14747
  </xsl:template>
14563
14748
 
14564
14749
  <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>
14750
+ <xsl:param name="page_sequence_at_top"/>
14751
+
14752
+ <xsl:choose>
14753
+ <xsl:when test="$page_sequence_at_top = 'true'">
14754
+ <xsl:for-each select="ancestor::*[ancestor::*[contains(local-name(), '-standard')]]">
14755
+ <element pos="{position()}">
14756
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14757
+ <xsl:value-of select="name()"/>
14758
+ </element>
14759
+ </xsl:for-each>
14760
+ </xsl:when>
14761
+ <xsl:otherwise>
14762
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14763
+ <element pos="{position()}">
14764
+ <xsl:copy-of select="@*[local-name() != 'id']"/>
14765
+ <xsl:value-of select="name()"/>
14766
+ </element>
14767
+ </xsl:for-each>
14768
+ </xsl:otherwise>
14769
+ </xsl:choose>
14571
14770
  </xsl:template>
14572
14771
 
14573
14772
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertClosingElements">
@@ -14605,11 +14804,14 @@
14605
14804
 
14606
14805
  <!-- move full page width figures, tables at top level -->
14607
14806
  <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">
14807
+ <xsl:param name="page_sequence_at_top">false</xsl:param>
14608
14808
  <xsl:choose>
14609
14809
  <xsl:when test="$layout_columns != 1">
14610
14810
 
14611
14811
  <xsl:variable name="tree_">
14612
- <xsl:call-template name="makeAncestorsElementsTree"/>
14812
+ <xsl:call-template name="makeAncestorsElementsTree">
14813
+ <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/>
14814
+ </xsl:call-template>
14613
14815
  </xsl:variable>
14614
14816
  <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
14615
14817
 
@@ -14653,81 +14855,140 @@
14653
14855
 
14654
14856
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_separators">_.\</xsl:variable>
14655
14857
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/>
14858
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_express_reference">(^([A-Za-z0-9_.\\]+)$)</xsl:variable>
14656
14859
 
14657
14860
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
14861
+ <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>
14862
+ <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
14863
 
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">
14864
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
14865
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
14866
+ <!-- add &lt; and &gt; to \S -->
14867
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
14868
+ <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
14869
 
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">
14870
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
14871
+ <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>
14872
+
14873
+ <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">
14874
+
14875
+ <xsl:variable name="parent" select="local-name(..)"/>
14876
+
14877
+ <xsl:if test="1 = 2"> <!-- alternative variant -->
14878
+
14879
+ <xsl:variable name="regexs">
14880
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14881
+ <xsl:if test="not(ancestor::*[local-name() = 'table'])"><regex><xsl:value-of select="$regex_standard_reference"/></regex></xsl:if>
14882
+ <!-- if EXPRESS reference -->
14883
+
14884
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
14885
+ <regex><xsl:value-of select="$regex_solidus_units"/></regex>
14886
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
14887
+ <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14888
+ <regex><xsl:value-of select="$regex_dots_units"/></regex>
14889
+ </xsl:if>
14890
+ </xsl:variable>
14891
+
14892
+ <xsl:variable name="regex_replacement"><xsl:text>(</xsl:text>
14893
+ <xsl:for-each select="xalan:nodeset($regexs)/regex">
14894
+ <xsl:value-of select="."/>
14895
+ <xsl:if test="position() != last()">|</xsl:if>
14896
+ </xsl:for-each>
14897
+ <xsl:text>)</xsl:text>
14898
+ </xsl:variable>
14899
+
14900
+ <!-- regex_replacement='<xsl:value-of select="$regex_replacement"/>' -->
14901
+
14902
+ <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))"/>
14903
+
14904
+ <!-- text_replaced='<xsl:value-of select="$text_replaced"/>' -->
14905
+
14906
+ <xsl:call-template name="replace_text_tags">
14672
14907
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14673
14908
  <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>
14909
+ <xsl:with-param name="text" select="$text_replaced"/>
14910
+ </xsl:call-template>
14911
+ </xsl:if>
14676
14912
 
14677
- <xsl:variable name="parent" select="local-name(..)"/>
14913
+ <xsl:if test="1 = 1">
14914
+
14915
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
14916
+ <xsl:variable name="text">
14917
+ <xsl:element name="text" namespace="{$namespace_full}">
14918
+ <xsl:choose>
14919
+ <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 -->
14920
+ <xsl:otherwise>
14921
+ <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))"/>
14922
+ <!-- <xsl:value-of select="$text__"/> -->
14923
+
14924
+ <xsl:call-template name="replace_text_tags">
14925
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14926
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14927
+ <xsl:with-param name="text" select="$text_"/>
14928
+ </xsl:call-template>
14929
+
14930
+ </xsl:otherwise>
14931
+ </xsl:choose>
14932
+ </xsl:element>
14933
+ </xsl:variable>
14678
14934
 
14679
14935
  <xsl:variable name="text2">
14680
- <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
14936
+ <xsl:element name="text" namespace="{$namespace_full}">
14937
+ <xsl:for-each select="xalan:nodeset($text)/*[local-name() = 'text']/node()">
14681
14938
  <xsl:copy-of select="."/>
14682
- </xsl:for-each></text>
14939
+ </xsl:for-each>
14940
+ </xsl:element>
14683
14941
  </xsl:variable>
14684
14942
 
14685
14943
  <!-- 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
14944
  <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>
14945
+ <xsl:element name="text" namespace="{$namespace_full}">
14946
+ <xsl:for-each select="xalan:nodeset($text2)/*[local-name() = 'text']/node()">
14947
+ <xsl:choose>
14948
+ <xsl:when test="self::text()">
14949
+ <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))"/>
14950
+ <!-- <xsl:variable name="text_units">
14951
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14952
+ <xsl:call-template name="replace_text_tags">
14953
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14954
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14955
+ <xsl:with-param name="text" select="$text_units"/>
14956
+ </xsl:call-template>
14957
+ <!-- </xsl:element>
14958
+ </xsl:variable>
14959
+ <xsl:copy-of select="xalan:nodeset($text_units)/*[local-name() = 'text']/node()"/> -->
14960
+ </xsl:when>
14961
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14962
+ </xsl:choose>
14963
+ </xsl:for-each>
14964
+ </xsl:element>
14706
14965
  </xsl:variable>
14707
14966
 
14708
14967
  <xsl:choose>
14709
14968
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
14710
14969
  <!-- 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()">
14970
+ <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()">
14714
14971
  <xsl:choose>
14715
14972
  <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()"/>
14973
+ <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))"/>
14974
+ <!-- <xsl:variable name="text_dots">
14975
+ <xsl:element name="text" namespace="{$namespace_full}"> -->
14976
+ <xsl:call-template name="replace_text_tags">
14977
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
14978
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
14979
+ <xsl:with-param name="text" select="$text_dots"/>
14980
+ </xsl:call-template>
14981
+ <!-- </xsl:element>
14982
+ </xsl:variable>
14983
+ <xsl:copy-of select="xalan:nodeset($text_dots)/*[local-name() = 'text']/node()"/> -->
14723
14984
  </xsl:when>
14724
14985
  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
14725
14986
  </xsl:choose>
14726
14987
  </xsl:for-each>
14727
14988
  </xsl:when>
14728
- <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
14989
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"/></xsl:otherwise>
14729
14990
  </xsl:choose>
14730
-
14991
+ </xsl:if>
14731
14992
  </xsl:template>
14732
14993
 
14733
14994
  <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 +15511,15 @@
15250
15511
  </xsl:otherwise>
15251
15512
  </xsl:choose>
15252
15513
  </xsl:for-each>
15514
+ <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
15515
+ <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
15516
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
15517
+ <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
15518
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/>
15519
+ <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
15520
+ <pdf:embedded-file src="{$url}" filename="{$filename_embedded}"/>
15521
+ </xsl:for-each>
15522
+ </xsl:if>
15253
15523
  </xsl:template> <!-- addPDFUAmeta -->
15254
15524
 
15255
15525
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getId">