metanorma-ogc 2.2.6 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1442,6 +1442,8 @@
1442
1442
  </fo:static-content>
1443
1443
  </xsl:template>
1444
1444
 
1445
+ <xsl:strip-space elements="ogc:xref"/>
1446
+
1445
1447
  <!-- external parameters -->
1446
1448
 
1447
1449
  <xsl:param name="svg_images"/> <!-- svg images array -->
@@ -2932,17 +2934,22 @@
2932
2934
  </xsl:for-each>
2933
2935
  </xsl:template>
2934
2936
 
2937
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2935
2938
  <xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
2936
2939
  <xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
2937
2940
  <xsl:template match="text()" name="text">
2938
2941
 
2939
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2940
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/>
2941
- <xsl:call-template name="replace_fo_inline_tags">
2942
- <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2943
- <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2944
- <xsl:with-param name="text" select="$text"/>
2945
- </xsl:call-template>
2942
+ <xsl:choose>
2943
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when>
2944
+ <xsl:otherwise>
2945
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/>
2946
+ <xsl:call-template name="replace_fo_inline_tags">
2947
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2948
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2949
+ <xsl:with-param name="text" select="$text"/>
2950
+ </xsl:call-template>
2951
+ </xsl:otherwise>
2952
+ </xsl:choose>
2946
2953
 
2947
2954
  </xsl:template>
2948
2955
 
@@ -3979,7 +3986,7 @@
3979
3986
  <xsl:template match="*[local-name()='tr']">
3980
3987
  <fo:table-row xsl:use-attribute-sets="table-body-row-style">
3981
3988
 
3982
- <xsl:if test="*[local-name() = 'th']">
3989
+ <xsl:if test="count(*) = count(*[local-name() = 'th'])"> <!-- row contains 'th' only -->
3983
3990
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
3984
3991
  </xsl:if>
3985
3992
 
@@ -4155,6 +4162,10 @@
4155
4162
  <xsl:variable name="footnote_inline">
4156
4163
  <fo:inline xsl:use-attribute-sets="fn-num-style">
4157
4164
 
4165
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
4166
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
4167
+ </xsl:if>
4168
+
4158
4169
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
4159
4170
  <xsl:value-of select="$current_fn_number_text"/>
4160
4171
  </fo:basic-link>
@@ -4963,7 +4974,8 @@
4963
4974
  <xsl:copy-of select="node()"/>
4964
4975
  </td>
4965
4976
  <td>
4966
- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
4977
+ <!-- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/> -->
4978
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]" mode="dl_if"/>
4967
4979
  <!-- get paragraphs from nested 'dl' -->
4968
4980
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
4969
4981
  </td>
@@ -4971,6 +4983,53 @@
4971
4983
  </xsl:template>
4972
4984
  <xsl:template match="*[local-name()='dd']" mode="dl_if"/>
4973
4985
 
4986
+ <xsl:template match="*" mode="dl_if">
4987
+ <xsl:copy-of select="."/>
4988
+ </xsl:template>
4989
+
4990
+ <xsl:template match="*[local-name() = 'p']" mode="dl_if">
4991
+ <xsl:param name="indent"/>
4992
+ <p>
4993
+ <xsl:copy-of select="@*"/>
4994
+ <xsl:value-of select="$indent"/>
4995
+ <xsl:copy-of select="node()"/>
4996
+ </p>
4997
+
4998
+ </xsl:template>
4999
+
5000
+ <xsl:template match="*[local-name() = 'ul' or local-name() = 'ol']" mode="dl_if">
5001
+ <xsl:variable name="list_rendered_">
5002
+ <xsl:apply-templates select="."/>
5003
+ </xsl:variable>
5004
+ <xsl:variable name="list_rendered" select="xalan:nodeset($list_rendered_)"/>
5005
+
5006
+ <xsl:variable name="indent">
5007
+ <xsl:for-each select="($list_rendered//fo:block[not(.//fo:block)])[1]">
5008
+ <xsl:apply-templates select="ancestor::*[@provisional-distance-between-starts]/@provisional-distance-between-starts" mode="dl_if"/>
5009
+ </xsl:for-each>
5010
+ </xsl:variable>
5011
+
5012
+ <xsl:apply-templates mode="dl_if">
5013
+ <xsl:with-param name="indent" select="$indent"/>
5014
+ </xsl:apply-templates>
5015
+ </xsl:template>
5016
+
5017
+ <xsl:template match="*[local-name() = 'li']" mode="dl_if">
5018
+ <xsl:param name="indent"/>
5019
+ <xsl:apply-templates mode="dl_if">
5020
+ <xsl:with-param name="indent" select="$indent"/>
5021
+ </xsl:apply-templates>
5022
+ </xsl:template>
5023
+
5024
+ <xsl:template match="@provisional-distance-between-starts" mode="dl_if">
5025
+ <xsl:variable name="value" select="round(substring-before(.,'mm'))"/>
5026
+ <!-- emulate left indent for list item -->
5027
+ <xsl:call-template name="repeat">
5028
+ <xsl:with-param name="char" select="'x'"/>
5029
+ <xsl:with-param name="count" select="$value"/>
5030
+ </xsl:call-template>
5031
+ </xsl:template>
5032
+
4974
5033
  <xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
4975
5034
  <xsl:for-each select="*[local-name() = 'dt']">
4976
5035
  <p>
@@ -5271,6 +5330,23 @@
5271
5330
  <xsl:apply-templates/>
5272
5331
  </xsl:template>
5273
5332
 
5333
+ <!-- Don't break standard's numbers -->
5334
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
5335
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
5336
+ <xsl:choose>
5337
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
5338
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
5339
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
5340
+ </xsl:when>
5341
+ <xsl:otherwise>
5342
+ <xsl:apply-templates/>
5343
+ </xsl:otherwise>
5344
+ </xsl:choose>
5345
+ </xsl:template>
5346
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'table']) and preceding-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear'] and following-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']]" priority="2">
5347
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
5348
+ </xsl:template>
5349
+
5274
5350
  <!-- ========================= -->
5275
5351
  <!-- END Rich text formatting -->
5276
5352
  <!-- ========================= -->
@@ -5369,6 +5445,7 @@
5369
5445
  </word>
5370
5446
  <xsl:call-template name="tokenize_with_tags">
5371
5447
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5448
+ <xsl:with-param name="tags" select="$tags"/>
5372
5449
  </xsl:call-template>
5373
5450
  </xsl:otherwise>
5374
5451
  </xsl:choose>
@@ -5408,8 +5485,18 @@
5408
5485
 
5409
5486
  <xsl:template name="add-zero-spaces-java">
5410
5487
  <xsl:param name="text" select="."/>
5411
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
5412
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| )','$1​')"/>
5488
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
5489
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
5490
+ <!-- add zero-width space (#x200B) after characters: 'great than' -->
5491
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
5492
+ <!-- add zero-width space (#x200B) before characters: 'less than' -->
5493
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
5494
+ <!-- add zero-width space (#x200B) before character: { -->
5495
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
5496
+ <!-- add zero-width space (#x200B) after character: , -->
5497
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
5498
+
5499
+ <xsl:value-of select="$text5"/>
5413
5500
  </xsl:template>
5414
5501
 
5415
5502
  <xsl:template name="add-zero-spaces-link-java">
@@ -5555,7 +5642,7 @@
5555
5642
  </xsl:copy>
5556
5643
  </xsl:template>
5557
5644
 
5558
- <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
5645
+ <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p']) and not(*[local-name()='sourcecode'])]" mode="table-without-br">
5559
5646
  <xsl:copy>
5560
5647
  <xsl:copy-of select="@*"/>
5561
5648
  <p>
@@ -5603,6 +5690,28 @@
5603
5690
  </xsl:for-each>
5604
5691
  </xsl:template>
5605
5692
 
5693
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']" mode="table-without-br">
5694
+ <xsl:apply-templates mode="table-without-br"/>
5695
+ </xsl:template>
5696
+
5697
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']/text()[contains(., '&#13;') or contains(., '&#10;')]" mode="table-without-br">
5698
+
5699
+ <xsl:variable name="sep">###SOURCECODE_NEWLINE###</xsl:variable>
5700
+ <xsl:variable name="sourcecode_text" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', $sep)"/>
5701
+ <xsl:variable name="items">
5702
+ <xsl:call-template name="split">
5703
+ <xsl:with-param name="pText" select="$sourcecode_text"/>
5704
+ <xsl:with-param name="sep" select="$sep"/>
5705
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5706
+ </xsl:call-template>
5707
+ </xsl:variable>
5708
+ <xsl:for-each select="xalan:nodeset($items)/*">
5709
+ <p>
5710
+ <sourcecode><xsl:copy-of select="node()"/></sourcecode>
5711
+ </p>
5712
+ </xsl:for-each>
5713
+ </xsl:template>
5714
+
5606
5715
  <!-- remove redundant white spaces -->
5607
5716
  <xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
5608
5717
  <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
@@ -5633,7 +5742,7 @@
5633
5742
  <xsl:choose>
5634
5743
  <xsl:when test="@colspan">
5635
5744
  <xsl:variable name="td">
5636
- <xsl:element name="td">
5745
+ <xsl:element name="{local-name()}">
5637
5746
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
5638
5747
  <xsl:if test="local-name()='th'">
5639
5748
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -5648,7 +5757,7 @@
5648
5757
  </xsl:call-template>
5649
5758
  </xsl:when>
5650
5759
  <xsl:otherwise>
5651
- <xsl:element name="td">
5760
+ <xsl:element name="{local-name()}">
5652
5761
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
5653
5762
  <xsl:if test="local-name()='th'">
5654
5763
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -5715,7 +5824,7 @@
5715
5824
  <xsl:variable name="currentRow" select="."/>
5716
5825
 
5717
5826
  <xsl:variable name="normalizedTDs">
5718
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
5827
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
5719
5828
  <xsl:choose>
5720
5829
  <xsl:when test="@rowspan &gt; 1">
5721
5830
  <xsl:copy>
@@ -5727,7 +5836,7 @@
5727
5836
  </xsl:copy>
5728
5837
  </xsl:when>
5729
5838
  <xsl:otherwise>
5730
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
5839
+ <xsl:copy-of select="$currentRow/*[self::td or self::th][1 + count(current()/preceding-sibling::*[self::td or self::th][not(@rowspan) or (@rowspan = 1)])]"/>
5731
5840
  </xsl:otherwise>
5732
5841
  </xsl:choose>
5733
5842
  </xsl:for-each>
@@ -5913,6 +6022,7 @@
5913
6022
  <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
5914
6023
  <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
5915
6024
  <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6025
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']"><tag>sourcecode</tag></xsl:if>
5916
6026
  <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
5917
6027
  </tags>
5918
6028
  </xsl:template>
@@ -6907,6 +7017,31 @@
6907
7017
  <xsl:apply-templates mode="svg_update"/>
6908
7018
  </xsl:copy>
6909
7019
  </xsl:template>
7020
+
7021
+ <!-- regex for 'display: inline-block;' -->
7022
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7023
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
7024
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
7025
+ </xsl:template>
7026
+
7027
+ <!-- replace
7028
+ stroke="rgba(r, g, b, alpha)" to
7029
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
7030
+ fill="rgba(r, g, b, alpha)" to
7031
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
7032
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
7033
+ <xsl:variable name="components_">
7034
+ <xsl:call-template name="split">
7035
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
7036
+ <xsl:with-param name="sep" select="','"/>
7037
+ </xsl:call-template>
7038
+ </xsl:variable>
7039
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
7040
+ <xsl:variable name="att_name" select="local-name()"/>
7041
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
7042
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
7043
+ </xsl:template>
7044
+
6910
7045
  <!-- ============== -->
6911
7046
  <!-- END: svg_update -->
6912
7047
  <!-- ============== -->
@@ -7563,46 +7698,20 @@
7563
7698
  <!-- =============== -->
7564
7699
  <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
7565
7700
 
7566
- <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7567
-
7568
- <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7569
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
7570
- </xsl:if>
7571
-
7572
- <xsl:if test="ancestor::*[local-name() = 'example']">
7573
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
7574
- </xsl:if>
7575
-
7576
- <xsl:copy-of select="@id"/>
7577
-
7578
- <xsl:if test="parent::*[local-name() = 'note']">
7579
- <xsl:attribute name="margin-left">
7580
- <xsl:choose>
7581
- <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
7582
- <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
7583
- </xsl:choose>
7584
- </xsl:attribute>
7701
+ <xsl:variable name="sourcecode_attributes">
7702
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
7703
+ <xsl:variable name="_font-size">
7585
7704
 
7586
- </xsl:if>
7587
- <fo:block-container margin-left="0mm">
7588
-
7589
- <xsl:if test="parent::*[local-name() = 'example']">
7590
- <fo:block font-size="1pt" line-height="10%" space-after="4pt"> </fo:block>
7591
- </xsl:if>
7592
-
7593
- <fo:block xsl:use-attribute-sets="sourcecode-style">
7594
- <xsl:variable name="_font-size">
7705
+ <!-- 9 -->
7595
7706
 
7596
- <!-- 9 -->
7597
-
7598
- <!-- <xsl:if test="$namespace = 'ieee'">
7599
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
7600
- </xsl:if> -->
7707
+ <!-- <xsl:if test="$namespace = 'ieee'">
7708
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
7709
+ </xsl:if> -->
7601
7710
 
7602
- <xsl:choose>
7603
- <xsl:when test="ancestor::*[local-name() = 'table']">8.5</xsl:when>
7604
- <xsl:otherwise>9.5</xsl:otherwise>
7605
- </xsl:choose>
7711
+ <xsl:choose>
7712
+ <xsl:when test="ancestor::*[local-name() = 'table']">8.5</xsl:when>
7713
+ <xsl:otherwise>9.5</xsl:otherwise>
7714
+ </xsl:choose>
7606
7715
 
7607
7716
  </xsl:variable>
7608
7717
 
@@ -7617,22 +7726,72 @@
7617
7726
  </xsl:choose>
7618
7727
  </xsl:attribute>
7619
7728
  </xsl:if>
7729
+ </xsl:element>
7730
+ </xsl:variable>
7620
7731
 
7621
- <xsl:if test="parent::*[local-name() = 'example']">
7622
- <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
7732
+ <xsl:choose>
7733
+ <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
7734
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
7735
+ <xsl:attribute name="{local-name()}">
7736
+ <xsl:value-of select="."/>
7737
+ </xsl:attribute>
7738
+ </xsl:for-each>
7739
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7740
+ </xsl:when>
7741
+
7742
+ <xsl:otherwise>
7743
+ <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7744
+
7745
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7746
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7623
7747
  </xsl:if>
7624
7748
 
7625
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7626
- </fo:block>
7749
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7750
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7751
+ </xsl:if>
7627
7752
 
7628
- <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
7753
+ <xsl:copy-of select="@id"/>
7629
7754
 
7630
- <xsl:if test="parent::*[local-name() = 'example']">
7631
- <fo:block font-size="1pt" line-height="10%" space-before="6pt"> </fo:block>
7632
- </xsl:if>
7755
+ <xsl:if test="parent::*[local-name() = 'note']">
7756
+ <xsl:attribute name="margin-left">
7757
+ <xsl:choose>
7758
+ <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
7759
+ <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
7760
+ </xsl:choose>
7761
+ </xsl:attribute>
7633
7762
 
7634
- </fo:block-container>
7635
- </fo:block-container>
7763
+ </xsl:if>
7764
+ <fo:block-container margin-left="0mm">
7765
+
7766
+ <xsl:if test="parent::*[local-name() = 'example']">
7767
+ <fo:block font-size="1pt" line-height="10%" space-after="4pt"> </fo:block>
7768
+ </xsl:if>
7769
+
7770
+ <fo:block xsl:use-attribute-sets="sourcecode-style">
7771
+
7772
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
7773
+ <xsl:attribute name="{local-name()}">
7774
+ <xsl:value-of select="."/>
7775
+ </xsl:attribute>
7776
+ </xsl:for-each>
7777
+
7778
+ <xsl:if test="parent::*[local-name() = 'example']">
7779
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
7780
+ </xsl:if>
7781
+
7782
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7783
+ </fo:block>
7784
+
7785
+ <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
7786
+
7787
+ <xsl:if test="parent::*[local-name() = 'example']">
7788
+ <fo:block font-size="1pt" line-height="10%" space-before="6pt"> </fo:block>
7789
+ </xsl:if>
7790
+
7791
+ </fo:block-container>
7792
+ </fo:block-container>
7793
+ </xsl:otherwise>
7794
+ </xsl:choose>
7636
7795
  </xsl:template>
7637
7796
 
7638
7797
  <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -9862,7 +10021,11 @@
9862
10021
  <!-- ===================================== -->
9863
10022
  <!-- Update xml -->
9864
10023
  <!-- ===================================== -->
9865
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10024
+ <!-- =========================================================================== -->
10025
+ <!-- STEP1: -->
10026
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
10027
+ <!-- - Ignore 'span' without style -->
10028
+ <!-- =========================================================================== -->
9866
10029
  <xsl:template match="@*|node()" mode="update_xml_step1">
9867
10030
  <xsl:copy>
9868
10031
  <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
@@ -9944,7 +10107,8 @@
9944
10107
  </xsl:copy>
9945
10108
  </xsl:template>
9946
10109
 
9947
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
10110
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
10111
+ <xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" mode="update_xml_step1" priority="2">
9948
10112
  <xsl:copy>
9949
10113
  <xsl:copy-of select="@*"/>
9950
10114
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -9954,10 +10118,15 @@
9954
10118
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9955
10119
  <xsl:apply-templates mode="update_xml_step1"/>
9956
10120
  </xsl:template>
9957
-
10121
+ <!-- =========================================================================== -->
9958
10122
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10123
+ <!-- =========================================================================== -->
9959
10124
 
10125
+ <!-- =========================================================================== -->
9960
10126
  <!-- XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10127
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
10128
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
10129
+ <!-- =========================================================================== -->
9961
10130
  <!-- Example: <keep-together_within-line>ISO 10303-51</keep-together_within-line> -->
9962
10131
  <xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9963
10132
  <xsl:copy>
@@ -9973,10 +10142,15 @@
9973
10142
  <xsl:template 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 starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
9974
10143
 
9975
10144
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
9976
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9977
10145
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9978
10146
  <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9979
- <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))"/>
10147
+ <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))"/>
10148
+ <xsl:variable name="text_">
10149
+ <xsl:choose>
10150
+ <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 -->
10151
+ <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
10152
+ </xsl:choose>
10153
+ </xsl:variable>
9980
10154
  <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9981
10155
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9982
10156
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
@@ -9992,7 +10166,11 @@
9992
10166
  </xsl:variable>
9993
10167
 
9994
10168
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9995
- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
10169
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
10170
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
10171
+ <!-- add &lt; and &gt; to \S -->
10172
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
10173
+ <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>
9996
10174
  <xsl:variable name="text3">
9997
10175
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9998
10176
  <xsl:choose>
@@ -10056,9 +10234,8 @@
10056
10234
  <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
10057
10235
  </xsl:choose>
10058
10236
  </xsl:template>
10059
-
10060
10237
  <!-- ===================================== -->
10061
- <!-- End Update xml -->
10238
+ <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10062
10239
  <!-- ===================================== -->
10063
10240
 
10064
10241
  <!-- for correct rendering combining chars -->