metanorma-nist 1.0.3 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,9 +107,9 @@ module Asciidoctor
107
107
  File.open(filename, "w:UTF-8") { |f| f.write(ret) }
108
108
  html_converter(node).convert filename unless node.attr("nodoc")
109
109
  word_converter(node).convert filename unless node.attr("nodoc")
110
- pdf_converter(node).convert filename unless node.attr("nodoc")
110
+ pdf_converter(node)&.convert filename unless node.attr("nodoc")
111
111
  end
112
- @log.write(@filename + ".err") unless @novalid
112
+ @log.write(@localdir + @filename + ".err") unless @novalid
113
113
  @files_to_delete.each { |f| FileUtils.rm f }
114
114
  ret
115
115
  end
@@ -151,36 +151,12 @@ module Asciidoctor
151
151
  end
152
152
  end
153
153
 
154
- def section(node)
155
- a = section_attributes(node)
156
- noko do |xml|
157
- case sectiontype(node)
158
- #when "normative references" then norm_ref_parse(a, xml, node)
159
- when "terms and definitions"
160
- if node.attr("style") == "appendix" && node.level == 1
161
- @term_def = true
162
- terms_annex_parse(a, xml, node)
163
- @term_def = false
164
- else
165
- clause_parse(a, xml, node)
166
- end
167
- when "acknowledgements"
168
- acknowledgements_parse(a, xml, node)
169
- else
170
- if @term_def
171
- term_def_subclause_parse(a, xml, node)
172
- elsif @biblio then bibliography_parse(a, xml, node)
173
- elsif node.attr("style") == "bibliography"
174
- bibliography_parse(a, xml, node)
175
- elsif node.attr("style") == "abstract"
176
- abstract_parse(a, xml, node)
177
- elsif node.attr("style") == "appendix" && node.level == 1
178
- annex_parse(a, xml, node)
179
- else
180
- clause_parse(a, xml, node)
181
- end
182
- end
183
- end.join("\n")
154
+ def term_def_parse(attrs, xml, node, toplevel)
155
+ if node.attr("style") == "appendix" && node.level == 1
156
+ terms_annex_parse(attrs, xml, node)
157
+ else
158
+ clause_parse(attrs, xml, node)
159
+ end
184
160
  end
185
161
 
186
162
  def bibliography_parse(a, xml, node)
@@ -236,6 +212,7 @@ module Asciidoctor
236
212
  end
237
213
 
238
214
  def pdf_converter(node)
215
+ return nil if node.attr("no-pdf")
239
216
  IsoDoc::NIST::PdfConvert.new(html_extract_attributes(node))
240
217
  end
241
218
  end
@@ -46,7 +46,7 @@ module Asciidoctor
46
46
 
47
47
  def title_main(node, t, at)
48
48
  t.title(**attr_code(at.merge(type: "main"))) do |t1|
49
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main") || node.title)
49
+ t1 << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main")) || node.title)
50
50
  end
51
51
  node.attr("title-main-short") and
52
52
  t.title(**attr_code(at.merge(type: "short-title"))) do |t1|
@@ -144,20 +144,26 @@ module Asciidoctor
144
144
  end
145
145
 
146
146
  def relaton_relations
147
- super + %w(obsoletes obsoleted-by supersedes superseded-by)
147
+ super + %w(obsoletes obsoleted-by)
148
148
  end
149
149
 
150
- def metadata_getrelation(node, xml, type)
151
- if type == "obsoleted-by" and node.attr("superseding-status")
150
+ def relaton_relation_descriptions
151
+ super.merge({
152
+ "supersedes" => "obsoletes",
153
+ "superseded-by" => "obsoleted-by",
154
+ })
155
+ end
156
+
157
+ def metadata_getrelation(node, xml, type, desc = nil)
158
+ if type == "obsoleted-by" and desc.nil? and node.attr("superseding-status")
152
159
  metadata_superseding_doc(node, xml)
153
- else
154
- super
155
160
  end
161
+ super
156
162
  end
157
163
 
158
164
  def metadata_superseding_doc(node, xml)
159
165
  xml.relation **{ type: "obsoletedBy" } do |r|
160
- r.bibitem do |b|
166
+ r.bibitem **{ type: "standard" } do |b|
161
167
  metadata_superseding_titles(b, node)
162
168
  doi = node.attr("superseding-doi") and
163
169
  b.uri doi, **{ type: "doi" }
@@ -197,16 +203,21 @@ module Asciidoctor
197
203
 
198
204
  def metadata_superseding_titles(b, node)
199
205
  if node.attr("superseding-title")
200
- b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-title")),
201
- **{ type: "main" }
206
+ b.title **{ type: "main" } do |t|
207
+ t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-title"))
208
+ end
202
209
  node.attr("superseding-subtitle") and
203
- b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-subtitle")),
204
- **{ type: "subtitle" }
210
+ b.title **{ type: "subtitle" } do |t|
211
+ t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-subtitle"))
212
+ end
205
213
  else
206
- b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main") || node.title),
207
- **{ type: "main" }
214
+ b.title **{ type: "main" } do |t|
215
+ t << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main")) || node.title)
216
+ end
208
217
  node.attr("title-sub") and
209
- b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub")), **{ type: "subtitle" }
218
+ b.title **{ type: "subtitle" } do |t|
219
+ t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
220
+ end
210
221
  end
211
222
  end
212
223
 
@@ -101,9 +101,7 @@
101
101
  <ref name="structuredidentifier"/>
102
102
  </zeroOrMore>
103
103
  </define>
104
- <define name="TitleType">
105
- <text/>
106
- </define>
104
+ <!-- TitleType = text -->
107
105
  <define name="sections">
108
106
  <element name="sections">
109
107
  <oneOrMore>
@@ -131,6 +129,9 @@
131
129
  </choice>
132
130
  </attribute>
133
131
  </optional>
132
+ <attribute name="normative">
133
+ <data type="boolean"/>
134
+ </attribute>
134
135
  <optional>
135
136
  <ref name="section-title"/>
136
137
  </optional>
@@ -307,6 +308,21 @@
307
308
  </define>
308
309
  </include>
309
310
  <!-- end overrides -->
311
+ <define name="TextElement" combine="choice">
312
+ <ref name="concept"/>
313
+ </define>
314
+ <define name="concept">
315
+ <element name="concept">
316
+ <optional>
317
+ <attribute name="term"/>
318
+ </optional>
319
+ <choice>
320
+ <ref name="eref"/>
321
+ <ref name="xref"/>
322
+ <ref name="termref"/>
323
+ </choice>
324
+ </element>
325
+ </define>
310
326
  <define name="BasicBlock" combine="choice">
311
327
  <choice>
312
328
  <ref name="requirement"/>
@@ -913,7 +929,10 @@
913
929
  </define>
914
930
  <define name="origin">
915
931
  <element name="origin">
916
- <ref name="erefType"/>
932
+ <choice>
933
+ <ref name="erefType"/>
934
+ <ref name="termref"/>
935
+ </choice>
917
936
  </element>
918
937
  </define>
919
938
  <define name="modification">
@@ -921,6 +940,15 @@
921
940
  <ref name="paragraph"/>
922
941
  </element>
923
942
  </define>
943
+ <define name="termref">
944
+ <element name="termref">
945
+ <attribute name="base"/>
946
+ <attribute name="target"/>
947
+ <optional>
948
+ <text/>
949
+ </optional>
950
+ </element>
951
+ </define>
924
952
  <define name="structuredidentifier">
925
953
  <element name="structuredidentifier">
926
954
  <optional>
@@ -12,15 +12,7 @@
12
12
  <define name="DocumentType">
13
13
  <value>standard</value>
14
14
  </define>
15
- <define name="TitleType">
16
- <choice>
17
- <value>alternative</value>
18
- <value>original</value>
19
- <value>unofficial</value>
20
- <value>subtitle</value>
21
- <value>main</value>
22
- </choice>
23
- </define>
15
+ <!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
24
16
  <define name="preface">
25
17
  <element name="preface">
26
18
  <optional>
@@ -177,8 +177,8 @@ module IsoDoc
177
177
 
178
178
  def get_linkend(node)
179
179
  link = anchor_linkend(node, docid_l10n(node["target"] || wrap_brackets(node['citeas'])))
180
- link += eref_localities(node.xpath(ns("./locality")), link)
181
- contents = node.children.select { |c| c.name != "locality" }
180
+ link += eref_localities(node.xpath(ns("./locality | ./localityStack")), link)
181
+ contents = node.children.select { |c| !%w{locality localityStack}.include? c.name }
182
182
  return link if contents.nil? || contents.empty?
183
183
  Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
184
184
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
@@ -208,7 +208,7 @@ module IsoDoc
208
208
  def bibliography_parse(node, out)
209
209
  title = node&.at(ns("./title"))&.text || ""
210
210
  out.div do |div|
211
- unless node.parent.name == "annex"
211
+ unless suppress_biblio_title(node)
212
212
  anchor(node['id'], :label, false) and
213
213
  clause_parse_title(node, div, node.at(ns("./title")), out) or
214
214
  div.h2 title, **{ class: "Section3" }
@@ -217,6 +217,16 @@ module IsoDoc
217
217
  end
218
218
  end
219
219
 
220
+ def suppress_biblio_title(node)
221
+ return false unless node.parent.name == "annex"
222
+ return false if node.parent.xpath("./references | ./clause | "\
223
+ "./terms | ./definitions").size > 1
224
+ title1 = node&.at(ns("./title"))&.text
225
+ return true unless title1
226
+ title2 = node&.parent&.at(ns("./title"))&.text
227
+ title1&.casecmp(title2) == 0
228
+ end
229
+
220
230
  def foreword(isoxml, out)
221
231
  f = isoxml.at(ns("//foreword")) || return
222
232
  out.div **attr_code(id: f["id"]) do |s|
@@ -0,0 +1,1246 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:iso="http://riboseinc.com/isoxml" xmlns:iec="http://riboseinc.com/isoxml" xmlns:itu="https://open.ribose.com/standards/itu" xmlns:nist="http://www.nist.gov/metanorma" xmlns:un="https://open.ribose.com/standards/unece" xmlns:csd="https://www.calconnect.org/standards/csd" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" version="1.0">
3
+
4
+ <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
5
+ <xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
6
+
7
+ <xsl:variable name="en_chars" select="concat($lower,$upper,',.`1234567890-=~!@#$%^*()_+[]{}\|?/')"/>
8
+
9
+ <xsl:variable name="linebreak" select="'&#x2028;'"/>
10
+
11
+ <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/>
12
+
13
+ <xsl:variable name="unece-rec">
14
+ <xsl:if test="$namespace = 'unece' and /un:unece-standard/un:bibdata/un:ext/un:doctype = 'recommendation'">true</xsl:if>
15
+ </xsl:variable>
16
+
17
+ <xsl:template match="text()">
18
+ <xsl:value-of select="."/>
19
+ </xsl:template>
20
+
21
+ <xsl:template match="*[local-name()='br']">
22
+ <xsl:value-of select="$linebreak"/>
23
+ </xsl:template>
24
+
25
+ <xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text()" priority="1">
26
+ <xsl:call-template name="add-zero-spaces"/>
27
+ </xsl:template>
28
+
29
+
30
+ <xsl:template match="*[local-name()='table']">
31
+
32
+ <xsl:variable name="simple-table">
33
+ <!-- <xsl:copy> -->
34
+ <xsl:call-template name="getSimpleTable"/>
35
+ <!-- </xsl:copy> -->
36
+ </xsl:variable>
37
+
38
+ <!-- DEBUG -->
39
+ <!-- SourceTable=<xsl:copy-of select="current()"/>EndSourceTable -->
40
+ <!-- Simpletable=<xsl:copy-of select="$simple-table"/>EndSimpltable -->
41
+
42
+ <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
43
+ <xsl:if test="$namespace = 'itu'">
44
+ <fo:block space-before="18pt">&#xA0;</fo:block>
45
+ </xsl:if>
46
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
47
+ <fo:block space-before="6pt">&#xA0;</fo:block>
48
+ </xsl:if>
49
+ <xsl:choose>
50
+ <xsl:when test="@unnumbered = 'true'"></xsl:when>
51
+ <xsl:otherwise>
52
+ <xsl:choose>
53
+ <xsl:when test="$namespace = 'unece' and ancestor::*[local-name() = 'sections'] and $unece-rec = 'true'">
54
+ </xsl:when>
55
+ <xsl:otherwise>
56
+ <fo:block font-weight="bold" text-align="center" margin-bottom="6pt" keep-with-next="always">
57
+ <xsl:if test="$namespace = 'nist'">
58
+ <xsl:attribute name="font-family">Arial</xsl:attribute>
59
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
60
+ </xsl:if>
61
+ <xsl:if test="$namespace = 'unece' and $unece-rec = 'true'">
62
+ <xsl:attribute name="text-align">left</xsl:attribute>
63
+ <xsl:attribute name="margin-top">12pt</xsl:attribute>
64
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
65
+ </xsl:if>
66
+ <xsl:if test="$namespace = 'unece' and $unece-rec != 'true'">
67
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
68
+ <xsl:attribute name="font-size">11pt</xsl:attribute>
69
+ </xsl:if>
70
+ <xsl:text>Table </xsl:text>
71
+ <xsl:choose>
72
+ <xsl:when test="ancestor::*[local-name()='executivesummary']"> <!-- NIST -->
73
+ <xsl:text>ES-</xsl:text><xsl:number format="1" count="*[local-name()='executivesummary']//*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true']"/>
74
+ </xsl:when>
75
+ <xsl:when test="ancestor::*[local-name()='annex']">
76
+ <xsl:choose>
77
+ <xsl:when test="$namespace = 'iso' or $namespace = 'iec'">
78
+ <xsl:number format="A." count="*[local-name()='annex']"/><xsl:number format="1"/>
79
+ </xsl:when>
80
+ <xsl:when test="$namespace = 'itu'">
81
+ <xsl:choose>
82
+ <xsl:when test="ancestor::itu:annex[@obligation = 'informative']">
83
+ <xsl:variable name="annex-id" select="ancestor::itu:annex/@id"/>
84
+ <!-- Table in Appendix -->
85
+ <xsl:number format="I-" count="itu:annex[@obligation = 'informative']"/>
86
+ <xsl:number format="1" level="any" count="itu:table[(not(@unnumbered) or @unnumbered != 'true') and ancestor::itu:annex[@id = $annex-id]]"/>
87
+ </xsl:when>
88
+ <!-- Table in Annex -->
89
+ <xsl:when test="ancestor::itu:annex[not(@obligation) or @obligation != 'informative']">
90
+ <xsl:variable name="annex-id" select="ancestor::itu:annex/@id"/>
91
+ <xsl:number format="A-" count="itu:annex[not(@obligation) or @obligation != 'informative']"/>
92
+ <xsl:number format="1" level="any" count="itu:table[(not(@unnumbered) or @unnumbered != 'true') and ancestor::itu:annex[@id = $annex-id]]"/>
93
+ </xsl:when>
94
+ </xsl:choose>
95
+ </xsl:when>
96
+ <xsl:when test="$namespace = 'nist'">
97
+ <xsl:variable name="annex-id" select="ancestor::*[local-name()='annex']/@id"/>
98
+ <xsl:number format="A-" count="*[local-name()='annex']"/>
99
+ <xsl:number format="1" level="any" count="*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true'][ancestor::*[local-name()='annex'][@id = $annex-id]]"/>
100
+ </xsl:when>
101
+ <xsl:when test="$namespace = 'unece' and $unece-rec = 'true'">
102
+ <!-- <xsl:variable name="annex-id" select="ancestor::*[local-name()='annex']/@id"/>
103
+ <xsl:number format="I." count="*[local-name()='annex']"/> -->
104
+ <xsl:text>A</xsl:text> <!-- 'A' means Annex -->
105
+ <xsl:number format="1" level="any" count="*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true'][ancestor::*[local-name()='annex']]"/> <!-- [@id = $annex-id] -->
106
+ </xsl:when>
107
+ <xsl:when test="$namespace = 'unece'">
108
+ <xsl:variable name="annex-id" select="ancestor::*[local-name()='annex']/@id"/>
109
+ <xsl:number format="I." count="*[local-name()='annex']"/>
110
+ <xsl:number format="1" level="any" count="*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true'][ancestor::*[local-name()='annex'][@id = $annex-id]]"/>
111
+ </xsl:when>
112
+ <xsl:otherwise>
113
+ <xsl:number format="A-1" level="multiple" count="*[local-name()='annex'] | *[local-name()='table'][not(@unnumbered) or @unnumbered != 'true'] "/>
114
+ </xsl:otherwise>
115
+ </xsl:choose>
116
+ </xsl:when>
117
+ <xsl:otherwise>
118
+ <!-- <xsl:number format="1"/> -->
119
+ <xsl:number format="A." count="*[local-name()='annex']"/>
120
+ <!-- <xsl:number format="1" level="any" count="*[local-name()='sections']//*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true']"/> -->
121
+ <xsl:number format="1" level="any" count="//*[local-name()='table']
122
+ [not(ancestor::*[local-name()='annex']) and not(ancestor::*[local-name()='executivesummary'])]
123
+ [not(@unnumbered) or @unnumbered != 'true']"/>
124
+ </xsl:otherwise>
125
+ </xsl:choose>
126
+ <xsl:if test="*[local-name()='name']">
127
+ <xsl:choose>
128
+ <xsl:when test="$namespace = 'unece' and $unece-rec = 'true'"><xsl:text>. </xsl:text></xsl:when>
129
+ <xsl:otherwise>
130
+ <xsl:text> — </xsl:text>
131
+ </xsl:otherwise>
132
+ </xsl:choose>
133
+ <xsl:apply-templates select="*[local-name()='name']" mode="process"/>
134
+ </xsl:if>
135
+ </fo:block>
136
+ </xsl:otherwise>
137
+ </xsl:choose>
138
+ <xsl:call-template name="fn_name_display"/>
139
+ </xsl:otherwise>
140
+ </xsl:choose>
141
+
142
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
143
+
144
+ <!-- <xsl:variable name="cols-count">
145
+ <xsl:choose>
146
+ <xsl:when test="*[local-name()='thead']">
147
+ <xsl:call-template name="calculate-columns-numbers">
148
+ <xsl:with-param name="table-row" select="*[local-name()='thead']/*[local-name()='tr'][1]"/>
149
+ </xsl:call-template>
150
+ </xsl:when>
151
+ <xsl:otherwise>
152
+ <xsl:call-template name="calculate-columns-numbers">
153
+ <xsl:with-param name="table-row" select="*[local-name()='tbody']/*[local-name()='tr'][1]"/>
154
+ </xsl:call-template>
155
+ </xsl:otherwise>
156
+ </xsl:choose>
157
+ </xsl:variable> -->
158
+ <!-- cols-count=<xsl:copy-of select="$cols-count"/> -->
159
+ <!-- cols-count2=<xsl:copy-of select="$cols-count2"/> -->
160
+
161
+
162
+
163
+ <xsl:variable name="colwidths">
164
+ <xsl:call-template name="calculate-column-widths">
165
+ <xsl:with-param name="cols-count" select="$cols-count"/>
166
+ <xsl:with-param name="table" select="$simple-table"/>
167
+ </xsl:call-template>
168
+ </xsl:variable>
169
+
170
+ <xsl:variable name="colwidths2">
171
+ <xsl:call-template name="calculate-column-widths">
172
+ <xsl:with-param name="cols-count" select="$cols-count"/>
173
+ </xsl:call-template>
174
+ </xsl:variable>
175
+
176
+ <!-- cols-count=<xsl:copy-of select="$cols-count"/>
177
+ colwidthsNew=<xsl:copy-of select="$colwidths"/>
178
+ colwidthsOld=<xsl:copy-of select="$colwidths2"/>z -->
179
+
180
+ <xsl:variable name="margin-left">
181
+ <xsl:choose>
182
+ <xsl:when test="sum(xalan:nodeset($colwidths)//column) &gt; 75">15</xsl:when>
183
+ <xsl:otherwise>0</xsl:otherwise>
184
+ </xsl:choose>
185
+ </xsl:variable>
186
+
187
+ <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm">
188
+ <xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
189
+ <xsl:attribute name="space-after">6pt</xsl:attribute>
190
+ </xsl:if>
191
+ <xsl:if test="$namespace='unece'">
192
+ <xsl:attribute name="space-after">12pt</xsl:attribute>
193
+ </xsl:if>
194
+ <fo:table id="{@id}" table-layout="fixed" width="100%" margin-left="{$margin-left}mm" margin-right="{$margin-left}mm">
195
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
196
+ <xsl:attribute name="border">1.5pt solid black</xsl:attribute>
197
+ </xsl:if>
198
+ <xsl:choose>
199
+ <xsl:when test="$namespace = 'nist' and (ancestor::*[local-name()='annex'] or ancestor::*[local-name()='preface'])">
200
+ <xsl:attribute name="font-family">Times New Roman</xsl:attribute>
201
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
202
+ </xsl:when>
203
+ <xsl:when test="$namespace = 'nist'">
204
+ <xsl:attribute name="font-family">Times New Roman</xsl:attribute>
205
+ <xsl:attribute name="font-size">12pt</xsl:attribute>
206
+ </xsl:when>
207
+ <xsl:when test="$namespace = 'unece' and ancestor::*[local-name()='sections'] and $unece-rec = 'true'">
208
+ <xsl:attribute name="border-top">1.5pt solid black</xsl:attribute>
209
+ <xsl:attribute name="border-bottom">1.5pt solid black</xsl:attribute>
210
+ </xsl:when>
211
+ <xsl:otherwise>
212
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
213
+ </xsl:otherwise>
214
+ </xsl:choose>
215
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
216
+ <xsl:choose>
217
+ <xsl:when test=". = 1">
218
+ <fo:table-column column-width="proportional-column-width(2)"/>
219
+ </xsl:when>
220
+ <xsl:otherwise>
221
+ <fo:table-column column-width="proportional-column-width({.})"/>
222
+ </xsl:otherwise>
223
+ </xsl:choose>
224
+ </xsl:for-each>
225
+ <xsl:apply-templates />
226
+ </fo:table>
227
+ <!-- <xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
228
+ <fo:block space-after="6pt">&#xA0;</fo:block>
229
+ </xsl:if> -->
230
+ </fo:block-container>
231
+ </xsl:template>
232
+
233
+ <xsl:template match="*[local-name()='table']/*[local-name()='name']"/>
234
+ <xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="process">
235
+ <xsl:apply-templates />
236
+ </xsl:template>
237
+
238
+
239
+
240
+ <xsl:template name="calculate-columns-numbers">
241
+ <xsl:param name="table-row" />
242
+ <xsl:variable name="columns-count" select="count($table-row/*)"/>
243
+ <xsl:variable name="sum-colspans" select="sum($table-row/*/@colspan)"/>
244
+ <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
245
+ <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
246
+ </xsl:template>
247
+
248
+ <xsl:template name="calculate-column-widths">
249
+ <xsl:param name="table"/>
250
+ <xsl:param name="cols-count"/>
251
+ <xsl:param name="curr-col" select="1"/>
252
+ <xsl:param name="width" select="0"/>
253
+
254
+ <xsl:if test="$curr-col &lt;= $cols-count">
255
+ <xsl:variable name="widths">
256
+ <xsl:choose>
257
+ <xsl:when test="not($table)">
258
+ <xsl:for-each select="*[local-name()='thead']//*[local-name()='tr']">
259
+ <xsl:variable name="words">
260
+ <xsl:call-template name="tokenize">
261
+ <xsl:with-param name="text" select="translate(*[local-name()='th'][$curr-col],'- —', ' ')"/>
262
+ </xsl:call-template>
263
+ </xsl:variable>
264
+ <xsl:variable name="max_length">
265
+ <xsl:call-template name="max_length">
266
+ <xsl:with-param name="words" select="xalan:nodeset($words)"/>
267
+ </xsl:call-template>
268
+ </xsl:variable>
269
+ <width>
270
+ <xsl:value-of select="$max_length"/>
271
+ </width>
272
+ </xsl:for-each>
273
+ <xsl:for-each select="*[local-name()='tbody']//*[local-name()='tr']">
274
+ <xsl:variable name="words">
275
+ <xsl:call-template name="tokenize">
276
+ <xsl:with-param name="text" select="translate(*[local-name()='td'][$curr-col],'- —', ' ')"/>
277
+ </xsl:call-template>
278
+ </xsl:variable>
279
+ <xsl:variable name="max_length">
280
+ <xsl:call-template name="max_length">
281
+ <xsl:with-param name="words" select="xalan:nodeset($words)"/>
282
+ </xsl:call-template>
283
+ </xsl:variable>
284
+ <width>
285
+ <xsl:value-of select="$max_length"/>
286
+ </width>
287
+
288
+ </xsl:for-each>
289
+ </xsl:when>
290
+ <xsl:otherwise>
291
+ <xsl:for-each select="xalan:nodeset($table)//tr">
292
+ <xsl:variable name="words">
293
+ <xsl:call-template name="tokenize">
294
+ <xsl:with-param name="text" select="translate(td[$curr-col],'- —', ' ')"/>
295
+ </xsl:call-template>
296
+ </xsl:variable>
297
+ <xsl:variable name="max_length">
298
+ <xsl:call-template name="max_length">
299
+ <xsl:with-param name="words" select="xalan:nodeset($words)"/>
300
+ </xsl:call-template>
301
+ </xsl:variable>
302
+ <width>
303
+ <xsl:variable name="divider">
304
+ <xsl:choose>
305
+ <xsl:when test="td[$curr-col]/@divide">
306
+ <xsl:value-of select="td[$curr-col]/@divide"/>
307
+ </xsl:when>
308
+ <xsl:otherwise>1</xsl:otherwise>
309
+ </xsl:choose>
310
+ </xsl:variable>
311
+ <xsl:value-of select="$max_length div $divider"/>
312
+ </width>
313
+
314
+ </xsl:for-each>
315
+
316
+ </xsl:otherwise>
317
+ </xsl:choose>
318
+ </xsl:variable>
319
+
320
+
321
+ <column>
322
+ <xsl:for-each select="xalan:nodeset($widths)//width">
323
+ <xsl:sort select="." data-type="number" order="descending"/>
324
+ <xsl:if test="position()=1">
325
+ <xsl:value-of select="."/>
326
+ </xsl:if>
327
+ </xsl:for-each>
328
+ </column>
329
+ <xsl:call-template name="calculate-column-widths">
330
+ <xsl:with-param name="cols-count" select="$cols-count"/>
331
+ <xsl:with-param name="curr-col" select="$curr-col +1"/>
332
+ <xsl:with-param name="table" select="$table"/>
333
+ </xsl:call-template>
334
+ </xsl:if>
335
+ </xsl:template>
336
+
337
+ <!-- for debug purpose only -->
338
+ <xsl:template match="*[local-name()='table2']"/>
339
+
340
+ <xsl:template match="*[local-name()='thead']"/>
341
+
342
+ <xsl:template match="*[local-name()='thead']" mode="process">
343
+ <!-- <fo:table-header font-weight="bold">
344
+ <xsl:apply-templates />
345
+ </fo:table-header> -->
346
+ <xsl:apply-templates />
347
+ </xsl:template>
348
+
349
+ <xsl:template match="*[local-name()='tfoot']"/>
350
+
351
+ <xsl:template match="*[local-name()='tfoot']" mode="process">
352
+ <xsl:apply-templates/>
353
+ </xsl:template>
354
+
355
+ <xsl:template match="*[local-name()='tbody']">
356
+ <xsl:variable name="cols-count">
357
+ <xsl:choose>
358
+ <xsl:when test="../*[local-name()='thead']">
359
+ <!-- <xsl:value-of select="count(../*[local-name()='thead']/*[local-name()='tr']/*[local-name()='th'])"/> -->
360
+ <xsl:call-template name="calculate-columns-numbers">
361
+ <xsl:with-param name="table-row" select="../*[local-name()='thead']/*[local-name()='tr'][1]"/>
362
+ </xsl:call-template>
363
+ </xsl:when>
364
+ <xsl:otherwise>
365
+ <!-- <xsl:value-of select="count(./*[local-name()='tr'][1]/*[local-name()='td'])"/> -->
366
+ <xsl:call-template name="calculate-columns-numbers">
367
+ <xsl:with-param name="table-row" select="./*[local-name()='tr'][1]"/>
368
+ </xsl:call-template>
369
+ </xsl:otherwise>
370
+ </xsl:choose>
371
+ </xsl:variable>
372
+
373
+ <fo:table-body>
374
+ <xsl:apply-templates select="../*[local-name()='thead']" mode="process"/>
375
+ <xsl:apply-templates />
376
+ <xsl:apply-templates select="../*[local-name()='tfoot']" mode="process"/>
377
+ <!-- if there are note(s) or fn(s) then create footer row -->
378
+ <xsl:if test="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']">
379
+ <fo:table-row>
380
+ <fo:table-cell border="solid black 1pt" padding-left="1mm" padding-right="1mm" padding-top="1mm" number-columns-spanned="{$cols-count}">
381
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
382
+ <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>
383
+ </xsl:if>
384
+ <!-- fn will be processed inside 'note' processing -->
385
+ <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
386
+ <!-- fn processing -->
387
+ <xsl:call-template name="fn_display" />
388
+
389
+ </fo:table-cell>
390
+ </fo:table-row>
391
+
392
+ </xsl:if>
393
+ </fo:table-body>
394
+ </xsl:template>
395
+
396
+ <!--
397
+ <xsl:template match="*[local-name()='thead']/*[local-name()='tr']">
398
+ <fo:table-row font-weight="bold" min-height="4mm" >
399
+ <xsl:apply-templates />
400
+ </fo:table-row>
401
+ </xsl:template> -->
402
+
403
+ <xsl:template match="*[local-name()='tr']">
404
+ <xsl:variable name="parent-name" select="local-name(..)"/>
405
+ <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
406
+ <fo:table-row min-height="4mm">
407
+ <xsl:if test="$parent-name = 'thead'">
408
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
409
+ <xsl:if test="$namespace = 'nist'">
410
+ <xsl:attribute name="font-family">Arial</xsl:attribute>
411
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
412
+ </xsl:if>
413
+ <xsl:choose>
414
+ <xsl:when test="($namespace = 'iso' or $namespace = 'iec') and position() = 1">
415
+ <xsl:attribute name="border-top">solid black 1.5pt</xsl:attribute>
416
+ <xsl:attribute name="border-bottom">solid black 1pt</xsl:attribute>
417
+ </xsl:when>
418
+ <xsl:when test="($namespace = 'iso' or $namespace = 'iec') and position() = last()">
419
+ <xsl:attribute name="border-top">solid black 1pt</xsl:attribute>
420
+ <xsl:attribute name="border-bottom">solid black 1.5pt</xsl:attribute>
421
+ </xsl:when>
422
+ <xsl:when test="$namespace = 'iso' or $namespace = 'iec'">
423
+ <xsl:attribute name="border-top">solid black 1pt</xsl:attribute>
424
+ <xsl:attribute name="border-bottom">solid black 1pt</xsl:attribute>
425
+ </xsl:when>
426
+ </xsl:choose>
427
+ </xsl:if>
428
+ <xsl:if test="$parent-name = 'tfoot'">
429
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
430
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
431
+ <xsl:attribute name="border-left">solid black 1pt</xsl:attribute>
432
+ <xsl:attribute name="border-right">solid black 1pt</xsl:attribute>
433
+ </xsl:if>
434
+ </xsl:if>
435
+ <xsl:apply-templates />
436
+ </fo:table-row>
437
+ </xsl:template>
438
+
439
+
440
+ <xsl:template match="*[local-name()='th']">
441
+ <fo:table-cell text-align="{@align}" font-weight="bold" border="solid black 1pt" padding-left="1mm" display-align="center">
442
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
443
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
444
+ </xsl:if>
445
+ <xsl:if test="$namespace = 'nist'">
446
+ <xsl:attribute name="text-align">center</xsl:attribute>
447
+ <xsl:attribute name="background-color">black</xsl:attribute>
448
+ <xsl:attribute name="color">white</xsl:attribute>
449
+ </xsl:if>
450
+ <xsl:if test="$namespace = 'unece' and ancestor::*[local-name()='sections'] and $unece-rec = 'true'">
451
+ <xsl:attribute name="border">solid black 0pt</xsl:attribute>
452
+ <xsl:attribute name="display-align">before</xsl:attribute>
453
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
454
+ </xsl:if>
455
+ <xsl:if test="$namespace = 'unece' and ancestor::*[local-name()='annex'] and $unece-rec = 'true'">
456
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
457
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
458
+ <xsl:attribute name="background-color">rgb(218, 218, 218)</xsl:attribute>
459
+ <xsl:if test="starts-with(text(), '1') or starts-with(text(), '2') or starts-with(text(), '3') or starts-with(text(), '4') or starts-with(text(), '5') or
460
+ starts-with(text(), '6') or starts-with(text(), '7') or starts-with(text(), '8') or starts-with(text(), '9')">
461
+ <xsl:attribute name="color">rgb(46, 116, 182)</xsl:attribute>
462
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
463
+ </xsl:if>
464
+ </xsl:if>
465
+ <xsl:if test="@colspan">
466
+ <xsl:attribute name="number-columns-spanned">
467
+ <xsl:value-of select="@colspan"/>
468
+ </xsl:attribute>
469
+ </xsl:if>
470
+ <xsl:if test="@rowspan">
471
+ <xsl:attribute name="number-rows-spanned">
472
+ <xsl:value-of select="@rowspan"/>
473
+ </xsl:attribute>
474
+ </xsl:if>
475
+ <fo:block>
476
+ <xsl:apply-templates />
477
+ </fo:block>
478
+ </fo:table-cell>
479
+ </xsl:template>
480
+
481
+
482
+ <xsl:template match="*[local-name()='td']">
483
+ <fo:table-cell text-align="{@align}" display-align="center" border="solid black 1pt" padding-left="1mm">
484
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'"> <!-- and ancestor::*[local-name() = 'thead'] -->
485
+ <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
486
+ </xsl:if>
487
+ <xsl:if test="($namespace = 'iso' or $namespace = 'iec') and ancestor::*[local-name() = 'tfoot']">
488
+ <xsl:attribute name="border">solid black 0</xsl:attribute>
489
+ </xsl:if>
490
+ <xsl:if test="$namespace = 'unece' and ancestor::*[local-name()='sections'] and $unece-rec = 'true'">
491
+ <xsl:attribute name="border">solid black 0pt</xsl:attribute>
492
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
493
+ </xsl:if>
494
+ <xsl:if test="@colspan">
495
+ <xsl:attribute name="number-columns-spanned">
496
+ <xsl:value-of select="@colspan"/>
497
+ </xsl:attribute>
498
+ </xsl:if>
499
+ <xsl:if test="@rowspan">
500
+ <xsl:attribute name="number-rows-spanned">
501
+ <xsl:value-of select="@rowspan"/>
502
+ </xsl:attribute>
503
+ </xsl:if>
504
+ <fo:block>
505
+ <xsl:apply-templates />
506
+ </fo:block>
507
+ <!-- <xsl:choose>
508
+ <xsl:when test="count(*) = 1 and *[local-name() = 'p']">
509
+ <xsl:apply-templates />
510
+ </xsl:when>
511
+ <xsl:otherwise>
512
+ <fo:block>
513
+ <xsl:apply-templates />
514
+ </fo:block>
515
+ </xsl:otherwise>
516
+ </xsl:choose> -->
517
+
518
+
519
+ </fo:table-cell>
520
+ </xsl:template>
521
+
522
+
523
+ <xsl:template match="*[local-name()='table']/*[local-name()='note']"/>
524
+ <xsl:template match="*[local-name()='table']/*[local-name()='note']" mode="process">
525
+
526
+
527
+ <fo:block font-size="10pt" margin-bottom="12pt">
528
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
529
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
530
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
531
+ </xsl:if>
532
+ <fo:inline padding-right="2mm">NOTE <xsl:number format="1 "/></fo:inline>
533
+ <xsl:apply-templates mode="process"/>
534
+ </fo:block>
535
+
536
+ </xsl:template>
537
+
538
+ <xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='p']" mode="process">
539
+ <xsl:apply-templates/>
540
+ </xsl:template>
541
+
542
+
543
+ <xsl:template name="fn_display">
544
+ <xsl:variable name="references">
545
+ <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
546
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
547
+ <xsl:apply-templates />
548
+ </fn>
549
+ </xsl:for-each>
550
+ </xsl:variable>
551
+ <xsl:for-each select="xalan:nodeset($references)//fn">
552
+ <xsl:variable name="reference" select="@reference"/>
553
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
554
+ <fo:block margin-bottom="12pt">
555
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
556
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
557
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
558
+ </xsl:if>
559
+ <fo:inline font-size="80%" padding-right="5mm" id="{@id}">
560
+ <xsl:if test="$namespace != 'iso' and $namespace != 'iec'">
561
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
562
+ </xsl:if>
563
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
564
+ <xsl:attribute name="alignment-baseline">hanging</xsl:attribute>
565
+ </xsl:if>
566
+ <xsl:value-of select="@reference"/>
567
+ </fo:inline>
568
+ <xsl:apply-templates />
569
+ </fo:block>
570
+ </xsl:if>
571
+ </xsl:for-each>
572
+ </xsl:template>
573
+
574
+ <xsl:template name="fn_name_display">
575
+ <!-- <xsl:variable name="references">
576
+ <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
577
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
578
+ <xsl:apply-templates />
579
+ </fn>
580
+ </xsl:for-each>
581
+ </xsl:variable>
582
+ $references=<xsl:copy-of select="$references"/> -->
583
+ <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
584
+ <xsl:variable name="reference" select="@reference"/>
585
+ <fo:block id="{@reference}_{ancestor::*[@id][1]/@id}"><xsl:value-of select="@reference"/></fo:block>
586
+ <fo:block margin-bottom="12pt">
587
+ <xsl:apply-templates />
588
+ </fo:block>
589
+ </xsl:for-each>
590
+ </xsl:template>
591
+
592
+
593
+ <xsl:template name="fn_display_figure">
594
+ <xsl:variable name="key_iso">
595
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">true</xsl:if> <!-- and (not(@class) or @class !='pseudocode') -->
596
+ </xsl:variable>
597
+ <xsl:variable name="references">
598
+ <xsl:for-each select=".//*[local-name()='fn']">
599
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
600
+ <xsl:apply-templates />
601
+ </fn>
602
+ </xsl:for-each>
603
+ </xsl:variable>
604
+ <xsl:if test="xalan:nodeset($references)//fn">
605
+ <fo:block>
606
+ <fo:table width="95%" table-layout="fixed">
607
+ <xsl:if test="$key_iso = 'true'">
608
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
609
+ </xsl:if>
610
+ <fo:table-column column-width="15%"/>
611
+ <fo:table-column column-width="85%"/>
612
+ <fo:table-body>
613
+ <xsl:for-each select="xalan:nodeset($references)//fn">
614
+ <xsl:variable name="reference" select="@reference"/>
615
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
616
+ <fo:table-row>
617
+ <fo:table-cell>
618
+ <fo:block>
619
+ <fo:inline font-size="80%" padding-right="5mm" vertical-align="super" id="{@id}">
620
+ <xsl:value-of select="@reference"/>
621
+ </fo:inline>
622
+ </fo:block>
623
+ </fo:table-cell>
624
+ <fo:table-cell>
625
+ <fo:block text-align="justify" margin-bottom="12pt">
626
+ <xsl:if test="$key_iso = 'true'">
627
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
628
+ </xsl:if>
629
+ <xsl:apply-templates />
630
+ </fo:block>
631
+ </fo:table-cell>
632
+ </fo:table-row>
633
+ </xsl:if>
634
+ </xsl:for-each>
635
+ </fo:table-body>
636
+ </fo:table>
637
+ </fo:block>
638
+ </xsl:if>
639
+
640
+ </xsl:template>
641
+
642
+ <!-- *[local-name()='table']// -->
643
+ <xsl:template match="*[local-name()='fn']">
644
+ <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
645
+ <fo:inline font-size="80%" keep-with-previous.within-line="always">
646
+ <xsl:if test="($namespace = 'iso' or $namespace = 'iec') and ancestor::*[local-name()='td']">
647
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
648
+ <!-- <xsl:attribute name="alignment-baseline">hanging</xsl:attribute> -->
649
+ <xsl:attribute name="baseline-shift">15%</xsl:attribute>
650
+ </xsl:if>
651
+ <xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
652
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
653
+ <xsl:attribute name="color">blue</xsl:attribute>
654
+ </xsl:if>
655
+ <xsl:if test="$namespace = 'nist'">
656
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
657
+ </xsl:if>
658
+ <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
659
+ <xsl:value-of select="@reference"/>
660
+ </fo:basic-link>
661
+ </fo:inline>
662
+ </xsl:template>
663
+
664
+
665
+ <xsl:template match="*[local-name()='fn']/*[local-name()='p']">
666
+ <fo:inline>
667
+ <xsl:apply-templates />
668
+ </fo:inline>
669
+ </xsl:template>
670
+
671
+ <xsl:template match="*[local-name()='dl']">
672
+ <xsl:variable name="parent" select="local-name(..)"/>
673
+
674
+ <xsl:variable name="key_iso">
675
+ <xsl:if test="($namespace = 'iso' or $namespace = 'iec') and ($parent = 'figure' or $parent = 'formula')">true</xsl:if> <!-- and (not(../@class) or ../@class !='pseudocode') -->
676
+ </xsl:variable>
677
+
678
+ <xsl:choose>
679
+ <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
680
+ <fo:block margin-bottom="12pt">
681
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
682
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
683
+ </xsl:if>
684
+ <xsl:text>where </xsl:text>
685
+ <xsl:apply-templates select="*[local-name()='dt']/*"/>
686
+ <xsl:text></xsl:text>
687
+ <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
688
+ </fo:block>
689
+ </xsl:when>
690
+ <xsl:when test="$parent = 'formula'"> <!-- a few components -->
691
+ <fo:block margin-bottom="12pt">
692
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
693
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
694
+ </xsl:if>
695
+ <xsl:text>where</xsl:text>
696
+ </fo:block>
697
+ </xsl:when>
698
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
699
+ <fo:block font-weight="bold" text-align="left" margin-bottom="12pt">
700
+ <xsl:if test="$namespace = 'iso' or $namespace = 'iec'">
701
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
702
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
703
+ </xsl:if>
704
+ <xsl:text>Key</xsl:text>
705
+ </fo:block>
706
+ </xsl:when>
707
+ </xsl:choose>
708
+
709
+ <!-- a few components -->
710
+ <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
711
+ <fo:block>
712
+ <xsl:if test="$namespace ='iso' and $parent = 'formula'">
713
+ <xsl:attribute name="margin-left">4mm</xsl:attribute>
714
+ </xsl:if>
715
+ <xsl:if test="$namespace = 'itu' and local-name(..) = 'li'">
716
+ <xsl:attribute name="margin-left">-4mm</xsl:attribute>
717
+ </xsl:if>
718
+ <xsl:if test="$namespace = 'nist' and not(.//*[local-name()='dt']//*[local-name()='stem'])">
719
+ <xsl:attribute name="margin-left">5mm</xsl:attribute>
720
+ </xsl:if>
721
+
722
+ <fo:block>
723
+ <xsl:if test="$namespace = 'nist' and not(.//*[local-name()='dt']//*[local-name()='stem'])">
724
+ <xsl:attribute name="margin-left">-2.5mm</xsl:attribute>
725
+ </xsl:if>
726
+
727
+ <!-- create virtual html table for dl/[dt and dd] -->
728
+ <xsl:variable name="html-table">
729
+ <xsl:element name="{$namespace}:table">
730
+ <tbody>
731
+ <xsl:apply-templates mode="dl"/>
732
+ </tbody>
733
+ </xsl:element>
734
+ </xsl:variable>
735
+
736
+ <xsl:variable name="colwidths">
737
+ <xsl:call-template name="calculate-column-widths">
738
+ <xsl:with-param name="cols-count" select="2"/>
739
+ <xsl:with-param name="table" select="$html-table"/>
740
+ </xsl:call-template>
741
+ </xsl:variable>
742
+ <!-- colwidths=<xsl:value-of select="$colwidths"/> -->
743
+
744
+ <fo:table width="95%" table-layout="fixed">
745
+ <xsl:choose>
746
+ <xsl:when test="$key_iso = 'true' and $parent = 'formula'">
747
+ <!-- <xsl:attribute name="font-size">11pt</xsl:attribute> -->
748
+ </xsl:when>
749
+ <xsl:when test="$key_iso = 'true'">
750
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
751
+ </xsl:when>
752
+ </xsl:choose>
753
+ <xsl:choose>
754
+ <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
755
+ <fo:table-column column-width="50%"/>
756
+ <fo:table-column column-width="50%"/>
757
+ </xsl:when>
758
+ <xsl:otherwise>
759
+ <xsl:choose>
760
+ <!-- <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 1.7">
761
+ <fo:table-column column-width="60%"/>
762
+ <fo:table-column column-width="40%"/>
763
+ </xsl:when> -->
764
+ <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 1.3">
765
+ <fo:table-column column-width="50%"/>
766
+ <fo:table-column column-width="50%"/>
767
+ </xsl:when>
768
+ <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 0.5">
769
+ <fo:table-column column-width="40%"/>
770
+ <fo:table-column column-width="60%"/>
771
+ </xsl:when>
772
+ <xsl:otherwise>
773
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
774
+ <xsl:choose>
775
+ <xsl:when test=". = 1">
776
+ <fo:table-column column-width="proportional-column-width(2)"/>
777
+ </xsl:when>
778
+ <xsl:otherwise>
779
+ <fo:table-column column-width="proportional-column-width({.})"/>
780
+ </xsl:otherwise>
781
+ </xsl:choose>
782
+ </xsl:for-each>
783
+ </xsl:otherwise>
784
+ </xsl:choose>
785
+ <!-- <fo:table-column column-width="15%"/>
786
+ <fo:table-column column-width="85%"/> -->
787
+ </xsl:otherwise>
788
+ </xsl:choose>
789
+ <fo:table-body>
790
+ <xsl:apply-templates>
791
+ <xsl:with-param name="key_iso" select="$key_iso"/>
792
+ </xsl:apply-templates>
793
+ </fo:table-body>
794
+ </fo:table>
795
+ </fo:block>
796
+ </fo:block>
797
+ </xsl:if>
798
+ </xsl:template>
799
+
800
+ <xsl:template match="*[local-name()='dl']/*[local-name()='note']">
801
+ <xsl:param name="key_iso"/>
802
+
803
+ <!-- <tr>
804
+ <td>NOTE</td>
805
+ <td>
806
+ <xsl:apply-templates />
807
+ </td>
808
+ </tr>
809
+ -->
810
+ <fo:table-row>
811
+ <fo:table-cell>
812
+ <fo:block margin-top="6pt">
813
+ <xsl:if test="$key_iso = 'true'">
814
+ <xsl:attribute name="margin-top">0</xsl:attribute>
815
+ </xsl:if>
816
+ NOTE
817
+ </fo:block>
818
+ </fo:table-cell>
819
+ <fo:table-cell>
820
+ <fo:block>
821
+ <xsl:apply-templates />
822
+ </fo:block>
823
+ </fo:table-cell>
824
+ </fo:table-row>
825
+ </xsl:template>
826
+
827
+ <xsl:template match="*[local-name()='dt']" mode="dl">
828
+ <tr>
829
+ <td>
830
+ <xsl:apply-templates />
831
+ </td>
832
+ <td>
833
+ <xsl:choose>
834
+ <xsl:when test="$namespace = 'nist'">
835
+ <xsl:if test="local-name(*[1]) != 'stem'">
836
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
837
+ </xsl:if>
838
+ </xsl:when>
839
+ <xsl:otherwise>
840
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
841
+ </xsl:otherwise>
842
+ </xsl:choose>
843
+ </td>
844
+ </tr>
845
+ <xsl:if test="local-name(*[1]) = 'stem' and $namespace = 'nist' ">
846
+ <tr>
847
+ <td>
848
+ <xsl:text>&#xA0;</xsl:text>
849
+ </td>
850
+ <td>
851
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="dl_process"/>
852
+ </td>
853
+ </tr>
854
+ </xsl:if>
855
+ </xsl:template>
856
+
857
+ <xsl:template match="*[local-name()='dt']">
858
+ <xsl:param name="key_iso"/>
859
+
860
+ <fo:table-row>
861
+ <fo:table-cell>
862
+ <fo:block margin-top="6pt">
863
+ <xsl:if test="$key_iso = 'true'">
864
+ <xsl:attribute name="margin-top">0</xsl:attribute>
865
+ </xsl:if>
866
+ <xsl:if test="$namespace = 'nist'">
867
+ <xsl:attribute name="margin-top">0</xsl:attribute>
868
+ <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
869
+ </xsl:if>
870
+ <xsl:apply-templates />
871
+ </fo:block>
872
+ </fo:table-cell>
873
+ <fo:table-cell>
874
+ <fo:block>
875
+ <xsl:choose>
876
+ <xsl:when test="$namespace = 'nist'">
877
+ <xsl:if test="local-name(*[1]) != 'stem'">
878
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
879
+ </xsl:if>
880
+ </xsl:when>
881
+ <xsl:otherwise>
882
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
883
+ </xsl:otherwise>
884
+ </xsl:choose>
885
+ </fo:block>
886
+ </fo:table-cell>
887
+ </fo:table-row>
888
+ <xsl:if test="local-name(*[1]) = 'stem' and $namespace = 'nist' ">
889
+ <fo:table-row>
890
+ <fo:table-cell>
891
+ <fo:block margin-top="6pt">
892
+ <xsl:if test="$key_iso = 'true'">
893
+ <xsl:attribute name="margin-top">0</xsl:attribute>
894
+ </xsl:if>
895
+ <xsl:text>&#xA0;</xsl:text>
896
+ </fo:block>
897
+ </fo:table-cell>
898
+ <fo:table-cell>
899
+ <fo:block>
900
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
901
+ </fo:block>
902
+ </fo:table-cell>
903
+ </fo:table-row>
904
+ </xsl:if>
905
+ </xsl:template>
906
+
907
+ <xsl:template match="*[local-name()='dd']" mode="dl"/>
908
+ <xsl:template match="*[local-name()='dd']" mode="dl_process">
909
+ <xsl:apply-templates />
910
+ </xsl:template>
911
+
912
+ <xsl:template match="*[local-name()='dd']"/>
913
+ <xsl:template match="*[local-name()='dd']" mode="process">
914
+ <xsl:apply-templates />
915
+ </xsl:template>
916
+
917
+ <xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
918
+ <fo:inline><xsl:apply-templates /></fo:inline>
919
+ </xsl:template>
920
+
921
+ <xsl:template match="*[local-name()='em']">
922
+ <fo:inline font-style="italic">
923
+ <xsl:apply-templates />
924
+ </fo:inline>
925
+ </xsl:template>
926
+
927
+ <xsl:template match="*[local-name()='strong']">
928
+ <fo:inline font-weight="bold">
929
+ <xsl:apply-templates />
930
+ </fo:inline>
931
+ </xsl:template>
932
+
933
+ <xsl:template match="*[local-name()='sup']">
934
+ <fo:inline font-size="80%" vertical-align="super">
935
+ <xsl:apply-templates />
936
+ </fo:inline>
937
+ </xsl:template>
938
+
939
+ <xsl:template match="*[local-name()='sub']">
940
+ <fo:inline font-size="80%" vertical-align="sub">
941
+ <xsl:apply-templates />
942
+ </fo:inline>
943
+ </xsl:template>
944
+
945
+ <xsl:template match="*[local-name()='tt']">
946
+ <fo:inline font-family="Courier" font-size="10pt">
947
+ <xsl:apply-templates />
948
+ </fo:inline>
949
+ </xsl:template>
950
+
951
+ <xsl:template match="*[local-name()='del']">
952
+ <fo:inline font-size="10pt" color="red" text-decoration="line-through">
953
+ <xsl:apply-templates />
954
+ </fo:inline>
955
+ </xsl:template>
956
+
957
+ <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
958
+ <xsl:variable name="text" select="normalize-space(.)"/>
959
+ <fo:inline font-size="75%">
960
+ <xsl:if test="string-length($text) &gt; 0">
961
+ <xsl:call-template name="recursiveSmallCaps">
962
+ <xsl:with-param name="text" select="$text"/>
963
+ </xsl:call-template>
964
+ </xsl:if>
965
+ </fo:inline>
966
+ </xsl:template>
967
+
968
+ <xsl:template name="recursiveSmallCaps">
969
+ <xsl:param name="text"/>
970
+ <xsl:variable name="char" select="substring($text,1,1)"/>
971
+ <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/>
972
+ <xsl:choose>
973
+ <xsl:when test="$char=$upperCase">
974
+ <fo:inline font-size="{100 div 0.75}%">
975
+ <xsl:value-of select="$upperCase"/>
976
+ </fo:inline>
977
+ </xsl:when>
978
+ <xsl:otherwise>
979
+ <xsl:value-of select="$upperCase"/>
980
+ </xsl:otherwise>
981
+ </xsl:choose>
982
+ <xsl:if test="string-length($text) &gt; 1">
983
+ <xsl:call-template name="recursiveSmallCaps">
984
+ <xsl:with-param name="text" select="substring($text,2)"/>
985
+ </xsl:call-template>
986
+ </xsl:if>
987
+ </xsl:template>
988
+
989
+ <!-- split string 'text' by 'separator' -->
990
+ <xsl:template name="tokenize">
991
+ <xsl:param name="text"/>
992
+ <xsl:param name="separator" select="' '"/>
993
+ <xsl:choose>
994
+ <xsl:when test="not(contains($text, $separator))">
995
+ <word>
996
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
997
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
998
+ <xsl:variable name="len_str" select="string-length(normalize-space($text))"/>
999
+
1000
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
1001
+ <xsl:message>
1002
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
1003
+ len_str=<xsl:value-of select="$len_str"/>
1004
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
1005
+ </xsl:message>
1006
+ </xsl:if> -->
1007
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
1008
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
1009
+ <xsl:choose>
1010
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
1011
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
1012
+ </xsl:when>
1013
+ <xsl:otherwise>
1014
+ <xsl:value-of select="$len_str"/>
1015
+ </xsl:otherwise>
1016
+ </xsl:choose>
1017
+ </word>
1018
+ </xsl:when>
1019
+ <xsl:otherwise>
1020
+ <word>
1021
+ <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
1022
+ </word>
1023
+ <xsl:call-template name="tokenize">
1024
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
1025
+ </xsl:call-template>
1026
+ </xsl:otherwise>
1027
+ </xsl:choose>
1028
+ </xsl:template>
1029
+
1030
+ <!-- get max value in array -->
1031
+ <xsl:template name="max_length">
1032
+ <xsl:param name="words"/>
1033
+ <xsl:for-each select="$words//word">
1034
+ <xsl:sort select="." data-type="number" order="descending"/>
1035
+ <xsl:if test="position()=1">
1036
+ <xsl:value-of select="."/>
1037
+ </xsl:if>
1038
+ </xsl:for-each>
1039
+ </xsl:template>
1040
+
1041
+ <!-- add zero space after dash character (for table's entries) -->
1042
+ <xsl:template name="add-zero-spaces">
1043
+ <xsl:param name="text" select="."/>
1044
+ <xsl:variable name="zero-space-after-chars">&#x002D;</xsl:variable>
1045
+ <xsl:variable name="zero-space-after-dot">.</xsl:variable>
1046
+ <xsl:variable name="zero-space-after-colon">:</xsl:variable>
1047
+ <xsl:variable name="zero-space">&#x200B;</xsl:variable>
1048
+ <xsl:choose>
1049
+ <xsl:when test="contains($text, $zero-space-after-chars)">
1050
+ <xsl:value-of select="substring-before($text, $zero-space-after-chars)"/>
1051
+ <xsl:value-of select="$zero-space-after-chars"/>
1052
+ <xsl:value-of select="$zero-space"/>
1053
+ <xsl:call-template name="add-zero-spaces">
1054
+ <xsl:with-param name="text" select="substring-after($text, $zero-space-after-chars)"/>
1055
+ </xsl:call-template>
1056
+ </xsl:when>
1057
+ <xsl:when test="contains($text, $zero-space-after-dot)">
1058
+ <xsl:value-of select="substring-before($text, $zero-space-after-dot)"/>
1059
+ <xsl:value-of select="$zero-space-after-dot"/>
1060
+ <xsl:value-of select="$zero-space"/>
1061
+ <xsl:call-template name="add-zero-spaces">
1062
+ <xsl:with-param name="text" select="substring-after($text, $zero-space-after-dot)"/>
1063
+ </xsl:call-template>
1064
+ </xsl:when>
1065
+ <xsl:when test="contains($text, $zero-space-after-colon)">
1066
+ <xsl:value-of select="substring-before($text, $zero-space-after-colon)"/>
1067
+ <xsl:value-of select="$zero-space-after-colon"/>
1068
+ <xsl:value-of select="$zero-space"/>
1069
+ <xsl:call-template name="add-zero-spaces">
1070
+ <xsl:with-param name="text" select="substring-after($text, $zero-space-after-colon)"/>
1071
+ </xsl:call-template>
1072
+ </xsl:when>
1073
+ <xsl:otherwise>
1074
+ <xsl:value-of select="$text"/>
1075
+ </xsl:otherwise>
1076
+ </xsl:choose>
1077
+ </xsl:template>
1078
+
1079
+ <!-- Table normalization (colspan,rowspan processing for adding TDs) for column width calculation -->
1080
+ <xsl:template name="getSimpleTable">
1081
+ <xsl:variable name="simple-table">
1082
+
1083
+ <!-- Step 1. colspan processing -->
1084
+ <xsl:variable name="simple-table-colspan">
1085
+ <tbody>
1086
+ <xsl:apply-templates mode="simple-table-colspan"/>
1087
+ </tbody>
1088
+ </xsl:variable>
1089
+
1090
+ <!-- Step 2. rowspan processing -->
1091
+ <xsl:variable name="simple-table-rowspan">
1092
+ <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
1093
+ </xsl:variable>
1094
+
1095
+ <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
1096
+
1097
+ <!-- <xsl:choose>
1098
+ <xsl:when test="current()//*[local-name()='th'][@colspan] or current()//*[local-name()='td'][@colspan] ">
1099
+
1100
+ </xsl:when>
1101
+ <xsl:otherwise>
1102
+ <xsl:copy-of select="current()"/>
1103
+ </xsl:otherwise>
1104
+ </xsl:choose> -->
1105
+ </xsl:variable>
1106
+ <xsl:copy-of select="$simple-table"/>
1107
+ </xsl:template>
1108
+
1109
+ <!-- ===================== -->
1110
+ <!-- 1. mode "simple-table-colspan"
1111
+ 1.1. remove thead, tbody, fn
1112
+ 1.2. rename th -> td
1113
+ 1.3. repeating N td with colspan=N
1114
+ 1.4. remove namespace
1115
+ 1.5. remove @colspan attribute
1116
+ 1.6. add @divide attribute for divide text width in further processing
1117
+ -->
1118
+ <!-- ===================== -->
1119
+ <xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
1120
+ <xsl:apply-templates mode="simple-table-colspan"/>
1121
+ </xsl:template>
1122
+ <xsl:template match="*[local-name()='fn']" mode="simple-table-colspan"/>
1123
+
1124
+ <xsl:template match="*[local-name()='th'] | *[local-name()='td']" mode="simple-table-colspan">
1125
+ <xsl:choose>
1126
+ <xsl:when test="@colspan">
1127
+ <xsl:variable name="td">
1128
+ <xsl:element name="td">
1129
+ <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
1130
+ <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
1131
+ <xsl:apply-templates mode="simple-table-colspan"/>
1132
+ </xsl:element>
1133
+ </xsl:variable>
1134
+ <xsl:call-template name="repeatNode">
1135
+ <xsl:with-param name="count" select="@colspan"/>
1136
+ <xsl:with-param name="node" select="$td"/>
1137
+ </xsl:call-template>
1138
+ </xsl:when>
1139
+ <xsl:otherwise>
1140
+ <xsl:element name="td">
1141
+ <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
1142
+ <xsl:apply-templates mode="simple-table-colspan"/>
1143
+ </xsl:element>
1144
+ </xsl:otherwise>
1145
+ </xsl:choose>
1146
+ </xsl:template>
1147
+
1148
+ <xsl:template match="@colspan" mode="simple-table-colspan"/>
1149
+
1150
+ <xsl:template match="*[local-name()='tr']" mode="simple-table-colspan">
1151
+ <xsl:element name="tr">
1152
+ <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
1153
+ <xsl:apply-templates mode="simple-table-colspan"/>
1154
+ </xsl:element>
1155
+ </xsl:template>
1156
+
1157
+ <xsl:template match="@*|node()" mode="simple-table-colspan">
1158
+ <xsl:copy>
1159
+ <xsl:apply-templates select="@*|node()" mode="simple-table-colspan"/>
1160
+ </xsl:copy>
1161
+ </xsl:template>
1162
+
1163
+ <!-- repeat node 'count' times -->
1164
+ <xsl:template name="repeatNode">
1165
+ <xsl:param name="count"/>
1166
+ <xsl:param name="node"/>
1167
+
1168
+ <xsl:if test="$count &gt; 0">
1169
+ <xsl:call-template name="repeatNode">
1170
+ <xsl:with-param name="count" select="$count - 1"/>
1171
+ <xsl:with-param name="node" select="$node"/>
1172
+ </xsl:call-template>
1173
+ <xsl:copy-of select="$node"/>
1174
+ </xsl:if>
1175
+ </xsl:template>
1176
+ <!-- End mode simple-table-colspan -->
1177
+ <!-- ===================== -->
1178
+ <!-- ===================== -->
1179
+
1180
+ <!-- ===================== -->
1181
+ <!-- 2. mode "simple-table-rowspan"
1182
+ Row span processing, more information http://andrewjwelch.com/code/xslt/table/table-normalization.html -->
1183
+ <!-- ===================== -->
1184
+ <xsl:template match="@*|node()" mode="simple-table-rowspan">
1185
+ <xsl:copy>
1186
+ <xsl:apply-templates select="@*|node()" mode="simple-table-rowspan"/>
1187
+ </xsl:copy>
1188
+ </xsl:template>
1189
+
1190
+ <xsl:template match="tbody" mode="simple-table-rowspan">
1191
+ <xsl:copy>
1192
+ <xsl:copy-of select="tr[1]" />
1193
+ <xsl:apply-templates select="tr[2]" mode="simple-table-rowspan">
1194
+ <xsl:with-param name="previousRow" select="tr[1]" />
1195
+ </xsl:apply-templates>
1196
+ </xsl:copy>
1197
+ </xsl:template>
1198
+
1199
+ <xsl:template match="tr" mode="simple-table-rowspan">
1200
+ <xsl:param name="previousRow"/>
1201
+ <xsl:variable name="currentRow" select="." />
1202
+
1203
+ <xsl:variable name="normalizedTDs">
1204
+ <xsl:for-each select="xalan:nodeset($previousRow)//td">
1205
+ <xsl:choose>
1206
+ <xsl:when test="@rowspan &gt; 1">
1207
+ <xsl:copy>
1208
+ <xsl:attribute name="rowspan">
1209
+ <xsl:value-of select="@rowspan - 1" />
1210
+ </xsl:attribute>
1211
+ <xsl:copy-of select="@*[not(name() = 'rowspan')]" />
1212
+ <xsl:copy-of select="node()" />
1213
+ </xsl:copy>
1214
+ </xsl:when>
1215
+ <xsl:otherwise>
1216
+ <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]" />
1217
+ </xsl:otherwise>
1218
+ </xsl:choose>
1219
+ </xsl:for-each>
1220
+ </xsl:variable>
1221
+
1222
+ <xsl:variable name="newRow">
1223
+ <xsl:copy>
1224
+ <xsl:copy-of select="$currentRow/@*" />
1225
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)" />
1226
+ </xsl:copy>
1227
+ </xsl:variable>
1228
+ <xsl:copy-of select="$newRow" />
1229
+
1230
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
1231
+ <xsl:with-param name="previousRow" select="$newRow" />
1232
+ </xsl:apply-templates>
1233
+ </xsl:template>
1234
+ <!-- End mode simple-table-rowspan -->
1235
+ <!-- ===================== -->
1236
+ <!-- ===================== -->
1237
+
1238
+ <xsl:template name="getLang">
1239
+ <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
1240
+ <xsl:choose>
1241
+ <xsl:when test="$language = 'English'">en</xsl:when>
1242
+ <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
1243
+ </xsl:choose>
1244
+ </xsl:template>
1245
+
1246
+ </xsl:stylesheet>