metanorma-un 0.9.13 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1519,6 +1519,12 @@
1519
1519
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1520
1520
  </xsl:attribute-set>
1521
1521
 
1522
+ <xsl:attribute-set name="figure-block-style">
1523
+
1524
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1525
+
1526
+ </xsl:attribute-set>
1527
+
1522
1528
  <xsl:attribute-set name="figure-style">
1523
1529
 
1524
1530
  </xsl:attribute-set>
@@ -1526,7 +1532,7 @@
1526
1532
  <xsl:attribute-set name="figure-name-style">
1527
1533
 
1528
1534
  <xsl:attribute name="text-align">center</xsl:attribute>
1529
- <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1535
+ <xsl:attribute name="space-after">6pt</xsl:attribute>
1530
1536
  <xsl:attribute name="keep-with-previous">always</xsl:attribute>
1531
1537
 
1532
1538
  </xsl:attribute-set>
@@ -2926,6 +2932,10 @@
2926
2932
  <xsl:with-param name="continued">true</xsl:with-param>
2927
2933
  </xsl:apply-templates>
2928
2934
 
2935
+ <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
2936
+ <fo:block/>
2937
+ </xsl:if>
2938
+
2929
2939
  </fo:table-cell>
2930
2940
  </fo:table-row>
2931
2941
  </xsl:template> <!-- table-header-title -->
@@ -3318,7 +3328,26 @@
3318
3328
 
3319
3329
  <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
3320
3330
  <xsl:variable name="footnote_inline">
3321
- <fo:inline xsl:use-attribute-sets="fn-num-style">
3331
+ <fo:inline>
3332
+
3333
+ <xsl:variable name="fn_styles">
3334
+ <xsl:choose>
3335
+ <xsl:when test="ancestor::*[local-name() = 'bibitem']">
3336
+ <fn_styles xsl:use-attribute-sets="bibitem-note-fn-style"/>
3337
+ </xsl:when>
3338
+ <xsl:otherwise>
3339
+ <fn_styles xsl:use-attribute-sets="fn-num-style"/>
3340
+ </xsl:otherwise>
3341
+ </xsl:choose>
3342
+ </xsl:variable>
3343
+
3344
+ <xsl:for-each select="xalan:nodeset($fn_styles)/fn_styles/@*">
3345
+ <xsl:copy-of select="."/>
3346
+ </xsl:for-each>
3347
+
3348
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
3349
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
3350
+ </xsl:if>
3322
3351
 
3323
3352
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3324
3353
  <xsl:value-of select="$current_fn_number_text"/>
@@ -3378,7 +3407,10 @@
3378
3407
  </xsl:for-each>
3379
3408
  <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']/*">
3380
3409
  <xsl:sort select="@displayorder" data-type="number"/>
3381
- <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])]">
3410
+ <!-- commented:
3411
+ .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
3412
+ because 'fn' there is in biblio-tag -->
3413
+ <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])]">
3382
3414
  <!-- copy unique fn -->
3383
3415
  <fn gen_id="{generate-id(.)}">
3384
3416
  <xsl:copy-of select="@*"/>
@@ -4227,7 +4259,7 @@
4227
4259
 
4228
4260
  <xsl:variable name="_font-size">
4229
4261
 
4230
- <!-- 10 -->
4262
+ <!-- inherit -->
4231
4263
 
4232
4264
  </xsl:variable>
4233
4265
  <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
@@ -4468,6 +4500,23 @@
4468
4500
  <xsl:apply-templates/>
4469
4501
  </xsl:template>
4470
4502
 
4503
+ <!-- Don't break standard's numbers -->
4504
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
4505
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
4506
+ <xsl:choose>
4507
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
4508
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
4509
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
4510
+ </xsl:when>
4511
+ <xsl:otherwise>
4512
+ <xsl:apply-templates/>
4513
+ </xsl:otherwise>
4514
+ </xsl:choose>
4515
+ </xsl:template>
4516
+ <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">
4517
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
4518
+ </xsl:template>
4519
+
4471
4520
  <!-- ========================= -->
4472
4521
  <!-- END Rich text formatting -->
4473
4522
  <!-- ========================= -->
@@ -4863,7 +4912,7 @@
4863
4912
  <xsl:choose>
4864
4913
  <xsl:when test="@colspan">
4865
4914
  <xsl:variable name="td">
4866
- <xsl:element name="td">
4915
+ <xsl:element name="{local-name()}">
4867
4916
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
4868
4917
  <xsl:if test="local-name()='th'">
4869
4918
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -4878,7 +4927,7 @@
4878
4927
  </xsl:call-template>
4879
4928
  </xsl:when>
4880
4929
  <xsl:otherwise>
4881
- <xsl:element name="td">
4930
+ <xsl:element name="{local-name()}">
4882
4931
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
4883
4932
  <xsl:if test="local-name()='th'">
4884
4933
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -4945,7 +4994,7 @@
4945
4994
  <xsl:variable name="currentRow" select="."/>
4946
4995
 
4947
4996
  <xsl:variable name="normalizedTDs">
4948
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
4997
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
4949
4998
  <xsl:choose>
4950
4999
  <xsl:when test="@rowspan &gt; 1">
4951
5000
  <xsl:copy>
@@ -4957,7 +5006,7 @@
4957
5006
  </xsl:copy>
4958
5007
  </xsl:when>
4959
5008
  <xsl:otherwise>
4960
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
5009
+ <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)])]"/>
4961
5010
  </xsl:otherwise>
4962
5011
  </xsl:choose>
4963
5012
  </xsl:for-each>
@@ -5178,6 +5227,33 @@
5178
5227
  </xsl:choose>
5179
5228
  </xsl:template>
5180
5229
 
5230
+ <xsl:template name="getLang_fromCurrentNode">
5231
+ <xsl:variable name="language_current" select="normalize-space(.//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5232
+ <xsl:variable name="language">
5233
+ <xsl:choose>
5234
+ <xsl:when test="$language_current != ''">
5235
+ <xsl:value-of select="$language_current"/>
5236
+ </xsl:when>
5237
+ <xsl:otherwise>
5238
+ <xsl:variable name="language_current_2" select="normalize-space(xalan:nodeset($bibdata)//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5239
+ <xsl:choose>
5240
+ <xsl:when test="$language_current_2 != ''">
5241
+ <xsl:value-of select="$language_current_2"/>
5242
+ </xsl:when>
5243
+ <xsl:otherwise>
5244
+ <xsl:value-of select=".//*[local-name()='bibdata']//*[local-name()='language']"/>
5245
+ </xsl:otherwise>
5246
+ </xsl:choose>
5247
+ </xsl:otherwise>
5248
+ </xsl:choose>
5249
+ </xsl:variable>
5250
+
5251
+ <xsl:choose>
5252
+ <xsl:when test="$language = 'English'">en</xsl:when>
5253
+ <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
5254
+ </xsl:choose>
5255
+ </xsl:template>
5256
+
5181
5257
  <xsl:template name="capitalizeWords">
5182
5258
  <xsl:param name="str"/>
5183
5259
  <xsl:variable name="str2" select="translate($str, '-', ' ')"/>
@@ -5632,12 +5708,6 @@
5632
5708
 
5633
5709
  <fo:block-container margin-left="0mm">
5634
5710
 
5635
- <!-- <xsl:if test="$namespace = 'iho'">
5636
- <xsl:if test="ancestor::iho:td">
5637
- <xsl:attribute name="font-size">12pt</xsl:attribute>
5638
- </xsl:if>
5639
- </xsl:if> -->
5640
-
5641
5711
  <fo:block>
5642
5712
 
5643
5713
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -5816,7 +5886,7 @@
5816
5886
  <xsl:template match="*[local-name() = 'figure']" name="figure">
5817
5887
  <xsl:variable name="isAdded" select="@added"/>
5818
5888
  <xsl:variable name="isDeleted" select="@deleted"/>
5819
- <fo:block-container id="{@id}">
5889
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
5820
5890
 
5821
5891
  <xsl:call-template name="setTrackChangesStyles">
5822
5892
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -6152,6 +6222,31 @@
6152
6222
  <xsl:apply-templates mode="svg_update"/>
6153
6223
  </xsl:copy>
6154
6224
  </xsl:template>
6225
+
6226
+ <!-- regex for 'display: inline-block;' -->
6227
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
6228
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
6229
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
6230
+ </xsl:template>
6231
+
6232
+ <!-- replace
6233
+ stroke="rgba(r, g, b, alpha)" to
6234
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
6235
+ fill="rgba(r, g, b, alpha)" to
6236
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
6237
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
6238
+ <xsl:variable name="components_">
6239
+ <xsl:call-template name="split">
6240
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
6241
+ <xsl:with-param name="sep" select="','"/>
6242
+ </xsl:call-template>
6243
+ </xsl:variable>
6244
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
6245
+ <xsl:variable name="att_name" select="local-name()"/>
6246
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
6247
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
6248
+ </xsl:template>
6249
+
6155
6250
  <!-- ============== -->
6156
6251
  <!-- END: svg_update -->
6157
6252
  <!-- ============== -->
@@ -6777,7 +6872,13 @@
6777
6872
  </xsl:template>
6778
6873
 
6779
6874
  <xsl:template match="text()" mode="contents_item">
6780
- <xsl:call-template name="keep_together_standard_number"/>
6875
+ <xsl:variable name="text">
6876
+ <!-- to split by '_' and other chars -->
6877
+ <text><xsl:call-template name="add-zero-spaces-java"/></text>
6878
+ </xsl:variable>
6879
+ <xsl:for-each select="xalan:nodeset($text)/text/text()">
6880
+ <xsl:call-template name="keep_together_standard_number"/>
6881
+ </xsl:for-each>
6781
6882
  </xsl:template>
6782
6883
 
6783
6884
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
@@ -6788,35 +6889,53 @@
6788
6889
  <!-- =============== -->
6789
6890
  <!-- sourcecode -->
6790
6891
  <!-- =============== -->
6791
- <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6792
6892
 
6793
- <xsl:variable name="sourcecode_attributes">
6794
- <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
6795
- <xsl:variable name="_font-size">
6893
+ <xsl:variable name="source-highlighter-css_" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'source-highlighter-css']"/>
6894
+ <xsl:variable name="sourcecode_css_" select="java:org.metanorma.fop.Util.parseCSS($source-highlighter-css_)"/>
6895
+ <xsl:variable name="sourcecode_css" select="xalan:nodeset($sourcecode_css_)"/>
6796
6896
 
6797
- <!-- 9 -->
6897
+ <xsl:template match="*[local-name() = 'property']" mode="css">
6898
+ <xsl:attribute name="{@name}">
6899
+ <xsl:value-of select="@value"/>
6900
+ </xsl:attribute>
6901
+ </xsl:template>
6798
6902
 
6799
- <!-- <xsl:if test="$namespace = 'ieee'">
6800
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
6801
- </xsl:if> -->
6903
+ <xsl:template name="get_sourcecode_attributes">
6904
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
6905
+ <xsl:variable name="_font-size">
6802
6906
 
6803
- 10
6804
- </xsl:variable>
6907
+ <!-- inherit -->
6805
6908
 
6806
- <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
6807
- <xsl:if test="$font-size != ''">
6808
- <xsl:attribute name="font-size">
6809
- <xsl:choose>
6810
- <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6811
- <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6812
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6813
- <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6814
- </xsl:choose>
6815
- </xsl:attribute>
6816
- </xsl:if>
6817
- </xsl:element>
6909
+ <!-- <xsl:if test="$namespace = 'ieee'">
6910
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
6911
+ </xsl:if> -->
6912
+
6913
+ 10
6914
+ </xsl:variable>
6915
+
6916
+ <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
6917
+ <xsl:if test="$font-size != ''">
6918
+ <xsl:attribute name="font-size">
6919
+ <xsl:choose>
6920
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6921
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6922
+ <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6923
+ <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6924
+ </xsl:choose>
6925
+ </xsl:attribute>
6926
+ </xsl:if>
6927
+ <xsl:apply-templates select="$sourcecode_css//class[@name = 'sourcecode']" mode="css"/>
6928
+ </xsl:element>
6929
+ </xsl:template>
6930
+
6931
+ <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6932
+
6933
+ <xsl:variable name="sourcecode_attributes">
6934
+ <xsl:call-template name="get_sourcecode_attributes"/>
6818
6935
  </xsl:variable>
6819
6936
 
6937
+ <!-- <xsl:copy-of select="$sourcecode_css"/> -->
6938
+
6820
6939
  <xsl:choose>
6821
6940
  <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
6822
6941
  <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
@@ -6870,9 +6989,10 @@
6870
6989
  </xsl:choose>
6871
6990
  </xsl:template>
6872
6991
 
6873
- <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
6992
+ <xsl:template match="*[local-name()='sourcecode']/text() | *[local-name()='sourcecode']//*[local-name()='span']/text()" priority="2">
6874
6993
  <xsl:choose>
6875
- <xsl:when test="normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
6994
+ <!-- disabled -->
6995
+ <xsl:when test="1 = 2 and normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
6876
6996
  <xsl:variable name="syntax" select="java:org.metanorma.fop.Util.syntaxHighlight(., ../@lang)"/>
6877
6997
  <xsl:choose>
6878
6998
  <xsl:when test="normalize-space($syntax) != ''"><!-- if there is highlighted result -->
@@ -6887,8 +7007,75 @@
6887
7007
  <xsl:call-template name="add_spaces_to_sourcecode"/>
6888
7008
  </xsl:otherwise>
6889
7009
  </xsl:choose>
7010
+ </xsl:template>
7011
+
7012
+ <!-- add sourcecode highlighting -->
7013
+ <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
7014
+ <xsl:variable name="class" select="@class"/>
7015
+ <xsl:choose>
7016
+ <xsl:when test="$sourcecode_css//class[@name = $class]">
7017
+ <fo:inline>
7018
+ <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
7019
+ <xsl:apply-templates/>
7020
+ </fo:inline>
7021
+ </xsl:when>
7022
+ <xsl:otherwise>
7023
+ <xsl:apply-templates/>
7024
+ </xsl:otherwise>
7025
+ </xsl:choose>
7026
+ </xsl:template>
7027
+
7028
+ <!-- outer table with line numbers for sourcecode -->
7029
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
7030
+ <fo:block>
7031
+ <fo:table width="100%" table-layout="fixed">
7032
+ <xsl:copy-of select="@id"/>
7033
+ <fo:table-column column-width="8%"/>
7034
+ <fo:table-column column-width="92%"/>
7035
+ <fo:table-body>
7036
+ <xsl:apply-templates/>
7037
+ </fo:table-body>
7038
+ </fo:table>
7039
+ </fo:block>
7040
+ </xsl:template>
7041
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
7042
+ <xsl:apply-templates/>
7043
+ </xsl:template>
7044
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
7045
+ <fo:table-row>
7046
+ <xsl:apply-templates/>
7047
+ </fo:table-row>
7048
+ </xsl:template>
7049
+ <!-- first td with line numbers -->
7050
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
7051
+ <fo:table-cell>
7052
+ <fo:block>
7053
+
7054
+ <!-- set attibutes for line numbers - same as sourcecode -->
7055
+ <xsl:variable name="sourcecode_attributes">
7056
+ <xsl:for-each select="following-sibling::*[local-name() = 'td']/*[local-name() = 'sourcecode']">
7057
+ <xsl:call-template name="get_sourcecode_attributes"/>
7058
+ </xsl:for-each>
7059
+ </xsl:variable>
7060
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*[not(starts-with(local-name(), 'margin-') or starts-with(local-name(), 'space-'))]">
7061
+ <xsl:attribute name="{local-name()}">
7062
+ <xsl:value-of select="."/>
7063
+ </xsl:attribute>
7064
+ </xsl:for-each>
6890
7065
 
7066
+ <xsl:apply-templates/>
7067
+ </fo:block>
7068
+ </fo:table-cell>
6891
7069
  </xsl:template>
7070
+ <!-- second td with sourcecode -->
7071
+ <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
7072
+ <fo:table-cell>
7073
+ <fo:block>
7074
+ <xsl:apply-templates/>
7075
+ </fo:block>
7076
+ </fo:table-cell>
7077
+ </xsl:template>
7078
+ <!-- END outer table with line numbers for sourcecode -->
6892
7079
 
6893
7080
  <xsl:template name="add_spaces_to_sourcecode">
6894
7081
  <xsl:variable name="text_step1">
@@ -8571,160 +8758,53 @@
8571
8758
  </xsl:template> <!-- references[not(@normative='true')]/bibitem -->
8572
8759
 
8573
8760
  <xsl:template name="processBibitem">
8761
+ <xsl:param name="biblio_tag_part">both</xsl:param>
8574
8762
 
8575
8763
  <!-- start UNECE bibitem processing -->
8576
- <fo:inline padding-right="5mm">[<xsl:value-of select="un:docidentifier"/>]</fo:inline><xsl:value-of select="un:docidentifier"/>
8577
- <xsl:text> </xsl:text>
8764
+ <fo:inline padding-right="5mm">
8765
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
8766
+ <xsl:with-param name="biblio_tag_part">first</xsl:with-param>
8767
+ </xsl:apply-templates>
8768
+ </fo:inline>
8769
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
8770
+ <xsl:with-param name="biblio_tag_part">last</xsl:with-param>
8771
+ </xsl:apply-templates>
8772
+
8578
8773
  <xsl:apply-templates select="un:formattedref"/>
8579
8774
  <!-- END UNECE bibitem processing -->
8580
8775
 
8581
8776
  </xsl:template> <!-- processBibitem (bibitem) -->
8582
8777
 
8583
- <xsl:template name="processBibitemDocId">
8584
- <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')]"/>
8585
- <xsl:choose>
8586
- <xsl:when test="normalize-space($_doc_ident) != ''">
8587
- <!-- <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"/>
8588
- <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
8589
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
8590
- </xsl:if> -->
8591
- <xsl:value-of select="$_doc_ident"/>
8592
- </xsl:when>
8593
- <xsl:otherwise>
8594
- <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
8595
- <xsl:if test="$type != ''">
8596
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
8597
- </xsl:if> -->
8598
- <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma') and not(@type = 'metanorma-ordinal')]"/>
8599
- </xsl:otherwise>
8600
- </xsl:choose>
8601
- </xsl:template> <!-- processBibitemDocId -->
8778
+ <xsl:template match="*[local-name() = 'title']" mode="title">
8779
+ <fo:inline><xsl:apply-templates/></fo:inline>
8780
+ </xsl:template>
8781
+
8782
+ <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
8783
+
8784
+ <xsl:template match="*[local-name() = 'formattedref']">
8785
+ <!-- <xsl:if test="$namespace = 'unece' or $namespace = 'unece-rec'">
8786
+ <xsl:text>, </xsl:text>
8787
+ </xsl:if> -->
8788
+ <xsl:apply-templates/>
8789
+ </xsl:template>
8602
8790
 
8603
- <xsl:template name="processPersonalAuthor">
8791
+ <xsl:template match="*[local-name() = 'biblio-tag']">
8792
+ <xsl:param name="biblio_tag_part">both</xsl:param>
8604
8793
  <xsl:choose>
8605
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'completename']">
8606
- <author>
8607
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'completename']"/>
8608
- </author>
8609
- </xsl:when>
8610
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'initial']">
8611
- <author>
8612
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
8613
- <xsl:text> </xsl:text>
8614
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'initial']" mode="strip"/>
8615
- </author>
8794
+ <xsl:when test="$biblio_tag_part = 'first' and *[local-name() = 'tab']">
8795
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
8616
8796
  </xsl:when>
8617
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'forename']">
8618
- <author>
8619
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
8620
- <xsl:text> </xsl:text>
8621
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'forename']" mode="strip"/>
8622
- </author>
8797
+ <xsl:when test="$biblio_tag_part = 'last'">
8798
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/following-sibling::node()"/>
8623
8799
  </xsl:when>
8624
8800
  <xsl:otherwise>
8625
8801
  <xsl:apply-templates/>
8626
8802
  </xsl:otherwise>
8627
8803
  </xsl:choose>
8628
- </xsl:template> <!-- processPersonalAuthor -->
8629
-
8630
- <xsl:template name="renderDate">
8631
- <xsl:if test="normalize-space(*[local-name() = 'on']) != ''">
8632
- <xsl:value-of select="*[local-name() = 'on']"/>
8633
- </xsl:if>
8634
- <xsl:if test="normalize-space(*[local-name() = 'from']) != ''">
8635
- <xsl:value-of select="concat(*[local-name() = 'from'], '–', *[local-name() = 'to'])"/>
8636
- </xsl:if>
8637
- </xsl:template>
8638
-
8639
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'initial']/text()" mode="strip">
8640
- <xsl:value-of select="translate(.,'. ','')"/>
8641
- </xsl:template>
8642
-
8643
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
8644
- <xsl:value-of select="substring(.,1,1)"/>
8645
- </xsl:template>
8646
-
8647
- <xsl:template match="*[local-name() = 'title']" mode="title">
8648
- <fo:inline><xsl:apply-templates/></fo:inline>
8649
- </xsl:template>
8650
-
8651
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'title']" priority="2">
8652
- <!-- <fo:inline><xsl:apply-templates /></fo:inline> -->
8653
- <fo:inline font-style="italic"> <!-- BIPM BSI CSD CSA GB IEC IHO ISO ITU JCGM -->
8654
- <xsl:apply-templates/>
8655
- </fo:inline>
8656
- </xsl:template>
8657
-
8658
- <!-- bibitem/note renders as footnote -->
8659
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
8660
-
8661
- <!-- list of footnotes to calculate actual footnotes number -->
8662
- <xsl:variable name="p_fn_">
8663
- <xsl:call-template name="get_fn_list"/>
8664
- </xsl:variable>
8665
- <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
8666
- <xsl:variable name="gen_id" select="generate-id(.)"/>
8667
- <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
8668
- <!-- fn sequence number in document -->
8669
- <xsl:variable name="current_fn_number">
8670
- <xsl:choose>
8671
- <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
8672
- <xsl:otherwise>
8673
- <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
8674
- <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
8675
- </xsl:otherwise>
8676
- </xsl:choose>
8677
- </xsl:variable>
8678
- <fo:footnote>
8679
- <xsl:variable name="number">
8680
-
8681
- <xsl:value-of select="$current_fn_number"/>
8682
-
8683
- </xsl:variable>
8684
-
8685
- <xsl:variable name="current_fn_number_text">
8686
- <xsl:value-of select="$number"/>
8687
-
8688
- </xsl:variable>
8689
-
8690
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
8691
- <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
8692
- <xsl:value-of select="$current_fn_number_text"/>
8693
- </fo:basic-link>
8694
- </fo:inline>
8695
- <fo:footnote-body>
8696
- <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
8697
- <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
8698
- <xsl:value-of select="$current_fn_number_text"/>
8699
- </fo:inline>
8700
- <xsl:apply-templates/>
8701
- </fo:block>
8702
- </fo:footnote-body>
8703
- </fo:footnote>
8704
- </xsl:template>
8705
-
8706
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'edition']"> <!-- for iho -->
8707
- <xsl:text> edition </xsl:text>
8708
- <xsl:value-of select="."/>
8709
- </xsl:template>
8710
-
8711
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'uri']"> <!-- for iho -->
8712
- <xsl:text> (</xsl:text>
8713
- <fo:inline xsl:use-attribute-sets="link-style">
8714
- <fo:basic-link external-destination="." fox:alt-text=".">
8715
- <xsl:value-of select="."/>
8716
- </fo:basic-link>
8717
- </fo:inline>
8718
- <xsl:text>)</xsl:text>
8719
8804
  </xsl:template>
8720
8805
 
8721
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
8722
-
8723
- <xsl:template match="*[local-name() = 'formattedref']">
8724
-
8725
- <xsl:text>, </xsl:text>
8726
-
8727
- <xsl:apply-templates/>
8806
+ <xsl:template match="*[local-name() = 'biblio-tag']/*[local-name() = 'tab']" priority="2">
8807
+ <xsl:text> </xsl:text>
8728
8808
  </xsl:template>
8729
8809
 
8730
8810
  <!-- ======================= -->
@@ -9061,7 +9141,9 @@
9061
9141
  <!-- Update xml -->
9062
9142
  <!-- ===================================== -->
9063
9143
  <!-- =========================================================================== -->
9064
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9144
+ <!-- STEP1: -->
9145
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
9146
+ <!-- - Ignore 'span' without style -->
9065
9147
  <!-- =========================================================================== -->
9066
9148
  <xsl:template match="@*|node()" mode="update_xml_step1">
9067
9149
  <xsl:copy>
@@ -9144,7 +9226,8 @@
9144
9226
  </xsl:copy>
9145
9227
  </xsl:template>
9146
9228
 
9147
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
9229
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
9230
+ <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">
9148
9231
  <xsl:copy>
9149
9232
  <xsl:copy-of select="@*"/>
9150
9233
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -9154,6 +9237,12 @@
9154
9237
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9155
9238
  <xsl:apply-templates mode="update_xml_step1"/>
9156
9239
  </xsl:template>
9240
+ <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
9241
+ <xsl:copy>
9242
+ <xsl:copy-of select="@*"/>
9243
+ <xsl:apply-templates mode="update_xml_step1"/>
9244
+ </xsl:copy>
9245
+ </xsl:template>
9157
9246
  <!-- =========================================================================== -->
9158
9247
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9159
9248
  <!-- =========================================================================== -->
@@ -9634,6 +9723,10 @@
9634
9723
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
9635
9724
  </xsl:template>
9636
9725
 
9726
+ <xsl:template name="getDocumentId_fromCurrentNode">
9727
+ <xsl:call-template name="getLang_fromCurrentNode"/><xsl:value-of select=".//*[local-name() = 'p'][1]/@id"/>
9728
+ </xsl:template>
9729
+
9637
9730
  <xsl:template name="namespaceCheck">
9638
9731
  <xsl:variable name="documentNS" select="namespace-uri(/*)"/>
9639
9732
  <xsl:variable name="XSLNS">