metanorma-un 0.10.0 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  <xsl:output version="1.0" method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
- <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"/>
5
+ <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'])) and not(ancestor::*[local-name() = 'bibdata'] and ancestor::*[local-name() = 'abstract'])]" use="@reference"/>
6
6
 
7
7
  <xsl:variable name="debug">false</xsl:variable>
8
8
 
@@ -645,7 +645,7 @@
645
645
  <!-- ============================ -->
646
646
 
647
647
  <xsl:template match="un:figure" priority="2">
648
- <fo:block-container id="{@id}">
648
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
649
649
  <fo:block>
650
650
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
651
651
  </fo:block>
@@ -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>
@@ -1555,6 +1561,7 @@
1555
1561
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1556
1562
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1557
1563
  <xsl:attribute name="border">2pt solid black</xsl:attribute>
1564
+ <xsl:attribute name="text-indent">0</xsl:attribute>
1558
1565
 
1559
1566
  </xsl:attribute-set>
1560
1567
 
@@ -2926,6 +2933,10 @@
2926
2933
  <xsl:with-param name="continued">true</xsl:with-param>
2927
2934
  </xsl:apply-templates>
2928
2935
 
2936
+ <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
2937
+ <fo:block/>
2938
+ </xsl:if>
2939
+
2929
2940
  </fo:table-cell>
2930
2941
  </fo:table-row>
2931
2942
  </xsl:template> <!-- table-header-title -->
@@ -3287,7 +3298,7 @@
3287
3298
  </fn>
3288
3299
  -->
3289
3300
  <!-- footnotes in text (title, bibliography, main body, table's, figure's names), not for tables, figures -->
3290
- <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" priority="2" name="fn">
3301
+ <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" priority="2" name="fn">
3291
3302
 
3292
3303
  <!-- list of footnotes to calculate actual footnotes number -->
3293
3304
  <xsl:variable name="p_fn_">
@@ -3318,7 +3329,22 @@
3318
3329
 
3319
3330
  <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
3320
3331
  <xsl:variable name="footnote_inline">
3321
- <fo:inline xsl:use-attribute-sets="fn-num-style">
3332
+ <fo:inline>
3333
+
3334
+ <xsl:variable name="fn_styles">
3335
+ <xsl:choose>
3336
+ <xsl:when test="ancestor::*[local-name() = 'bibitem']">
3337
+ <fn_styles xsl:use-attribute-sets="bibitem-note-fn-style"/>
3338
+ </xsl:when>
3339
+ <xsl:otherwise>
3340
+ <fn_styles xsl:use-attribute-sets="fn-num-style"/>
3341
+ </xsl:otherwise>
3342
+ </xsl:choose>
3343
+ </xsl:variable>
3344
+
3345
+ <xsl:for-each select="xalan:nodeset($fn_styles)/fn_styles/@*">
3346
+ <xsl:copy-of select="."/>
3347
+ </xsl:for-each>
3322
3348
 
3323
3349
  <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
3324
3350
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
@@ -3329,8 +3355,7 @@
3329
3355
  </fo:basic-link>
3330
3356
  </fo:inline>
3331
3357
  </xsl:variable>
3332
- <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
3333
- gen_id=<xsl:value-of select="$gen_id"/> -->
3358
+
3334
3359
  <xsl:choose>
3335
3360
  <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
3336
3361
  <xsl:copy-of select="$footnote_inline"/>
@@ -3382,7 +3407,10 @@
3382
3407
  </xsl:for-each>
3383
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']/*">
3384
3409
  <xsl:sort select="@displayorder" data-type="number"/>
3385
- <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])]">
3386
3414
  <!-- copy unique fn -->
3387
3415
  <fn gen_id="{generate-id(.)}">
3388
3416
  <xsl:copy-of select="@*"/>
@@ -4231,7 +4259,7 @@
4231
4259
 
4232
4260
  <xsl:variable name="_font-size">
4233
4261
 
4234
- <!-- 10 -->
4262
+ <!-- inherit -->
4235
4263
 
4236
4264
  </xsl:variable>
4237
4265
  <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
@@ -5199,6 +5227,33 @@
5199
5227
  </xsl:choose>
5200
5228
  </xsl:template>
5201
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
+
5202
5257
  <xsl:template name="capitalizeWords">
5203
5258
  <xsl:param name="str"/>
5204
5259
  <xsl:variable name="str2" select="translate($str, '-', ' ')"/>
@@ -5831,7 +5886,7 @@
5831
5886
  <xsl:template match="*[local-name() = 'figure']" name="figure">
5832
5887
  <xsl:variable name="isAdded" select="@added"/>
5833
5888
  <xsl:variable name="isDeleted" select="@deleted"/>
5834
- <fo:block-container id="{@id}">
5889
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
5835
5890
 
5836
5891
  <xsl:call-template name="setTrackChangesStyles">
5837
5892
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -5909,7 +5964,9 @@
5909
5964
 
5910
5965
  <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
5911
5966
  <xsl:if test="number($scale) &lt; 100">
5912
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
5967
+
5968
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
5969
+
5913
5970
  </xsl:if>
5914
5971
 
5915
5972
  </xsl:if>
@@ -6817,7 +6874,13 @@
6817
6874
  </xsl:template>
6818
6875
 
6819
6876
  <xsl:template match="text()" mode="contents_item">
6820
- <xsl:call-template name="keep_together_standard_number"/>
6877
+ <xsl:variable name="text">
6878
+ <!-- to split by '_' and other chars -->
6879
+ <text><xsl:call-template name="add-zero-spaces-java"/></text>
6880
+ </xsl:variable>
6881
+ <xsl:for-each select="xalan:nodeset($text)/text/text()">
6882
+ <xsl:call-template name="keep_together_standard_number"/>
6883
+ </xsl:for-each>
6821
6884
  </xsl:template>
6822
6885
 
6823
6886
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
@@ -6828,35 +6891,53 @@
6828
6891
  <!-- =============== -->
6829
6892
  <!-- sourcecode -->
6830
6893
  <!-- =============== -->
6831
- <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6832
6894
 
6833
- <xsl:variable name="sourcecode_attributes">
6834
- <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
6835
- <xsl:variable name="_font-size">
6895
+ <xsl:variable name="source-highlighter-css_" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'source-highlighter-css']"/>
6896
+ <xsl:variable name="sourcecode_css_" select="java:org.metanorma.fop.Util.parseCSS($source-highlighter-css_)"/>
6897
+ <xsl:variable name="sourcecode_css" select="xalan:nodeset($sourcecode_css_)"/>
6836
6898
 
6837
- <!-- 9 -->
6899
+ <xsl:template match="*[local-name() = 'property']" mode="css">
6900
+ <xsl:attribute name="{@name}">
6901
+ <xsl:value-of select="@value"/>
6902
+ </xsl:attribute>
6903
+ </xsl:template>
6838
6904
 
6839
- <!-- <xsl:if test="$namespace = 'ieee'">
6840
- <xsl:if test="$current_template = 'standard'">8</xsl:if>
6841
- </xsl:if> -->
6905
+ <xsl:template name="get_sourcecode_attributes">
6906
+ <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style">
6907
+ <xsl:variable name="_font-size">
6842
6908
 
6843
- 10
6844
- </xsl:variable>
6909
+ <!-- inherit -->
6845
6910
 
6846
- <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
6847
- <xsl:if test="$font-size != ''">
6848
- <xsl:attribute name="font-size">
6849
- <xsl:choose>
6850
- <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6851
- <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6852
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6853
- <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6854
- </xsl:choose>
6855
- </xsl:attribute>
6856
- </xsl:if>
6857
- </xsl:element>
6911
+ <!-- <xsl:if test="$namespace = 'ieee'">
6912
+ <xsl:if test="$current_template = 'standard'">8</xsl:if>
6913
+ </xsl:if> -->
6914
+
6915
+ 10
6916
+ </xsl:variable>
6917
+
6918
+ <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
6919
+ <xsl:if test="$font-size != ''">
6920
+ <xsl:attribute name="font-size">
6921
+ <xsl:choose>
6922
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6923
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6924
+ <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6925
+ <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6926
+ </xsl:choose>
6927
+ </xsl:attribute>
6928
+ </xsl:if>
6929
+ <xsl:apply-templates select="$sourcecode_css//class[@name = 'sourcecode']" mode="css"/>
6930
+ </xsl:element>
6931
+ </xsl:template>
6932
+
6933
+ <xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6934
+
6935
+ <xsl:variable name="sourcecode_attributes">
6936
+ <xsl:call-template name="get_sourcecode_attributes"/>
6858
6937
  </xsl:variable>
6859
6938
 
6939
+ <!-- <xsl:copy-of select="$sourcecode_css"/> -->
6940
+
6860
6941
  <xsl:choose>
6861
6942
  <xsl:when test="$isGenerateTableIF = 'true' and (ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])">
6862
6943
  <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*">
@@ -6899,6 +6980,12 @@
6899
6980
  </xsl:attribute>
6900
6981
  </xsl:for-each>
6901
6982
 
6983
+ <!-- remove margin between rows in the table with sourcecode line numbers -->
6984
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']">
6985
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
6986
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
6987
+ </xsl:if>
6988
+
6902
6989
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
6903
6990
  </fo:block>
6904
6991
 
@@ -6910,9 +6997,10 @@
6910
6997
  </xsl:choose>
6911
6998
  </xsl:template>
6912
6999
 
6913
- <xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
7000
+ <xsl:template match="*[local-name()='sourcecode']/text() | *[local-name()='sourcecode']//*[local-name()='span']/text()" priority="2">
6914
7001
  <xsl:choose>
6915
- <xsl:when test="normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
7002
+ <!-- disabled -->
7003
+ <xsl:when test="1 = 2 and normalize-space($syntax-highlight) = 'true' and normalize-space(../@lang) != ''"> <!-- condition for turn on of highlighting -->
6916
7004
  <xsl:variable name="syntax" select="java:org.metanorma.fop.Util.syntaxHighlight(., ../@lang)"/>
6917
7005
  <xsl:choose>
6918
7006
  <xsl:when test="normalize-space($syntax) != ''"><!-- if there is highlighted result -->
@@ -6927,9 +7015,77 @@
6927
7015
  <xsl:call-template name="add_spaces_to_sourcecode"/>
6928
7016
  </xsl:otherwise>
6929
7017
  </xsl:choose>
7018
+ </xsl:template>
7019
+
7020
+ <!-- add sourcecode highlighting -->
7021
+ <xsl:template match="*[local-name()='sourcecode']//*[local-name()='span'][@class]" priority="2">
7022
+ <xsl:variable name="class" select="@class"/>
7023
+ <xsl:choose>
7024
+ <xsl:when test="$sourcecode_css//class[@name = $class]">
7025
+ <fo:inline>
7026
+ <xsl:apply-templates select="$sourcecode_css//class[@name = $class]" mode="css"/>
7027
+ <xsl:apply-templates/>
7028
+ </fo:inline>
7029
+ </xsl:when>
7030
+ <xsl:otherwise>
7031
+ <xsl:apply-templates/>
7032
+ </xsl:otherwise>
7033
+ </xsl:choose>
7034
+ </xsl:template>
7035
+
7036
+ <!-- outer table with line numbers for sourcecode -->
7037
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] | -->
7038
+ <fo:block>
7039
+ <fo:table width="100%" table-layout="fixed">
7040
+ <xsl:copy-of select="@id"/>
7041
+ <fo:table-column column-width="8%"/>
7042
+ <fo:table-column column-width="92%"/>
7043
+ <fo:table-body>
7044
+ <xsl:apply-templates/>
7045
+ </fo:table-body>
7046
+ </fo:table>
7047
+ </fo:block>
7048
+ </xsl:template>
7049
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']/*[local-name() = 'tbody']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody'] | -->
7050
+ <xsl:apply-templates/>
7051
+ </xsl:template>
7052
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr'] | -->
7053
+ <fo:table-row>
7054
+ <xsl:apply-templates/>
7055
+ </fo:table-row>
7056
+ </xsl:template>
7057
+ <!-- first td with line numbers -->
7058
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
7059
+ <fo:table-cell>
7060
+ <fo:block>
7061
+
7062
+ <!-- set attibutes for line numbers - same as sourcecode -->
7063
+ <xsl:variable name="sourcecode_attributes">
7064
+ <xsl:for-each select="following-sibling::*[local-name() = 'td']/*[local-name() = 'sourcecode']">
7065
+ <xsl:call-template name="get_sourcecode_attributes"/>
7066
+ </xsl:for-each>
7067
+ </xsl:variable>
7068
+ <xsl:for-each select="xalan:nodeset($sourcecode_attributes)/sourcecode_attributes/@*[not(starts-with(local-name(), 'margin-') or starts-with(local-name(), 'space-'))]">
7069
+ <xsl:attribute name="{local-name()}">
7070
+ <xsl:value-of select="."/>
7071
+ </xsl:attribute>
7072
+ </xsl:for-each>
6930
7073
 
7074
+ <xsl:apply-templates/>
7075
+ </fo:block>
7076
+ </fo:table-cell>
6931
7077
  </xsl:template>
6932
7078
 
7079
+ <!-- second td with sourcecode -->
7080
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
7081
+ <fo:table-cell>
7082
+ <fo:block>
7083
+ <xsl:apply-templates/>
7084
+ </fo:block>
7085
+ </fo:table-cell>
7086
+ </xsl:template>
7087
+ <!-- END outer table with line numbers for sourcecode -->
7088
+
6933
7089
  <xsl:template name="add_spaces_to_sourcecode">
6934
7090
  <xsl:variable name="text_step1">
6935
7091
  <xsl:call-template name="add-zero-spaces-equal"/>
@@ -7159,7 +7315,25 @@
7159
7315
  <xsl:template match="*[local-name()='pre']" name="pre">
7160
7316
  <fo:block xsl:use-attribute-sets="pre-style">
7161
7317
  <xsl:copy-of select="@id"/>
7162
- <xsl:apply-templates/>
7318
+ <xsl:choose>
7319
+
7320
+ <xsl:when test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name()='td'][1][not(preceding-sibling::*)]"> <!-- pre in the first td in the table with @linenums = 'true' -->
7321
+ <xsl:if test="ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']"> <!-- is current tr isn't last -->
7322
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
7323
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
7324
+ </xsl:if>
7325
+ <fo:instream-foreign-object fox:alt-text="{.}" content-width="95%">
7326
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
7327
+ <mtext><xsl:value-of select="."/></mtext>
7328
+ </math>
7329
+ </fo:instream-foreign-object>
7330
+ </xsl:when>
7331
+
7332
+ <xsl:otherwise>
7333
+ <xsl:apply-templates/>
7334
+ </xsl:otherwise>
7335
+
7336
+ </xsl:choose>
7163
7337
  </fo:block>
7164
7338
  </xsl:template>
7165
7339
  <!-- =============== -->
@@ -8611,160 +8785,53 @@
8611
8785
  </xsl:template> <!-- references[not(@normative='true')]/bibitem -->
8612
8786
 
8613
8787
  <xsl:template name="processBibitem">
8788
+ <xsl:param name="biblio_tag_part">both</xsl:param>
8614
8789
 
8615
8790
  <!-- start UNECE bibitem processing -->
8616
- <fo:inline padding-right="5mm">[<xsl:value-of select="un:docidentifier"/>]</fo:inline><xsl:value-of select="un:docidentifier"/>
8617
- <xsl:text> </xsl:text>
8791
+ <fo:inline padding-right="5mm">
8792
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
8793
+ <xsl:with-param name="biblio_tag_part">first</xsl:with-param>
8794
+ </xsl:apply-templates>
8795
+ </fo:inline>
8796
+ <xsl:apply-templates select="*[local-name() = 'biblio-tag']">
8797
+ <xsl:with-param name="biblio_tag_part">last</xsl:with-param>
8798
+ </xsl:apply-templates>
8799
+
8618
8800
  <xsl:apply-templates select="un:formattedref"/>
8619
8801
  <!-- END UNECE bibitem processing -->
8620
8802
 
8621
8803
  </xsl:template> <!-- processBibitem (bibitem) -->
8622
8804
 
8623
- <xsl:template name="processBibitemDocId">
8624
- <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')]"/>
8625
- <xsl:choose>
8626
- <xsl:when test="normalize-space($_doc_ident) != ''">
8627
- <!-- <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"/>
8628
- <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
8629
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
8630
- </xsl:if> -->
8631
- <xsl:value-of select="$_doc_ident"/>
8632
- </xsl:when>
8633
- <xsl:otherwise>
8634
- <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
8635
- <xsl:if test="$type != ''">
8636
- <xsl:value-of select="$type"/><xsl:text> </xsl:text>
8637
- </xsl:if> -->
8638
- <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma') and not(@type = 'metanorma-ordinal')]"/>
8639
- </xsl:otherwise>
8640
- </xsl:choose>
8641
- </xsl:template> <!-- processBibitemDocId -->
8805
+ <xsl:template match="*[local-name() = 'title']" mode="title">
8806
+ <fo:inline><xsl:apply-templates/></fo:inline>
8807
+ </xsl:template>
8808
+
8809
+ <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
8810
+
8811
+ <xsl:template match="*[local-name() = 'formattedref']">
8812
+ <!-- <xsl:if test="$namespace = 'unece' or $namespace = 'unece-rec'">
8813
+ <xsl:text>, </xsl:text>
8814
+ </xsl:if> -->
8815
+ <xsl:apply-templates/>
8816
+ </xsl:template>
8642
8817
 
8643
- <xsl:template name="processPersonalAuthor">
8818
+ <xsl:template match="*[local-name() = 'biblio-tag']">
8819
+ <xsl:param name="biblio_tag_part">both</xsl:param>
8644
8820
  <xsl:choose>
8645
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'completename']">
8646
- <author>
8647
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'completename']"/>
8648
- </author>
8821
+ <xsl:when test="$biblio_tag_part = 'first' and *[local-name() = 'tab']">
8822
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
8649
8823
  </xsl:when>
8650
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'initial']">
8651
- <author>
8652
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
8653
- <xsl:text> </xsl:text>
8654
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'initial']" mode="strip"/>
8655
- </author>
8656
- </xsl:when>
8657
- <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'forename']">
8658
- <author>
8659
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
8660
- <xsl:text> </xsl:text>
8661
- <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'forename']" mode="strip"/>
8662
- </author>
8824
+ <xsl:when test="$biblio_tag_part = 'last'">
8825
+ <xsl:apply-templates select="./*[local-name() = 'tab'][1]/following-sibling::node()"/>
8663
8826
  </xsl:when>
8664
8827
  <xsl:otherwise>
8665
8828
  <xsl:apply-templates/>
8666
8829
  </xsl:otherwise>
8667
8830
  </xsl:choose>
8668
- </xsl:template> <!-- processPersonalAuthor -->
8669
-
8670
- <xsl:template name="renderDate">
8671
- <xsl:if test="normalize-space(*[local-name() = 'on']) != ''">
8672
- <xsl:value-of select="*[local-name() = 'on']"/>
8673
- </xsl:if>
8674
- <xsl:if test="normalize-space(*[local-name() = 'from']) != ''">
8675
- <xsl:value-of select="concat(*[local-name() = 'from'], '–', *[local-name() = 'to'])"/>
8676
- </xsl:if>
8677
- </xsl:template>
8678
-
8679
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'initial']/text()" mode="strip">
8680
- <xsl:value-of select="translate(.,'. ','')"/>
8681
- </xsl:template>
8682
-
8683
- <xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
8684
- <xsl:value-of select="substring(.,1,1)"/>
8685
- </xsl:template>
8686
-
8687
- <xsl:template match="*[local-name() = 'title']" mode="title">
8688
- <fo:inline><xsl:apply-templates/></fo:inline>
8689
8831
  </xsl:template>
8690
8832
 
8691
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'title']" priority="2">
8692
- <!-- <fo:inline><xsl:apply-templates /></fo:inline> -->
8693
- <fo:inline font-style="italic"> <!-- BIPM BSI CSD CSA GB IEC IHO ISO ITU JCGM -->
8694
- <xsl:apply-templates/>
8695
- </fo:inline>
8696
- </xsl:template>
8697
-
8698
- <!-- bibitem/note renders as footnote -->
8699
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
8700
-
8701
- <!-- list of footnotes to calculate actual footnotes number -->
8702
- <xsl:variable name="p_fn_">
8703
- <xsl:call-template name="get_fn_list"/>
8704
- </xsl:variable>
8705
- <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
8706
- <xsl:variable name="gen_id" select="generate-id(.)"/>
8707
- <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
8708
- <!-- fn sequence number in document -->
8709
- <xsl:variable name="current_fn_number">
8710
- <xsl:choose>
8711
- <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
8712
- <xsl:otherwise>
8713
- <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
8714
- <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
8715
- </xsl:otherwise>
8716
- </xsl:choose>
8717
- </xsl:variable>
8718
- <fo:footnote>
8719
- <xsl:variable name="number">
8720
-
8721
- <xsl:value-of select="$current_fn_number"/>
8722
-
8723
- </xsl:variable>
8724
-
8725
- <xsl:variable name="current_fn_number_text">
8726
- <xsl:value-of select="$number"/>
8727
-
8728
- </xsl:variable>
8729
-
8730
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
8731
- <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
8732
- <xsl:value-of select="$current_fn_number_text"/>
8733
- </fo:basic-link>
8734
- </fo:inline>
8735
- <fo:footnote-body>
8736
- <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
8737
- <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
8738
- <xsl:value-of select="$current_fn_number_text"/>
8739
- </fo:inline>
8740
- <xsl:apply-templates/>
8741
- </fo:block>
8742
- </fo:footnote-body>
8743
- </fo:footnote>
8744
- </xsl:template>
8745
-
8746
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'edition']"> <!-- for iho -->
8747
- <xsl:text> edition </xsl:text>
8748
- <xsl:value-of select="."/>
8749
- </xsl:template>
8750
-
8751
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'uri']"> <!-- for iho -->
8752
- <xsl:text> (</xsl:text>
8753
- <fo:inline xsl:use-attribute-sets="link-style">
8754
- <fo:basic-link external-destination="." fox:alt-text=".">
8755
- <xsl:value-of select="."/>
8756
- </fo:basic-link>
8757
- </fo:inline>
8758
- <xsl:text>)</xsl:text>
8759
- </xsl:template>
8760
-
8761
- <xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'docidentifier']"/>
8762
-
8763
- <xsl:template match="*[local-name() = 'formattedref']">
8764
-
8765
- <xsl:text>, </xsl:text>
8766
-
8767
- <xsl:apply-templates/>
8833
+ <xsl:template match="*[local-name() = 'biblio-tag']/*[local-name() = 'tab']" priority="2">
8834
+ <xsl:text> </xsl:text>
8768
8835
  </xsl:template>
8769
8836
 
8770
8837
  <!-- ======================= -->
@@ -9197,6 +9264,12 @@
9197
9264
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9198
9265
  <xsl:apply-templates mode="update_xml_step1"/>
9199
9266
  </xsl:template>
9267
+ <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
9268
+ <xsl:copy>
9269
+ <xsl:copy-of select="@*"/>
9270
+ <xsl:apply-templates mode="update_xml_step1"/>
9271
+ </xsl:copy>
9272
+ </xsl:template>
9200
9273
  <!-- =========================================================================== -->
9201
9274
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9202
9275
  <!-- =========================================================================== -->
@@ -9677,6 +9750,10 @@
9677
9750
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
9678
9751
  </xsl:template>
9679
9752
 
9753
+ <xsl:template name="getDocumentId_fromCurrentNode">
9754
+ <xsl:call-template name="getLang_fromCurrentNode"/><xsl:value-of select=".//*[local-name() = 'p'][1]/@id"/>
9755
+ </xsl:template>
9756
+
9680
9757
  <xsl:template name="namespaceCheck">
9681
9758
  <xsl:variable name="documentNS" select="namespace-uri(/*)"/>
9682
9759
  <xsl:variable name="XSLNS">