metanorma-itu 2.1.12 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2049,6 +2049,8 @@
2049
2049
  </xsl:if>
2050
2050
  </xsl:template>
2051
2051
 
2052
+ <xsl:strip-space elements="itu:xref"/>
2053
+
2052
2054
  <!-- external parameters -->
2053
2055
 
2054
2056
  <xsl:param name="svg_images"/> <!-- svg images array -->
@@ -3426,17 +3428,22 @@
3426
3428
  </xsl:for-each>
3427
3429
  </xsl:template>
3428
3430
 
3431
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3429
3432
  <xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
3430
3433
  <xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
3431
3434
  <xsl:template match="text()" name="text">
3432
3435
 
3433
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3434
- <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))"/>
3435
- <xsl:call-template name="replace_fo_inline_tags">
3436
- <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3437
- <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3438
- <xsl:with-param name="text" select="$text"/>
3439
- </xsl:call-template>
3436
+ <xsl:choose>
3437
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when>
3438
+ <xsl:otherwise>
3439
+ <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))"/>
3440
+ <xsl:call-template name="replace_fo_inline_tags">
3441
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3442
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3443
+ <xsl:with-param name="text" select="$text"/>
3444
+ </xsl:call-template>
3445
+ </xsl:otherwise>
3446
+ </xsl:choose>
3440
3447
 
3441
3448
  </xsl:template>
3442
3449
 
@@ -3822,7 +3829,7 @@
3822
3829
 
3823
3830
  <!-- centered table when table name is centered (see table-name-style) -->
3824
3831
 
3825
- <fo:table table-layout="fixed" width="100%">
3832
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
3826
3833
  <fo:table-column column-width="proportional-column-width(1)"/>
3827
3834
  <fo:table-column column-width="{@width}"/>
3828
3835
  <fo:table-column column-width="proportional-column-width(1)"/>
@@ -4498,7 +4505,7 @@
4498
4505
  <xsl:template match="*[local-name()='tr']">
4499
4506
  <fo:table-row xsl:use-attribute-sets="table-body-row-style">
4500
4507
 
4501
- <xsl:if test="*[local-name() = 'th']">
4508
+ <xsl:if test="count(*) = count(*[local-name() = 'th'])"> <!-- row contains 'th' only -->
4502
4509
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
4503
4510
  </xsl:if>
4504
4511
 
@@ -4683,6 +4690,10 @@
4683
4690
  <xsl:variable name="footnote_inline">
4684
4691
  <fo:inline xsl:use-attribute-sets="fn-num-style">
4685
4692
 
4693
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
4694
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
4695
+ </xsl:if>
4696
+
4686
4697
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
4687
4698
  <xsl:value-of select="$current_fn_number_text"/>
4688
4699
  </fo:basic-link>
@@ -5506,7 +5517,8 @@
5506
5517
  <xsl:copy-of select="node()"/>
5507
5518
  </td>
5508
5519
  <td>
5509
- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5520
+ <!-- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/> -->
5521
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]" mode="dl_if"/>
5510
5522
  <!-- get paragraphs from nested 'dl' -->
5511
5523
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5512
5524
  </td>
@@ -5514,6 +5526,53 @@
5514
5526
  </xsl:template>
5515
5527
  <xsl:template match="*[local-name()='dd']" mode="dl_if"/>
5516
5528
 
5529
+ <xsl:template match="*" mode="dl_if">
5530
+ <xsl:copy-of select="."/>
5531
+ </xsl:template>
5532
+
5533
+ <xsl:template match="*[local-name() = 'p']" mode="dl_if">
5534
+ <xsl:param name="indent"/>
5535
+ <p>
5536
+ <xsl:copy-of select="@*"/>
5537
+ <xsl:value-of select="$indent"/>
5538
+ <xsl:copy-of select="node()"/>
5539
+ </p>
5540
+
5541
+ </xsl:template>
5542
+
5543
+ <xsl:template match="*[local-name() = 'ul' or local-name() = 'ol']" mode="dl_if">
5544
+ <xsl:variable name="list_rendered_">
5545
+ <xsl:apply-templates select="."/>
5546
+ </xsl:variable>
5547
+ <xsl:variable name="list_rendered" select="xalan:nodeset($list_rendered_)"/>
5548
+
5549
+ <xsl:variable name="indent">
5550
+ <xsl:for-each select="($list_rendered//fo:block[not(.//fo:block)])[1]">
5551
+ <xsl:apply-templates select="ancestor::*[@provisional-distance-between-starts]/@provisional-distance-between-starts" mode="dl_if"/>
5552
+ </xsl:for-each>
5553
+ </xsl:variable>
5554
+
5555
+ <xsl:apply-templates mode="dl_if">
5556
+ <xsl:with-param name="indent" select="$indent"/>
5557
+ </xsl:apply-templates>
5558
+ </xsl:template>
5559
+
5560
+ <xsl:template match="*[local-name() = 'li']" mode="dl_if">
5561
+ <xsl:param name="indent"/>
5562
+ <xsl:apply-templates mode="dl_if">
5563
+ <xsl:with-param name="indent" select="$indent"/>
5564
+ </xsl:apply-templates>
5565
+ </xsl:template>
5566
+
5567
+ <xsl:template match="@provisional-distance-between-starts" mode="dl_if">
5568
+ <xsl:variable name="value" select="round(substring-before(.,'mm'))"/>
5569
+ <!-- emulate left indent for list item -->
5570
+ <xsl:call-template name="repeat">
5571
+ <xsl:with-param name="char" select="'x'"/>
5572
+ <xsl:with-param name="count" select="$value"/>
5573
+ </xsl:call-template>
5574
+ </xsl:template>
5575
+
5517
5576
  <xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5518
5577
  <xsl:for-each select="*[local-name() = 'dt']">
5519
5578
  <p>
@@ -5809,6 +5868,23 @@
5809
5868
  <xsl:apply-templates/>
5810
5869
  </xsl:template>
5811
5870
 
5871
+ <!-- Don't break standard's numbers -->
5872
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
5873
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
5874
+ <xsl:choose>
5875
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
5876
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
5877
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
5878
+ </xsl:when>
5879
+ <xsl:otherwise>
5880
+ <xsl:apply-templates/>
5881
+ </xsl:otherwise>
5882
+ </xsl:choose>
5883
+ </xsl:template>
5884
+ <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">
5885
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
5886
+ </xsl:template>
5887
+
5812
5888
  <!-- ========================= -->
5813
5889
  <!-- END Rich text formatting -->
5814
5890
  <!-- ========================= -->
@@ -5907,6 +5983,7 @@
5907
5983
  </word>
5908
5984
  <xsl:call-template name="tokenize_with_tags">
5909
5985
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5986
+ <xsl:with-param name="tags" select="$tags"/>
5910
5987
  </xsl:call-template>
5911
5988
  </xsl:otherwise>
5912
5989
  </xsl:choose>
@@ -5946,8 +6023,18 @@
5946
6023
 
5947
6024
  <xsl:template name="add-zero-spaces-java">
5948
6025
  <xsl:param name="text" select="."/>
5949
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
5950
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| )','$1​')"/>
6026
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
6027
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
6028
+ <!-- add zero-width space (#x200B) after characters: 'great than' -->
6029
+ <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' -->
6030
+ <!-- add zero-width space (#x200B) before characters: 'less than' -->
6031
+ <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' -->
6032
+ <!-- add zero-width space (#x200B) before character: { -->
6033
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
6034
+ <!-- add zero-width space (#x200B) after character: , -->
6035
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
6036
+
6037
+ <xsl:value-of select="$text5"/>
5951
6038
  </xsl:template>
5952
6039
 
5953
6040
  <xsl:template name="add-zero-spaces-link-java">
@@ -6093,7 +6180,7 @@
6093
6180
  </xsl:copy>
6094
6181
  </xsl:template>
6095
6182
 
6096
- <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
6183
+ <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">
6097
6184
  <xsl:copy>
6098
6185
  <xsl:copy-of select="@*"/>
6099
6186
  <p>
@@ -6141,6 +6228,28 @@
6141
6228
  </xsl:for-each>
6142
6229
  </xsl:template>
6143
6230
 
6231
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']" mode="table-without-br">
6232
+ <xsl:apply-templates mode="table-without-br"/>
6233
+ </xsl:template>
6234
+
6235
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']/text()[contains(., '&#13;') or contains(., '&#10;')]" mode="table-without-br">
6236
+
6237
+ <xsl:variable name="sep">###SOURCECODE_NEWLINE###</xsl:variable>
6238
+ <xsl:variable name="sourcecode_text" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', $sep)"/>
6239
+ <xsl:variable name="items">
6240
+ <xsl:call-template name="split">
6241
+ <xsl:with-param name="pText" select="$sourcecode_text"/>
6242
+ <xsl:with-param name="sep" select="$sep"/>
6243
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
6244
+ </xsl:call-template>
6245
+ </xsl:variable>
6246
+ <xsl:for-each select="xalan:nodeset($items)/*">
6247
+ <p>
6248
+ <sourcecode><xsl:copy-of select="node()"/></sourcecode>
6249
+ </p>
6250
+ </xsl:for-each>
6251
+ </xsl:template>
6252
+
6144
6253
  <!-- remove redundant white spaces -->
6145
6254
  <xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
6146
6255
  <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
@@ -6171,7 +6280,7 @@
6171
6280
  <xsl:choose>
6172
6281
  <xsl:when test="@colspan">
6173
6282
  <xsl:variable name="td">
6174
- <xsl:element name="td">
6283
+ <xsl:element name="{local-name()}">
6175
6284
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
6176
6285
  <xsl:if test="local-name()='th'">
6177
6286
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -6186,7 +6295,7 @@
6186
6295
  </xsl:call-template>
6187
6296
  </xsl:when>
6188
6297
  <xsl:otherwise>
6189
- <xsl:element name="td">
6298
+ <xsl:element name="{local-name()}">
6190
6299
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
6191
6300
  <xsl:if test="local-name()='th'">
6192
6301
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -6253,7 +6362,7 @@
6253
6362
  <xsl:variable name="currentRow" select="."/>
6254
6363
 
6255
6364
  <xsl:variable name="normalizedTDs">
6256
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
6365
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
6257
6366
  <xsl:choose>
6258
6367
  <xsl:when test="@rowspan &gt; 1">
6259
6368
  <xsl:copy>
@@ -6265,7 +6374,7 @@
6265
6374
  </xsl:copy>
6266
6375
  </xsl:when>
6267
6376
  <xsl:otherwise>
6268
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
6377
+ <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)])]"/>
6269
6378
  </xsl:otherwise>
6270
6379
  </xsl:choose>
6271
6380
  </xsl:for-each>
@@ -6451,6 +6560,7 @@
6451
6560
  <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6452
6561
  <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6453
6562
  <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6563
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']"><tag>sourcecode</tag></xsl:if>
6454
6564
  <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6455
6565
  </tags>
6456
6566
  </xsl:template>
@@ -7443,6 +7553,31 @@
7443
7553
  <xsl:apply-templates mode="svg_update"/>
7444
7554
  </xsl:copy>
7445
7555
  </xsl:template>
7556
+
7557
+ <!-- regex for 'display: inline-block;' -->
7558
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7559
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
7560
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
7561
+ </xsl:template>
7562
+
7563
+ <!-- replace
7564
+ stroke="rgba(r, g, b, alpha)" to
7565
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
7566
+ fill="rgba(r, g, b, alpha)" to
7567
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
7568
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
7569
+ <xsl:variable name="components_">
7570
+ <xsl:call-template name="split">
7571
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
7572
+ <xsl:with-param name="sep" select="','"/>
7573
+ </xsl:call-template>
7574
+ </xsl:variable>
7575
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
7576
+ <xsl:variable name="att_name" select="local-name()"/>
7577
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
7578
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
7579
+ </xsl:template>
7580
+
7446
7581
  <!-- ============== -->
7447
7582
  <!-- END: svg_update -->
7448
7583
  <!-- ============== -->
@@ -8081,38 +8216,16 @@
8081
8216
  <!-- =============== -->
8082
8217
  <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
8083
8218
 
8084
- <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
8085
-
8086
- <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
8087
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
8088
- </xsl:if>
8089
-
8090
- <xsl:if test="ancestor::*[local-name() = 'example']">
8091
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
8092
- </xsl:if>
8093
-
8094
- <xsl:copy-of select="@id"/>
8095
-
8096
- <xsl:if test="parent::*[local-name() = 'note']">
8097
- <xsl:attribute name="margin-left">
8098
- <xsl:choose>
8099
- <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
8100
- <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
8101
- </xsl:choose>
8102
- </xsl:attribute>
8103
-
8104
- </xsl:if>
8105
- <fo:block-container margin-left="0mm">
8219
+ <xsl:variable name="sourcecode_attributes">
8220
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
8221
+ <xsl:variable name="_font-size">
8106
8222
 
8107
- <fo:block xsl:use-attribute-sets="sourcecode-style">
8108
- <xsl:variable name="_font-size">
8223
+ <!-- 9 -->
8109
8224
 
8110
- <!-- 9 -->
8111
-
8112
- <!-- <xsl:if test="$namespace = 'ieee'">
8113
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
8114
- </xsl:if> -->
8115
- 10
8225
+ <!-- <xsl:if test="$namespace = 'ieee'">
8226
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
8227
+ </xsl:if> -->
8228
+ 10
8116
8229
 
8117
8230
 
8118
8231
  </xsl:variable>
@@ -8128,14 +8241,60 @@
8128
8241
  </xsl:choose>
8129
8242
  </xsl:attribute>
8130
8243
  </xsl:if>
8244
+ </xsl:element>
8245
+ </xsl:variable>
8131
8246
 
8247
+ <xsl:choose>
8248
+ <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
8249
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
8250
+ <xsl:attribute name="{local-name()}">
8251
+ <xsl:value-of select="."/>
8252
+ </xsl:attribute>
8253
+ </xsl:for-each>
8132
8254
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8133
- </fo:block>
8255
+ </xsl:when>
8134
8256
 
8135
- <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
8257
+ <xsl:otherwise>
8258
+ <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
8136
8259
 
8137
- </fo:block-container>
8138
- </fo:block-container>
8260
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
8261
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
8262
+ </xsl:if>
8263
+
8264
+ <xsl:if test="ancestor::*[local-name() = 'example']">
8265
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
8266
+ </xsl:if>
8267
+
8268
+ <xsl:copy-of select="@id"/>
8269
+
8270
+ <xsl:if test="parent::*[local-name() = 'note']">
8271
+ <xsl:attribute name="margin-left">
8272
+ <xsl:choose>
8273
+ <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
8274
+ <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
8275
+ </xsl:choose>
8276
+ </xsl:attribute>
8277
+
8278
+ </xsl:if>
8279
+ <fo:block-container margin-left="0mm">
8280
+
8281
+ <fo:block xsl:use-attribute-sets="sourcecode-style">
8282
+
8283
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
8284
+ <xsl:attribute name="{local-name()}">
8285
+ <xsl:value-of select="."/>
8286
+ </xsl:attribute>
8287
+ </xsl:for-each>
8288
+
8289
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8290
+ </fo:block>
8291
+
8292
+ <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
8293
+
8294
+ </fo:block-container>
8295
+ </fo:block-container>
8296
+ </xsl:otherwise>
8297
+ </xsl:choose>
8139
8298
  </xsl:template>
8140
8299
 
8141
8300
  <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -10396,7 +10555,11 @@
10396
10555
  <!-- ===================================== -->
10397
10556
  <!-- Update xml -->
10398
10557
  <!-- ===================================== -->
10399
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10558
+ <!-- =========================================================================== -->
10559
+ <!-- STEP1: -->
10560
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
10561
+ <!-- - Ignore 'span' without style -->
10562
+ <!-- =========================================================================== -->
10400
10563
  <xsl:template match="@*|node()" mode="update_xml_step1">
10401
10564
  <xsl:copy>
10402
10565
  <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
@@ -10478,7 +10641,8 @@
10478
10641
  </xsl:copy>
10479
10642
  </xsl:template>
10480
10643
 
10481
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
10644
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
10645
+ <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">
10482
10646
  <xsl:copy>
10483
10647
  <xsl:copy-of select="@*"/>
10484
10648
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -10488,10 +10652,15 @@
10488
10652
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
10489
10653
  <xsl:apply-templates mode="update_xml_step1"/>
10490
10654
  </xsl:template>
10491
-
10655
+ <!-- =========================================================================== -->
10492
10656
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10657
+ <!-- =========================================================================== -->
10493
10658
 
10659
+ <!-- =========================================================================== -->
10494
10660
  <!-- XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10661
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
10662
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
10663
+ <!-- =========================================================================== -->
10495
10664
  <!-- Example: <keep-together_within-line>ISO 10303-51</keep-together_within-line> -->
10496
10665
  <xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
10497
10666
  <xsl:copy>
@@ -10507,10 +10676,15 @@
10507
10676
  <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">
10508
10677
 
10509
10678
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
10510
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
10511
10679
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
10512
10680
  <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
10513
- <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))"/>
10681
+ <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))"/>
10682
+ <xsl:variable name="text_">
10683
+ <xsl:choose>
10684
+ <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 -->
10685
+ <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
10686
+ </xsl:choose>
10687
+ </xsl:variable>
10514
10688
  <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
10515
10689
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
10516
10690
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
@@ -10526,7 +10700,11 @@
10526
10700
  </xsl:variable>
10527
10701
 
10528
10702
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
10529
- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
10703
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
10704
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
10705
+ <!-- add &lt; and &gt; to \S -->
10706
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
10707
+ <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>
10530
10708
  <xsl:variable name="text3">
10531
10709
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
10532
10710
  <xsl:choose>
@@ -10590,9 +10768,8 @@
10590
10768
  <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
10591
10769
  </xsl:choose>
10592
10770
  </xsl:template>
10593
-
10594
10771
  <!-- ===================================== -->
10595
- <!-- End Update xml -->
10772
+ <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10596
10773
  <!-- ===================================== -->
10597
10774
 
10598
10775
  <!-- for correct rendering combining chars -->