metanorma-iho 0.6.13 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -335,29 +335,32 @@
335
335
 
336
336
  <!-- Document Pages -->
337
337
 
338
- <fo:page-sequence master-reference="document" initial-page-number="1" format="1" force-page-count="no-force">
339
- <fo:static-content flow-name="xsl-footnote-separator">
340
- <fo:block>
341
- <fo:leader leader-pattern="rule" leader-length="30%"/>
342
- </fo:block>
343
- </fo:static-content>
344
- <xsl:call-template name="insertHeaderFooter"/>
345
- <fo:flow flow-name="xsl-region-body">
346
- <fo:block-container>
338
+ <xsl:if test="/iho:iho-standard/iho:sections/*">
347
339
 
348
- <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="18pt" role="H1"><xsl:value-of select="$title-en"/></fo:block> -->
340
+ <fo:page-sequence master-reference="document" initial-page-number="1" format="1" force-page-count="no-force">
341
+ <fo:static-content flow-name="xsl-footnote-separator">
342
+ <fo:block>
343
+ <fo:leader leader-pattern="rule" leader-length="30%"/>
344
+ </fo:block>
345
+ </fo:static-content>
346
+ <xsl:call-template name="insertHeaderFooter"/>
347
+ <fo:flow flow-name="xsl-region-body">
348
+ <fo:block-container>
349
349
 
350
- <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/>
351
- <!-- Normative references -->
352
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"/>
353
- <!-- Terms and definitions -->
354
- <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms']"/>
355
- <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='definitions']"/>
356
- <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope')]"/>
350
+ <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="18pt" role="H1"><xsl:value-of select="$title-en"/></fo:block> -->
357
351
 
358
- </fo:block-container>
359
- </fo:flow>
360
- </fo:page-sequence>
352
+ <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/>
353
+ <!-- Normative references -->
354
+ <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"/>
355
+ <!-- Terms and definitions -->
356
+ <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms']"/>
357
+ <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='definitions']"/>
358
+ <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope')]"/>
359
+
360
+ </fo:block-container>
361
+ </fo:flow>
362
+ </fo:page-sequence>
363
+ </xsl:if>
361
364
 
362
365
  <xsl:if test="/iho:iho-standard/iho:annex">
363
366
  <fo:page-sequence master-reference="document">
@@ -484,6 +487,10 @@
484
487
 
485
488
  </xsl:template>
486
489
 
490
+ <xsl:template match="*[local-name() = 'strong']" mode="contents_item" priority="2">
491
+ <xsl:apply-templates mode="contents_item"/>
492
+ </xsl:template>
493
+
487
494
  <!-- ============================= -->
488
495
  <!-- END CONTENTS -->
489
496
  <!-- ============================= -->
@@ -1651,6 +1658,12 @@
1651
1658
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1652
1659
  </xsl:attribute-set>
1653
1660
 
1661
+ <xsl:attribute-set name="figure-block-style">
1662
+
1663
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1664
+
1665
+ </xsl:attribute-set>
1666
+
1654
1667
  <xsl:attribute-set name="figure-style">
1655
1668
 
1656
1669
  </xsl:attribute-set>
@@ -1661,7 +1674,7 @@
1661
1674
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1662
1675
  <xsl:attribute name="text-align">center</xsl:attribute>
1663
1676
  <xsl:attribute name="margin-top">2pt</xsl:attribute>
1664
- <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1677
+ <xsl:attribute name="space-after">6pt</xsl:attribute>
1665
1678
  <xsl:attribute name="keep-with-previous">always</xsl:attribute>
1666
1679
 
1667
1680
  </xsl:attribute-set>
@@ -3057,6 +3070,10 @@
3057
3070
  <xsl:with-param name="continued">true</xsl:with-param>
3058
3071
  </xsl:apply-templates>
3059
3072
 
3073
+ <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
3074
+ <fo:block/>
3075
+ </xsl:if>
3076
+
3060
3077
  </fo:table-cell>
3061
3078
  </fo:table-row>
3062
3079
  </xsl:template> <!-- table-header-title -->
@@ -3441,7 +3458,26 @@
3441
3458
 
3442
3459
  <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
3443
3460
  <xsl:variable name="footnote_inline">
3444
- <fo:inline xsl:use-attribute-sets="fn-num-style">
3461
+ <fo:inline>
3462
+
3463
+ <xsl:variable name="fn_styles">
3464
+ <xsl:choose>
3465
+ <xsl:when test="ancestor::*[local-name() = 'bibitem']">
3466
+ <fn_styles xsl:use-attribute-sets="bibitem-note-fn-style"/>
3467
+ </xsl:when>
3468
+ <xsl:otherwise>
3469
+ <fn_styles xsl:use-attribute-sets="fn-num-style"/>
3470
+ </xsl:otherwise>
3471
+ </xsl:choose>
3472
+ </xsl:variable>
3473
+
3474
+ <xsl:for-each select="xalan:nodeset($fn_styles)/fn_styles/@*">
3475
+ <xsl:copy-of select="."/>
3476
+ </xsl:for-each>
3477
+
3478
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
3479
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
3480
+ </xsl:if>
3445
3481
 
3446
3482
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3447
3483
  <xsl:value-of select="$current_fn_number_text"/>
@@ -3501,7 +3537,10 @@
3501
3537
  </xsl:for-each>
3502
3538
  <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']/*">
3503
3539
  <xsl:sort select="@displayorder" data-type="number"/>
3504
- <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
3540
+ <!-- commented:
3541
+ .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
3542
+ because 'fn' there is in biblio-tag -->
3543
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
3505
3544
  <!-- copy unique fn -->
3506
3545
  <fn gen_id="{generate-id(.)}">
3507
3546
  <xsl:copy-of select="@*"/>
@@ -4357,7 +4396,7 @@
4357
4396
  <xsl:variable name="_font-size">
4358
4397
 
4359
4398
  9.5
4360
- <!-- 10 -->
4399
+ <!-- inherit -->
4361
4400
 
4362
4401
  </xsl:variable>
4363
4402
  <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
@@ -4667,6 +4706,23 @@
4667
4706
  <xsl:apply-templates/>
4668
4707
  </xsl:template>
4669
4708
 
4709
+ <!-- Don't break standard's numbers -->
4710
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
4711
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
4712
+ <xsl:choose>
4713
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
4714
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
4715
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
4716
+ </xsl:when>
4717
+ <xsl:otherwise>
4718
+ <xsl:apply-templates/>
4719
+ </xsl:otherwise>
4720
+ </xsl:choose>
4721
+ </xsl:template>
4722
+ <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">
4723
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
4724
+ </xsl:template>
4725
+
4670
4726
  <!-- ========================= -->
4671
4727
  <!-- END Rich text formatting -->
4672
4728
  <!-- ========================= -->
@@ -5062,7 +5118,7 @@
5062
5118
  <xsl:choose>
5063
5119
  <xsl:when test="@colspan">
5064
5120
  <xsl:variable name="td">
5065
- <xsl:element name="td">
5121
+ <xsl:element name="{local-name()}">
5066
5122
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
5067
5123
  <xsl:if test="local-name()='th'">
5068
5124
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -5077,7 +5133,7 @@
5077
5133
  </xsl:call-template>
5078
5134
  </xsl:when>
5079
5135
  <xsl:otherwise>
5080
- <xsl:element name="td">
5136
+ <xsl:element name="{local-name()}">
5081
5137
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
5082
5138
  <xsl:if test="local-name()='th'">
5083
5139
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -5144,7 +5200,7 @@
5144
5200
  <xsl:variable name="currentRow" select="."/>
5145
5201
 
5146
5202
  <xsl:variable name="normalizedTDs">
5147
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
5203
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
5148
5204
  <xsl:choose>
5149
5205
  <xsl:when test="@rowspan &gt; 1">
5150
5206
  <xsl:copy>
@@ -5156,7 +5212,7 @@
5156
5212
  </xsl:copy>
5157
5213
  </xsl:when>
5158
5214
  <xsl:otherwise>
5159
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
5215
+ <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)])]"/>
5160
5216
  </xsl:otherwise>
5161
5217
  </xsl:choose>
5162
5218
  </xsl:for-each>
@@ -5377,6 +5433,33 @@
5377
5433
  </xsl:choose>
5378
5434
  </xsl:template>
5379
5435
 
5436
+ <xsl:template name="getLang_fromCurrentNode">
5437
+ <xsl:variable name="language_current" select="normalize-space(.//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5438
+ <xsl:variable name="language">
5439
+ <xsl:choose>
5440
+ <xsl:when test="$language_current != ''">
5441
+ <xsl:value-of select="$language_current"/>
5442
+ </xsl:when>
5443
+ <xsl:otherwise>
5444
+ <xsl:variable name="language_current_2" select="normalize-space(xalan:nodeset($bibdata)//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5445
+ <xsl:choose>
5446
+ <xsl:when test="$language_current_2 != ''">
5447
+ <xsl:value-of select="$language_current_2"/>
5448
+ </xsl:when>
5449
+ <xsl:otherwise>
5450
+ <xsl:value-of select=".//*[local-name()='bibdata']//*[local-name()='language']"/>
5451
+ </xsl:otherwise>
5452
+ </xsl:choose>
5453
+ </xsl:otherwise>
5454
+ </xsl:choose>
5455
+ </xsl:variable>
5456
+
5457
+ <xsl:choose>
5458
+ <xsl:when test="$language = 'English'">en</xsl:when>
5459
+ <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
5460
+ </xsl:choose>
5461
+ </xsl:template>
5462
+
5380
5463
  <xsl:template name="capitalizeWords">
5381
5464
  <xsl:param name="str"/>
5382
5465
  <xsl:variable name="str2" select="translate($str, '-', ' ')"/>
@@ -5826,12 +5909,6 @@
5826
5909
 
5827
5910
  <fo:block-container margin-left="0mm">
5828
5911
 
5829
- <!-- <xsl:if test="$namespace = 'iho'">
5830
- <xsl:if test="ancestor::iho:td">
5831
- <xsl:attribute name="font-size">12pt</xsl:attribute>
5832
- </xsl:if>
5833
- </xsl:if> -->
5834
-
5835
5912
  <fo:block>
5836
5913
 
5837
5914
  <fo:inline xsl:use-attribute-sets="note-name-style">
@@ -5999,7 +6076,7 @@
5999
6076
  <xsl:template match="*[local-name() = 'figure']" name="figure">
6000
6077
  <xsl:variable name="isAdded" select="@added"/>
6001
6078
  <xsl:variable name="isDeleted" select="@deleted"/>
6002
- <fo:block-container id="{@id}">
6079
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6003
6080
 
6004
6081
  <xsl:call-template name="setTrackChangesStyles">
6005
6082
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -6335,6 +6412,31 @@
6335
6412
  <xsl:apply-templates mode="svg_update"/>
6336
6413
  </xsl:copy>
6337
6414
  </xsl:template>
6415
+
6416
+ <!-- regex for 'display: inline-block;' -->
6417
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
6418
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
6419
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
6420
+ </xsl:template>
6421
+
6422
+ <!-- replace
6423
+ stroke="rgba(r, g, b, alpha)" to
6424
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
6425
+ fill="rgba(r, g, b, alpha)" to
6426
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
6427
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
6428
+ <xsl:variable name="components_">
6429
+ <xsl:call-template name="split">
6430
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
6431
+ <xsl:with-param name="sep" select="','"/>
6432
+ </xsl:call-template>
6433
+ </xsl:variable>
6434
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
6435
+ <xsl:variable name="att_name" select="local-name()"/>
6436
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
6437
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
6438
+ </xsl:template>
6439
+
6338
6440
  <!-- ============== -->
6339
6441
  <!-- END: svg_update -->
6340
6442
  <!-- ============== -->
@@ -6960,7 +7062,13 @@
6960
7062
  </xsl:template>
6961
7063
 
6962
7064
  <xsl:template match="text()" mode="contents_item">
6963
- <xsl:call-template name="keep_together_standard_number"/>
7065
+ <xsl:variable name="text">
7066
+ <!-- to split by '_' and other chars -->
7067
+ <text><xsl:call-template name="add-zero-spaces-java"/></text>
7068
+ </xsl:variable>
7069
+ <xsl:for-each select="xalan:nodeset($text)/text/text()">
7070
+ <xsl:call-template name="keep_together_standard_number"/>
7071
+ </xsl:for-each>
6964
7072
  </xsl:template>
6965
7073
 
6966
7074
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
@@ -6971,35 +7079,53 @@
6971
7079
  <!-- =============== -->
6972
7080
  <!-- sourcecode -->
6973
7081
  <!-- =============== -->
6974
- <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6975
7082
 
6976
- <xsl:variable name="sourcecode_attributes">
6977
- <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
6978
- <xsl:variable name="_font-size">
7083
+ <xsl:variable name="source-highlighter-css_" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'source-highlighter-css']"/>
7084
+ <xsl:variable name="sourcecode_css_" select="java:org.metanorma.fop.Util.parseCSS($source-highlighter-css_)"/>
7085
+ <xsl:variable name="sourcecode_css" select="xalan:nodeset($sourcecode_css_)"/>
6979
7086
 
6980
- 10
6981
- <!-- 9 -->
7087
+ <xsl:template match="*[local-name() = 'property']" mode="css">
7088
+ <xsl:attribute name="{@name}">
7089
+ <xsl:value-of select="@value"/>
7090
+ </xsl:attribute>
7091
+ </xsl:template>
6982
7092
 
6983
- <!-- <xsl:if test="$namespace = 'ieee'">
6984
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
6985
- </xsl:if> -->
7093
+ <xsl:template name="get_sourcecode_attributes">
7094
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
7095
+ <xsl:variable name="_font-size">
6986
7096
 
6987
- </xsl:variable>
7097
+ 9.5
7098
+ <!-- inherit -->
6988
7099
 
6989
- <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
6990
- <xsl:if test="$font-size != ''">
6991
- <xsl:attribute name="font-size">
6992
- <xsl:choose>
6993
- <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6994
- <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6995
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6996
- <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6997
- </xsl:choose>
6998
- </xsl:attribute>
6999
- </xsl:if>
7000
- </xsl:element>
7100
+ <!-- <xsl:if test="$namespace = 'ieee'">
7101
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
7102
+ </xsl:if> -->
7103
+
7104
+ </xsl:variable>
7105
+
7106
+ <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
7107
+ <xsl:if test="$font-size != ''">
7108
+ <xsl:attribute name="font-size">
7109
+ <xsl:choose>
7110
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
7111
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
7112
+ <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
7113
+ <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
7114
+ </xsl:choose>
7115
+ </xsl:attribute>
7116
+ </xsl:if>
7117
+ <xsl:apply-templates select="$sourcecode_css//class[@name = 'sourcecode']" mode="css"/>
7118
+ </xsl:element>
7119
+ </xsl:template>
7120
+
7121
+ <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
7122
+
7123
+ <xsl:variable name="sourcecode_attributes">
7124
+ <xsl:call-template name="get_sourcecode_attributes"/>
7001
7125
  </xsl:variable>
7002
7126
 
7127
+ <!-- <xsl:copy-of select="$sourcecode_css"/> -->
7128
+
7003
7129
  <xsl:choose>
7004
7130
  <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
7005
7131
  <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
@@ -7053,9 +7179,10 @@
7053
7179
  </xsl:choose>
7054
7180
  </xsl:template>
7055
7181
 
7056
- <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
7182
+ <xsl:template match="*[local-name()='sourcecode']/text() | *[local-name()='sourcecode']//*[local-name()='span']/text()" priority="2">
7057
7183
  <xsl:choose>
7058
- <xsl:when test="normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
7184
+ <!-- disabled -->
7185
+ <xsl:when test="1 = 2 and normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
7059
7186
  <xsl:variable name="syntax" select="java:org.metanorma.fop.Util.syntaxHighlight(., ../@lang)"/>
7060
7187
  <xsl:choose>
7061
7188
  <xsl:when test="normalize-space($syntax) != ''"><!-- if there is highlighted result -->
@@ -7070,8 +7197,75 @@
7070
7197
  <xsl:call-template name="add_spaces_to_sourcecode"/>
7071
7198
  </xsl:otherwise>
7072
7199
  </xsl:choose>
7200
+ </xsl:template>
7073
7201
 
7202
+ <!-- add sourcecode highlighting -->
7203
+ <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
7204
+ <xsl:variable name="class" select="@class"/>
7205
+ <xsl:choose>
7206
+ <xsl:when test="$sourcecode_css//class[@name = $class]">
7207
+ <fo:inline>
7208
+ <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
7209
+ <xsl:apply-templates/>
7210
+ </fo:inline>
7211
+ </xsl:when>
7212
+ <xsl:otherwise>
7213
+ <xsl:apply-templates/>
7214
+ </xsl:otherwise>
7215
+ </xsl:choose>
7216
+ </xsl:template>
7217
+
7218
+ <!-- outer table with line numbers for sourcecode -->
7219
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
7220
+ <fo:block>
7221
+ <fo:table width="100%" table-layout="fixed">
7222
+ <xsl:copy-of select="@id"/>
7223
+ <fo:table-column column-width="8%"/>
7224
+ <fo:table-column column-width="92%"/>
7225
+ <fo:table-body>
7226
+ <xsl:apply-templates/>
7227
+ </fo:table-body>
7228
+ </fo:table>
7229
+ </fo:block>
7230
+ </xsl:template>
7231
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
7232
+ <xsl:apply-templates/>
7233
+ </xsl:template>
7234
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
7235
+ <fo:table-row>
7236
+ <xsl:apply-templates/>
7237
+ </fo:table-row>
7074
7238
  </xsl:template>
7239
+ <!-- first td with line numbers -->
7240
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
7241
+ <fo:table-cell>
7242
+ <fo:block>
7243
+
7244
+ <!-- set attibutes for line numbers - same as sourcecode -->
7245
+ <xsl:variable name="sourcecode_attributes">
7246
+ <xsl:for-each select="following-sibling::*[local-name() = 'td']/*[local-name() = 'sourcecode']">
7247
+ <xsl:call-template name="get_sourcecode_attributes"/>
7248
+ </xsl:for-each>
7249
+ </xsl:variable>
7250
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*[not(starts-with(local-name(), 'margin-') or starts-with(local-name(), 'space-'))]">
7251
+ <xsl:attribute name="{local-name()}">
7252
+ <xsl:value-of select="."/>
7253
+ </xsl:attribute>
7254
+ </xsl:for-each>
7255
+
7256
+ <xsl:apply-templates/>
7257
+ </fo:block>
7258
+ </fo:table-cell>
7259
+ </xsl:template>
7260
+ <!-- second td with sourcecode -->
7261
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
7262
+ <fo:table-cell>
7263
+ <fo:block>
7264
+ <xsl:apply-templates/>
7265
+ </fo:block>
7266
+ </fo:table-cell>
7267
+ </xsl:template>
7268
+ <!-- END outer table with line numbers for sourcecode -->
7075
7269
 
7076
7270
  <xsl:template name="add_spaces_to_sourcecode">
7077
7271
  <xsl:variable name="text_step1">
@@ -8727,7 +8921,11 @@
8727
8921
 
8728
8922
  <fo:list-block id="{@id}" xsl:use-attribute-sets="bibitem-normative-list-style">
8729
8923
 
8730
- <xsl:variable name="docidentifier" select="normalize-space(iho:docidentifier[@type != 'metanorma'][1])"/>
8924
+ <xsl:variable name="docidentifier">
8925
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
8926
+ <xsl:with-param name="biblio_tag_part">first</xsl:with-param>
8927
+ </xsl:apply-templates>
8928
+ </xsl:variable>
8731
8929
 
8732
8930
  <xsl:attribute name="provisional-distance-between-starts">
8733
8931
  <xsl:choose>
@@ -8742,15 +8940,15 @@
8742
8940
  <fo:list-item-label end-indent="label-end()">
8743
8941
  <fo:block>
8744
8942
  <fo:inline>
8745
-
8746
- <xsl:value-of select="$docidentifier"/>
8747
-
8943
+ <xsl:copy-of select="$docidentifier"/>
8748
8944
  </fo:inline>
8749
8945
  </fo:block>
8750
8946
  </fo:list-item-label>
8751
8947
  <fo:list-item-body start-indent="body-start()">
8752
8948
  <fo:block xsl:use-attribute-sets="bibitem-normative-list-body-style">
8753
- <xsl:call-template name="processBibitem"/>
8949
+ <xsl:call-template name="processBibitem">
8950
+ <xsl:with-param name="biblio_tag_part">last</xsl:with-param>
8951
+ </xsl:call-template>
8754
8952
  </fo:block>
8755
8953
  </fo:list-item-body>
8756
8954
  </fo:list-item>
@@ -8766,158 +8964,51 @@
8766
8964
  </xsl:template> <!-- references[not(@normative='true')]/bibitem -->
8767
8965
 
8768
8966
  <xsl:template name="processBibitem">
8967
+ <xsl:param name="biblio_tag_part">both</xsl:param>
8769
8968
 
8770
- <!-- start IHO bibitem processing -->
8771
- <xsl:apply-templates select="iho:formattedref"/>
8772
- <!-- end IHO bibitem processing -->
8969
+ <!-- start bibitem processing -->
8970
+ <xsl:if test=".//*[local-name() = 'fn']">
8971
+ <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
8972
+ </xsl:if>
8973
+
8974
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
8975
+ <xsl:with-param name="biblio_tag_part" select="$biblio_tag_part"/>
8976
+ </xsl:apply-templates>
8977
+ <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
8978
+ <!-- end bibitem processing -->
8773
8979
 
8774
8980
  </xsl:template> <!-- processBibitem (bibitem) -->
8775
8981
 
8776
- <xsl:template name="processBibitemDocId">
8777
- <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
8778
- <xsl:choose>
8779
- <xsl:when test="normalize-space($_doc_ident) != ''">
8780
- <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
8781
- <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
8782
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
8783
- </xsl:if> -->
8784
- <xsl:value-of select="$_doc_ident"/>
8785
- </xsl:when>
8786
- <xsl:otherwise>
8787
- <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
8788
- <xsl:if test="$type != ''">
8789
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
8790
- </xsl:if> -->
8791
- <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma') and not(@type = 'metanorma-ordinal')]"/>
8792
- </xsl:otherwise>
8793
- </xsl:choose>
8794
- </xsl:template> <!-- processBibitemDocId -->
8982
+ <xsl:template match="*[local-name() = 'title']" mode="title">
8983
+ <fo:inline><xsl:apply-templates/></fo:inline>
8984
+ </xsl:template>
8985
+
8986
+ <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
8987
+
8988
+ <xsl:template match="*[local-name() = 'formattedref']">
8989
+ <!-- <xsl:if test="$namespace = 'unece' or $namespace = 'unece-rec'">
8990
+ <xsl:text>, </xsl:text>
8991
+ </xsl:if> -->
8992
+ <xsl:apply-templates/>
8993
+ </xsl:template>
8795
8994
 
8796
- <xsl:template name="processPersonalAuthor">
8995
+ <xsl:template match="*[local-name() = 'biblio-tag']">
8996
+ <xsl:param name="biblio_tag_part">both</xsl:param>
8797
8997
  <xsl:choose>
8798
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'completename']">
8799
- <author>
8800
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'completename']"/>
8801
- </author>
8802
- </xsl:when>
8803
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'initial']">
8804
- <author>
8805
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
8806
- <xsl:text> </xsl:text>
8807
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'initial']" mode="strip"/>
8808
- </author>
8998
+ <xsl:when test="$biblio_tag_part = 'first' and *[local-name() = 'tab']">
8999
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
8809
9000
  </xsl:when>
8810
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'forename']">
8811
- <author>
8812
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
8813
- <xsl:text> </xsl:text>
8814
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'forename']" mode="strip"/>
8815
- </author>
9001
+ <xsl:when test="$biblio_tag_part = 'last'">
9002
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/following-sibling::node()"/>
8816
9003
  </xsl:when>
8817
9004
  <xsl:otherwise>
8818
9005
  <xsl:apply-templates/>
8819
9006
  </xsl:otherwise>
8820
9007
  </xsl:choose>
8821
- </xsl:template> <!-- processPersonalAuthor -->
8822
-
8823
- <xsl:template name="renderDate">
8824
- <xsl:if test="normalize-space(*[local-name() = 'on']) != ''">
8825
- <xsl:value-of select="*[local-name() = 'on']"/>
8826
- </xsl:if>
8827
- <xsl:if test="normalize-space(*[local-name() = 'from']) != ''">
8828
- <xsl:value-of select="concat(*[local-name() = 'from'], '–', *[local-name() = 'to'])"/>
8829
- </xsl:if>
8830
- </xsl:template>
8831
-
8832
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'initial']/text()" mode="strip">
8833
- <xsl:value-of select="translate(.,'. ','')"/>
8834
- </xsl:template>
8835
-
8836
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
8837
- <xsl:value-of select="substring(.,1,1)"/>
8838
- </xsl:template>
8839
-
8840
- <xsl:template match="*[local-name() = 'title']" mode="title">
8841
- <fo:inline><xsl:apply-templates/></fo:inline>
8842
9008
  </xsl:template>
8843
9009
 
8844
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'title']" priority="2">
8845
- <!-- <fo:inline><xsl:apply-templates /></fo:inline> -->
8846
- <fo:inline font-style="italic"> <!-- BIPM BSI CSD CSA GB IEC IHO ISO ITU JCGM -->
8847
- <xsl:apply-templates/>
8848
- </fo:inline>
8849
- </xsl:template>
8850
-
8851
- <!-- bibitem/note renders as footnote -->
8852
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
8853
-
8854
- <!-- list of footnotes to calculate actual footnotes number -->
8855
- <xsl:variable name="p_fn_">
8856
- <xsl:call-template name="get_fn_list"/>
8857
- </xsl:variable>
8858
- <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
8859
- <xsl:variable name="gen_id" select="generate-id(.)"/>
8860
- <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
8861
- <!-- fn sequence number in document -->
8862
- <xsl:variable name="current_fn_number">
8863
- <xsl:choose>
8864
- <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
8865
- <xsl:otherwise>
8866
- <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
8867
- <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
8868
- </xsl:otherwise>
8869
- </xsl:choose>
8870
- </xsl:variable>
8871
- <fo:footnote>
8872
- <xsl:variable name="number">
8873
-
8874
- <xsl:value-of select="$current_fn_number"/>
8875
-
8876
- </xsl:variable>
8877
-
8878
- <xsl:variable name="current_fn_number_text">
8879
- <xsl:value-of select="$number"/>
8880
-
8881
- <xsl:text>)</xsl:text>
8882
-
8883
- </xsl:variable>
8884
-
8885
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
8886
- <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
8887
- <xsl:value-of select="$current_fn_number_text"/>
8888
- </fo:basic-link>
8889
- </fo:inline>
8890
- <fo:footnote-body>
8891
- <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
8892
- <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
8893
- <xsl:value-of select="$current_fn_number_text"/>
8894
- </fo:inline>
8895
- <xsl:apply-templates/>
8896
- </fo:block>
8897
- </fo:footnote-body>
8898
- </fo:footnote>
8899
- </xsl:template>
8900
-
8901
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'edition']"> <!-- for iho -->
8902
- <xsl:text> edition </xsl:text>
8903
- <xsl:value-of select="."/>
8904
- </xsl:template>
8905
-
8906
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'uri']"> <!-- for iho -->
8907
- <xsl:text> (</xsl:text>
8908
- <fo:inline xsl:use-attribute-sets="link-style">
8909
- <fo:basic-link external-destination="." fox:alt-text=".">
8910
- <xsl:value-of select="."/>
8911
- </fo:basic-link>
8912
- </fo:inline>
8913
- <xsl:text>)</xsl:text>
8914
- </xsl:template>
8915
-
8916
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
8917
-
8918
- <xsl:template match="*[local-name() = 'formattedref']">
8919
-
8920
- <xsl:apply-templates/>
9010
+ <xsl:template match="*[local-name() = 'biblio-tag']/*[local-name() = 'tab']" priority="2">
9011
+ <xsl:text> </xsl:text>
8921
9012
  </xsl:template>
8922
9013
 
8923
9014
  <!-- ======================= -->
@@ -9247,7 +9338,9 @@
9247
9338
  <!-- Update xml -->
9248
9339
  <!-- ===================================== -->
9249
9340
  <!-- =========================================================================== -->
9250
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9341
+ <!-- STEP1: -->
9342
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
9343
+ <!-- - Ignore 'span' without style -->
9251
9344
  <!-- =========================================================================== -->
9252
9345
  <xsl:template match="@*|node()" mode="update_xml_step1">
9253
9346
  <xsl:copy>
@@ -9330,7 +9423,8 @@
9330
9423
  </xsl:copy>
9331
9424
  </xsl:template>
9332
9425
 
9333
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
9426
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
9427
+ <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">
9334
9428
  <xsl:copy>
9335
9429
  <xsl:copy-of select="@*"/>
9336
9430
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -9340,6 +9434,12 @@
9340
9434
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9341
9435
  <xsl:apply-templates mode="update_xml_step1"/>
9342
9436
  </xsl:template>
9437
+ <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
9438
+ <xsl:copy>
9439
+ <xsl:copy-of select="@*"/>
9440
+ <xsl:apply-templates mode="update_xml_step1"/>
9441
+ </xsl:copy>
9442
+ </xsl:template>
9343
9443
  <!-- =========================================================================== -->
9344
9444
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9345
9445
  <!-- =========================================================================== -->
@@ -9820,6 +9920,10 @@
9820
9920
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
9821
9921
  </xsl:template>
9822
9922
 
9923
+ <xsl:template name="getDocumentId_fromCurrentNode">
9924
+ <xsl:call-template name="getLang_fromCurrentNode"/><xsl:value-of select=".//*[local-name() = 'p'][1]/@id"/>
9925
+ </xsl:template>
9926
+
9823
9927
  <xsl:template name="namespaceCheck">
9824
9928
  <xsl:variable name="documentNS" select="namespace-uri(/*)"/>
9825
9929
  <xsl:variable name="XSLNS">