metanorma-ieee 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
5
  <!-- mandatory 'key' -->
6
- <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
6
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
7
7
 
8
8
  <!-- mandatory variable -->
9
9
 
@@ -40,7 +40,7 @@
40
40
  <!-- mandatory variable -->
41
41
  <xsl:variable name="ids">
42
42
  <xsl:for-each select="//*[@id]">
43
- <id><xsl:value-of select="@id"/></id>
43
+ <id name="{local-name()}"><xsl:value-of select="@id"/></id>
44
44
  </xsl:for-each>
45
45
  </xsl:variable>
46
46
 
@@ -77,7 +77,7 @@
77
77
  <xsl:variable name="current_template">
78
78
  <xsl:choose>
79
79
  <xsl:when test="($doctype = 'standard' or $doctype = 'guide' or $doctype = 'recommended-practice') and $stage = 'draft'">draft</xsl:when>
80
- <xsl:when test="($doctype = 'standard' or $doctype = 'guide' or $doctype = 'recommended-practice') and $stage = 'published'">standard</xsl:when>
80
+ <xsl:when test="($doctype = 'standard' or $doctype = 'guide' or $doctype = 'recommended-practice') and ($stage = 'published' or $stage = 'approved')">standard</xsl:when>
81
81
  <xsl:otherwise><xsl:value-of select="$doctype"/></xsl:otherwise>
82
82
  </xsl:choose>
83
83
  </xsl:variable>
@@ -548,6 +548,8 @@
548
548
 
549
549
  <fo:block break-after="page"/>
550
550
 
551
+ <!-- Second page -->
552
+
551
553
  <fo:block font-family="Arial" text-align="justify">
552
554
  <fo:block>
553
555
  <fo:inline font-weight="bold">
@@ -566,6 +568,7 @@
566
568
  <xsl:if test="position() != last()">, </xsl:if>
567
569
  </xsl:for-each>
568
570
  </fo:block>
571
+ <xsl:apply-templates select="/ieee:ieee-standard/ieee:preface/ieee:acknowledgements"/>
569
572
  </fo:block>
570
573
 
571
574
  <!-- Example:
@@ -728,6 +731,7 @@
728
731
  <xsl:if test="position() != last()">, </xsl:if>
729
732
  </xsl:for-each>
730
733
  </fo:block>
734
+ <xsl:apply-templates select="/ieee:ieee-standard/ieee:preface/ieee:acknowledgements"/>
731
735
  </fo:block>
732
736
 
733
737
  <!-- Example:
@@ -764,7 +768,7 @@
764
768
  </fo:block>
765
769
  </fo:flow>
766
770
  </fo:page-sequence>
767
- </xsl:when> <!-- $stage = 'published' -->
771
+ </xsl:when> <!-- $current_template = 'standard' -->
768
772
 
769
773
  <xsl:when test="$current_template = 'whitepaper' or $current_template = 'icap-whitepaper' or $current_template = 'industry-connection-report'">
770
774
  <fo:page-sequence master-reference="document-nonstandard" force-page-count="no-force" font-family="Calibri Light">
@@ -869,7 +873,7 @@
869
873
  </fo:block>
870
874
 
871
875
  <fo:block font-family="Arial" font-size="12pt" role="H1" font-weight="bold" margin-top="12pt" margin-bottom="24pt">
872
- <xsl:if test="$stage = 'published'">
876
+ <xsl:if test="$stage = 'published' or $stage = 'approved'">
873
877
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
874
878
  </xsl:if>
875
879
  <!-- Contents -->
@@ -940,7 +944,7 @@
940
944
 
941
945
  </xsl:when> <!-- $stage = 'draft' -->
942
946
 
943
- <xsl:when test="$stage = 'published'">
947
+ <xsl:when test="$stage = 'published' or $stage = 'approved'">
944
948
 
945
949
  <xsl:variable name="provisional-distance-between-starts">10</xsl:variable>
946
950
 
@@ -1012,7 +1016,7 @@
1012
1016
  </xsl:for-each>
1013
1017
  </xsl:if>
1014
1018
 
1015
- </xsl:when> <!-- $stage = 'published' -->
1019
+ </xsl:when> <!-- $stage = 'published' or 'approved' -->
1016
1020
  </xsl:choose>
1017
1021
 
1018
1022
  </xsl:if>
@@ -1509,15 +1513,15 @@
1509
1513
  </fo:table>
1510
1514
  </fo:block>
1511
1515
 
1512
- <xsl:if test="following-sibling::*[not(@type = 'officemember' or @type = 'emeritus_sign')]">
1513
- <fo:block font-size="10pt" space-after="12pt"> </fo:block>
1516
+ <xsl:if test="following-sibling::*[1][not(@type = 'officemember' or @type = 'emeritus_sign')]">
1517
+ <fo:block font-size="10pt" space-after="12pt" keep-with-previous="always"> </fo:block>
1514
1518
  </xsl:if>
1515
1519
  </xsl:when> <!-- @type = 'officemember' -->
1516
1520
 
1517
1521
  <xsl:when test="@type = 'officemember' and preceding-sibling::*[1][self::ieee:p][@type = 'officemember']"><!-- skip --></xsl:when>
1518
1522
 
1519
1523
  <xsl:when test="@type = 'emeritus_sign'">
1520
- <fo:block font-size="9pt" margin-left="9.4mm">
1524
+ <fo:block font-size="9pt" margin-left="9.4mm" space-before="6pt" space-after="12pt" keep-with-previous="always">
1521
1525
  <xsl:apply-templates/>
1522
1526
  </fo:block>
1523
1527
  </xsl:when>
@@ -1597,6 +1601,12 @@
1597
1601
  <fo:inline><xsl:apply-templates/></fo:inline>
1598
1602
  </xsl:template>
1599
1603
 
1604
+ <xsl:template match="ieee:preface/ieee:acknowledgements" priority="3">
1605
+ <fo:block>
1606
+ <xsl:apply-templates/>
1607
+ </fo:block>
1608
+ </xsl:template>
1609
+
1600
1610
  <xsl:template match="text()" priority="2" mode="uppercase">
1601
1611
  <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
1602
1612
  </xsl:template>
@@ -2301,6 +2311,7 @@
2301
2311
  <xsl:otherwise>
2302
2312
  <xsl:choose>
2303
2313
  <xsl:when test="@type = 'section-title'">12pt</xsl:when>
2314
+ <xsl:when test="ancestor::ieee:acknowledgements">inherit</xsl:when>
2304
2315
  <xsl:when test="$level = 1">12pt</xsl:when>
2305
2316
  <xsl:when test="$level = 2">11pt</xsl:when>
2306
2317
  <xsl:otherwise>10pt</xsl:otherwise> <!-- 3rd, 4th, ... levels -->
@@ -2804,7 +2815,7 @@
2804
2815
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
2805
2816
 
2806
2817
  <!-- no highlight term's names -->
2807
- <xsl:if test="normalize-space() != '' and string-length(normalize-space()) = string-length(translate(normalize-space(), '0123456789', '')) and not(contains(normalize-space(), 'Annex'))">
2818
+ <xsl:if test="normalize-space() != '' and xalan:nodeset($ids)/id[. = current()/@target]/@name = 'term'"> <!-- string-length(normalize-space()) = string-length(translate(normalize-space(), '0123456789', '')) and not(contains(normalize-space(), 'Annex')) -->
2808
2819
  <xsl:attribute name="color">inherit</xsl:attribute>
2809
2820
  <xsl:attribute name="text-decoration">none</xsl:attribute>
2810
2821
  </xsl:if>
@@ -3722,6 +3733,8 @@
3722
3733
  </xsl:choose>
3723
3734
  </xsl:template>
3724
3735
 
3736
+ <xsl:strip-space elements="ieee:xref"/>
3737
+
3725
3738
  <!-- external parameters -->
3726
3739
 
3727
3740
  <xsl:param name="svg_images"/> <!-- svg images array -->
@@ -4257,6 +4270,7 @@
4257
4270
 
4258
4271
  1pt solid black
4259
4272
 
4273
+
4260
4274
  </xsl:variable>
4261
4275
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
4262
4276
 
@@ -5125,17 +5139,22 @@
5125
5139
  </xsl:for-each>
5126
5140
  </xsl:template>
5127
5141
 
5142
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5128
5143
  <xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
5129
5144
  <xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
5130
5145
  <xsl:template match="text()" name="text">
5131
5146
 
5132
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5133
- <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))"/>
5134
- <xsl:call-template name="replace_fo_inline_tags">
5135
- <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
5136
- <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
5137
- <xsl:with-param name="text" select="$text"/>
5138
- </xsl:call-template>
5147
+ <xsl:choose>
5148
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when>
5149
+ <xsl:otherwise>
5150
+ <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))"/>
5151
+ <xsl:call-template name="replace_fo_inline_tags">
5152
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
5153
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
5154
+ <xsl:with-param name="text" select="$text"/>
5155
+ </xsl:call-template>
5156
+ </xsl:otherwise>
5157
+ </xsl:choose>
5139
5158
 
5140
5159
  </xsl:template>
5141
5160
 
@@ -6214,7 +6233,7 @@
6214
6233
  <xsl:template match="*[local-name()='tr']">
6215
6234
  <fo:table-row xsl:use-attribute-sets="table-body-row-style">
6216
6235
 
6217
- <xsl:if test="*[local-name() = 'th']">
6236
+ <xsl:if test="count(*) = count(*[local-name() = 'th'])"> <!-- row contains 'th' only -->
6218
6237
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
6219
6238
  </xsl:if>
6220
6239
 
@@ -6387,6 +6406,10 @@
6387
6406
  <xsl:variable name="footnote_inline">
6388
6407
  <fo:inline xsl:use-attribute-sets="fn-num-style">
6389
6408
 
6409
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
6410
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
6411
+ </xsl:if>
6412
+
6390
6413
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
6391
6414
  <xsl:value-of select="$current_fn_number_text"/>
6392
6415
  </fo:basic-link>
@@ -7193,7 +7216,8 @@
7193
7216
  <xsl:copy-of select="node()"/>
7194
7217
  </td>
7195
7218
  <td>
7196
- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
7219
+ <!-- <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/> -->
7220
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]" mode="dl_if"/>
7197
7221
  <!-- get paragraphs from nested 'dl' -->
7198
7222
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
7199
7223
  </td>
@@ -7201,6 +7225,53 @@
7201
7225
  </xsl:template>
7202
7226
  <xsl:template match="*[local-name()='dd']" mode="dl_if"/>
7203
7227
 
7228
+ <xsl:template match="*" mode="dl_if">
7229
+ <xsl:copy-of select="."/>
7230
+ </xsl:template>
7231
+
7232
+ <xsl:template match="*[local-name() = 'p']" mode="dl_if">
7233
+ <xsl:param name="indent"/>
7234
+ <p>
7235
+ <xsl:copy-of select="@*"/>
7236
+ <xsl:value-of select="$indent"/>
7237
+ <xsl:copy-of select="node()"/>
7238
+ </p>
7239
+
7240
+ </xsl:template>
7241
+
7242
+ <xsl:template match="*[local-name() = 'ul' or local-name() = 'ol']" mode="dl_if">
7243
+ <xsl:variable name="list_rendered_">
7244
+ <xsl:apply-templates select="."/>
7245
+ </xsl:variable>
7246
+ <xsl:variable name="list_rendered" select="xalan:nodeset($list_rendered_)"/>
7247
+
7248
+ <xsl:variable name="indent">
7249
+ <xsl:for-each select="($list_rendered//fo:block[not(.//fo:block)])[1]">
7250
+ <xsl:apply-templates select="ancestor::*[@provisional-distance-between-starts]/@provisional-distance-between-starts" mode="dl_if"/>
7251
+ </xsl:for-each>
7252
+ </xsl:variable>
7253
+
7254
+ <xsl:apply-templates mode="dl_if">
7255
+ <xsl:with-param name="indent" select="$indent"/>
7256
+ </xsl:apply-templates>
7257
+ </xsl:template>
7258
+
7259
+ <xsl:template match="*[local-name() = 'li']" mode="dl_if">
7260
+ <xsl:param name="indent"/>
7261
+ <xsl:apply-templates mode="dl_if">
7262
+ <xsl:with-param name="indent" select="$indent"/>
7263
+ </xsl:apply-templates>
7264
+ </xsl:template>
7265
+
7266
+ <xsl:template match="@provisional-distance-between-starts" mode="dl_if">
7267
+ <xsl:variable name="value" select="round(substring-before(.,'mm'))"/>
7268
+ <!-- emulate left indent for list item -->
7269
+ <xsl:call-template name="repeat">
7270
+ <xsl:with-param name="char" select="'x'"/>
7271
+ <xsl:with-param name="count" select="$value"/>
7272
+ </xsl:call-template>
7273
+ </xsl:template>
7274
+
7204
7275
  <xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
7205
7276
  <xsl:for-each select="*[local-name() = 'dt']">
7206
7277
  <p>
@@ -7496,6 +7567,23 @@
7496
7567
  <xsl:apply-templates/>
7497
7568
  </xsl:template>
7498
7569
 
7570
+ <!-- Don't break standard's numbers -->
7571
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
7572
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
7573
+ <xsl:choose>
7574
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
7575
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
7576
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
7577
+ </xsl:when>
7578
+ <xsl:otherwise>
7579
+ <xsl:apply-templates/>
7580
+ </xsl:otherwise>
7581
+ </xsl:choose>
7582
+ </xsl:template>
7583
+ <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">
7584
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
7585
+ </xsl:template>
7586
+
7499
7587
  <!-- ========================= -->
7500
7588
  <!-- END Rich text formatting -->
7501
7589
  <!-- ========================= -->
@@ -7594,6 +7682,7 @@
7594
7682
  </word>
7595
7683
  <xsl:call-template name="tokenize_with_tags">
7596
7684
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
7685
+ <xsl:with-param name="tags" select="$tags"/>
7597
7686
  </xsl:call-template>
7598
7687
  </xsl:otherwise>
7599
7688
  </xsl:choose>
@@ -7633,8 +7722,18 @@
7633
7722
 
7634
7723
  <xsl:template name="add-zero-spaces-java">
7635
7724
  <xsl:param name="text" select="."/>
7636
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
7637
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| )','$1​')"/>
7725
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
7726
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
7727
+ <!-- add zero-width space (#x200B) after characters: 'great than' -->
7728
+ <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' -->
7729
+ <!-- add zero-width space (#x200B) before characters: 'less than' -->
7730
+ <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' -->
7731
+ <!-- add zero-width space (#x200B) before character: { -->
7732
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
7733
+ <!-- add zero-width space (#x200B) after character: , -->
7734
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
7735
+
7736
+ <xsl:value-of select="$text5"/>
7638
7737
  </xsl:template>
7639
7738
 
7640
7739
  <xsl:template name="add-zero-spaces-link-java">
@@ -7780,7 +7879,7 @@
7780
7879
  </xsl:copy>
7781
7880
  </xsl:template>
7782
7881
 
7783
- <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
7882
+ <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">
7784
7883
  <xsl:copy>
7785
7884
  <xsl:copy-of select="@*"/>
7786
7885
  <p>
@@ -7828,6 +7927,28 @@
7828
7927
  </xsl:for-each>
7829
7928
  </xsl:template>
7830
7929
 
7930
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']" mode="table-without-br">
7931
+ <xsl:apply-templates mode="table-without-br"/>
7932
+ </xsl:template>
7933
+
7934
+ <xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'sourcecode']/text()[contains(., '&#13;') or contains(., '&#10;')]" mode="table-without-br">
7935
+
7936
+ <xsl:variable name="sep">###SOURCECODE_NEWLINE###</xsl:variable>
7937
+ <xsl:variable name="sourcecode_text" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', $sep)"/>
7938
+ <xsl:variable name="items">
7939
+ <xsl:call-template name="split">
7940
+ <xsl:with-param name="pText" select="$sourcecode_text"/>
7941
+ <xsl:with-param name="sep" select="$sep"/>
7942
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
7943
+ </xsl:call-template>
7944
+ </xsl:variable>
7945
+ <xsl:for-each select="xalan:nodeset($items)/*">
7946
+ <p>
7947
+ <sourcecode><xsl:copy-of select="node()"/></sourcecode>
7948
+ </p>
7949
+ </xsl:for-each>
7950
+ </xsl:template>
7951
+
7831
7952
  <!-- remove redundant white spaces -->
7832
7953
  <xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
7833
7954
  <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
@@ -7858,7 +7979,7 @@
7858
7979
  <xsl:choose>
7859
7980
  <xsl:when test="@colspan">
7860
7981
  <xsl:variable name="td">
7861
- <xsl:element name="td">
7982
+ <xsl:element name="{local-name()}">
7862
7983
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
7863
7984
  <xsl:if test="local-name()='th'">
7864
7985
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -7873,7 +7994,7 @@
7873
7994
  </xsl:call-template>
7874
7995
  </xsl:when>
7875
7996
  <xsl:otherwise>
7876
- <xsl:element name="td">
7997
+ <xsl:element name="{local-name()}">
7877
7998
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
7878
7999
  <xsl:if test="local-name()='th'">
7879
8000
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -7940,7 +8061,7 @@
7940
8061
  <xsl:variable name="currentRow" select="."/>
7941
8062
 
7942
8063
  <xsl:variable name="normalizedTDs">
7943
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
8064
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
7944
8065
  <xsl:choose>
7945
8066
  <xsl:when test="@rowspan &gt; 1">
7946
8067
  <xsl:copy>
@@ -7952,7 +8073,7 @@
7952
8073
  </xsl:copy>
7953
8074
  </xsl:when>
7954
8075
  <xsl:otherwise>
7955
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
8076
+ <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)])]"/>
7956
8077
  </xsl:otherwise>
7957
8078
  </xsl:choose>
7958
8079
  </xsl:for-each>
@@ -8138,6 +8259,7 @@
8138
8259
  <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
8139
8260
  <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
8140
8261
  <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
8262
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode']"><tag>sourcecode</tag></xsl:if>
8141
8263
  <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
8142
8264
  </tags>
8143
8265
  </xsl:template>
@@ -9142,6 +9264,31 @@
9142
9264
  <xsl:apply-templates mode="svg_update"/>
9143
9265
  </xsl:copy>
9144
9266
  </xsl:template>
9267
+
9268
+ <!-- regex for 'display: inline-block;' -->
9269
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
9270
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
9271
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
9272
+ </xsl:template>
9273
+
9274
+ <!-- replace
9275
+ stroke="rgba(r, g, b, alpha)" to
9276
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
9277
+ fill="rgba(r, g, b, alpha)" to
9278
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
9279
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
9280
+ <xsl:variable name="components_">
9281
+ <xsl:call-template name="split">
9282
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
9283
+ <xsl:with-param name="sep" select="','"/>
9284
+ </xsl:call-template>
9285
+ </xsl:variable>
9286
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
9287
+ <xsl:variable name="att_name" select="local-name()"/>
9288
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
9289
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
9290
+ </xsl:template>
9291
+
9145
9292
  <!-- ============== -->
9146
9293
  <!-- END: svg_update -->
9147
9294
  <!-- ============== -->
@@ -9785,37 +9932,15 @@
9785
9932
  <!-- =============== -->
9786
9933
  <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
9787
9934
 
9788
- <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
9789
-
9790
- <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
9791
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
9792
- </xsl:if>
9793
-
9794
- <xsl:if test="ancestor::*[local-name() = 'example']">
9795
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
9796
- </xsl:if>
9797
-
9798
- <xsl:copy-of select="@id"/>
9799
-
9800
- <xsl:if test="parent::*[local-name() = 'note']">
9801
- <xsl:attribute name="margin-left">
9802
- <xsl:choose>
9803
- <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
9804
- <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
9805
- </xsl:choose>
9806
- </xsl:attribute>
9807
-
9808
- </xsl:if>
9809
- <fo:block-container margin-left="0mm">
9810
-
9811
- <fo:block xsl:use-attribute-sets="sourcecode-style">
9812
- <xsl:variable name="_font-size">
9935
+ <xsl:variable name="sourcecode_attributes">
9936
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
9937
+ <xsl:variable name="_font-size">
9813
9938
 
9814
- <!-- 9 -->
9939
+ <!-- 9 -->
9815
9940
 
9816
- <!-- <xsl:if test="$namespace = 'ieee'">
9817
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
9818
- </xsl:if> -->
9941
+ <!-- <xsl:if test="$namespace = 'ieee'">
9942
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
9943
+ </xsl:if> -->
9819
9944
 
9820
9945
  </xsl:variable>
9821
9946
 
@@ -9830,14 +9955,60 @@
9830
9955
  </xsl:choose>
9831
9956
  </xsl:attribute>
9832
9957
  </xsl:if>
9958
+ </xsl:element>
9959
+ </xsl:variable>
9833
9960
 
9961
+ <xsl:choose>
9962
+ <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
9963
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
9964
+ <xsl:attribute name="{local-name()}">
9965
+ <xsl:value-of select="."/>
9966
+ </xsl:attribute>
9967
+ </xsl:for-each>
9834
9968
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
9835
- </fo:block>
9969
+ </xsl:when>
9836
9970
 
9837
- <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
9971
+ <xsl:otherwise>
9972
+ <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
9838
9973
 
9839
- </fo:block-container>
9840
- </fo:block-container>
9974
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
9975
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
9976
+ </xsl:if>
9977
+
9978
+ <xsl:if test="ancestor::*[local-name() = 'example']">
9979
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
9980
+ </xsl:if>
9981
+
9982
+ <xsl:copy-of select="@id"/>
9983
+
9984
+ <xsl:if test="parent::*[local-name() = 'note']">
9985
+ <xsl:attribute name="margin-left">
9986
+ <xsl:choose>
9987
+ <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when>
9988
+ <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise>
9989
+ </xsl:choose>
9990
+ </xsl:attribute>
9991
+
9992
+ </xsl:if>
9993
+ <fo:block-container margin-left="0mm">
9994
+
9995
+ <fo:block xsl:use-attribute-sets="sourcecode-style">
9996
+
9997
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
9998
+ <xsl:attribute name="{local-name()}">
9999
+ <xsl:value-of select="."/>
10000
+ </xsl:attribute>
10001
+ </xsl:for-each>
10002
+
10003
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
10004
+ </fo:block>
10005
+
10006
+ <xsl:apply-templates select="*[local-name()='name']"/> <!-- show sourcecode's name AFTER content -->
10007
+
10008
+ </fo:block-container>
10009
+ </fo:block-container>
10010
+ </xsl:otherwise>
10011
+ </xsl:choose>
9841
10012
  </xsl:template>
9842
10013
 
9843
10014
  <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -12125,7 +12296,11 @@
12125
12296
  <!-- ===================================== -->
12126
12297
  <!-- Update xml -->
12127
12298
  <!-- ===================================== -->
12128
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12299
+ <!-- =========================================================================== -->
12300
+ <!-- STEP1: -->
12301
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
12302
+ <!-- - Ignore 'span' without style -->
12303
+ <!-- =========================================================================== -->
12129
12304
  <xsl:template match="@*|node()" mode="update_xml_step1">
12130
12305
  <xsl:copy>
12131
12306
  <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
@@ -12207,7 +12382,8 @@
12207
12382
  </xsl:copy>
12208
12383
  </xsl:template>
12209
12384
 
12210
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
12385
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
12386
+ <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">
12211
12387
  <xsl:copy>
12212
12388
  <xsl:copy-of select="@*"/>
12213
12389
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -12217,10 +12393,13 @@
12217
12393
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
12218
12394
  <xsl:apply-templates mode="update_xml_step1"/>
12219
12395
  </xsl:template>
12220
-
12396
+ <!-- =========================================================================== -->
12221
12397
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12398
+ <!-- =========================================================================== -->
12222
12399
 
12400
+ <!-- =========================================================================== -->
12223
12401
  <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12402
+ <!-- =========================================================================== -->
12224
12403
  <xsl:template match="@*|node()" mode="update_xml_step2">
12225
12404
  <xsl:copy>
12226
12405
  <xsl:apply-templates select="@*|node()" mode="update_xml_step2"/>
@@ -12299,8 +12478,6 @@
12299
12478
  </xsl:copy>
12300
12479
  </xsl:template>
12301
12480
 
12302
- <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12303
-
12304
12481
  <!-- enclose sequence of 'char x' + 'combining char y' to <lang_none>xy</lang_none> -->
12305
12482
  <xsl:variable name="regex_combining_chars">(.[̀-ͯ])</xsl:variable>
12306
12483
  <xsl:variable name="element_name_lang_none">lang_none</xsl:variable>
@@ -12316,7 +12493,15 @@
12316
12493
  </xsl:call-template>
12317
12494
  </xsl:template>
12318
12495
 
12496
+ <!-- =========================================================================== -->
12497
+ <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12498
+ <!-- =========================================================================== -->
12499
+
12500
+ <!-- =========================================================================== -->
12319
12501
  <!-- XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
12502
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
12503
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
12504
+ <!-- =========================================================================== -->
12320
12505
  <!-- Example: <keep-together_within-line>ISO 10303-51</keep-together_within-line> -->
12321
12506
  <xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
12322
12507
  <xsl:copy>
@@ -12332,10 +12517,15 @@
12332
12517
  <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">
12333
12518
 
12334
12519
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
12335
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
12336
12520
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
12337
12521
  <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
12338
- <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))"/>
12522
+ <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))"/>
12523
+ <xsl:variable name="text_">
12524
+ <xsl:choose>
12525
+ <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 -->
12526
+ <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise>
12527
+ </xsl:choose>
12528
+ </xsl:variable>
12339
12529
  <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
12340
12530
  <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
12341
12531
  <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
@@ -12351,7 +12541,11 @@
12351
12541
  </xsl:variable>
12352
12542
 
12353
12543
  <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
12354
- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
12544
+ <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
12545
+ <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
12546
+ <!-- add &lt; and &gt; to \S -->
12547
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
12548
+ <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>
12355
12549
  <xsl:variable name="text3">
12356
12550
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
12357
12551
  <xsl:choose>
@@ -12415,9 +12609,8 @@
12415
12609
  <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
12416
12610
  </xsl:choose>
12417
12611
  </xsl:template>
12418
-
12419
12612
  <!-- ===================================== -->
12420
- <!-- End Update xml -->
12613
+ <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
12421
12614
  <!-- ===================================== -->
12422
12615
 
12423
12616
  <!-- for correct rendering combining chars -->
@@ -12,7 +12,7 @@ module IsoDoc
12
12
 
13
13
  def xref_init(lang, script, _klass, i18n, options)
14
14
  html = HtmlConvert.new(language: lang, script: script)
15
- options = options.merge(hierarchical_assets: @hierarchical_assets)
15
+ options = options.merge(hierarchicalassets: @hierarchical_assets)
16
16
  @xrefs = Xref.new(lang, script, html, i18n, options)
17
17
  end
18
18