metanorma-nist 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1656,6 +1656,9 @@
1656
1656
  <xsl:when test="local-name(..) = 'ul'">•</xsl:when>
1657
1657
  <xsl:otherwise> <!-- for ordered lists -->
1658
1658
  <xsl:choose>
1659
+ <xsl:when test="../@class = 'steps'">
1660
+ <xsl:number format="1."/>
1661
+ </xsl:when>
1659
1662
  <xsl:when test="../@type = 'arabic'">
1660
1663
  <xsl:number format="a)"/>
1661
1664
  </xsl:when>
@@ -1843,27 +1846,26 @@
1843
1846
  </xsl:template>
1844
1847
 
1845
1848
  <xsl:template match="nist:references">
1846
- <fo:block break-after="page"/>
1847
1849
  <fo:block id="{@id}">
1848
1850
  <xsl:apply-templates/>
1849
1851
  </fo:block>
1850
1852
  </xsl:template>
1851
1853
 
1852
- <xsl:template match="nist:dl[@type = 'glossary']" priority="2">
1853
- <xsl:apply-templates/>
1854
+ <!-- <xsl:template match="nist:dl[@type = 'glossary']" priority="2">
1855
+ <xsl:apply-templates />
1854
1856
  </xsl:template>
1855
1857
 
1856
- <xsl:template match="nist:dt[../@type = 'glossary']" priority="2">
1858
+ <xsl:template match="nist:dt[../@type = 'glossary']" priority="2">
1857
1859
  <fo:block margin-bottom="12pt">
1858
- <xsl:apply-templates/>
1860
+ <xsl:apply-templates />
1859
1861
  </fo:block>
1860
1862
  </xsl:template>
1861
1863
 
1862
- <xsl:template match="nist:dd[../@type = 'glossary']" priority="2">
1864
+ <xsl:template match="nist:dd[../@type = 'glossary']" priority="2">
1863
1865
  <fo:block margin-bottom="12pt" margin-left="12.7mm">
1864
- <xsl:apply-templates/>
1866
+ <xsl:apply-templates />
1865
1867
  </fo:block>
1866
- </xsl:template>
1868
+ </xsl:template> -->
1867
1869
 
1868
1870
  <xsl:template name="insertHeaderFooter">
1869
1871
  <xsl:call-template name="insertHeader"/>
@@ -3439,16 +3441,18 @@
3439
3441
  <fo:table-cell>
3440
3442
  <fo:block>
3441
3443
 
3442
-
3444
+ <!-- <xsl:if test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
3443
3445
  <xsl:if test="local-name(*[1]) != 'stem'">
3444
3446
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
3445
3447
  </xsl:if>
3448
+ </xsl:if> -->
3446
3449
 
3450
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
3447
3451
 
3448
3452
  </fo:block>
3449
3453
  </fo:table-cell>
3450
3454
  </fo:table-row>
3451
-
3455
+ <!-- <xsl:if test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
3452
3456
  <xsl:if test="local-name(*[1]) = 'stem'">
3453
3457
  <fo:table-row>
3454
3458
  <fo:table-cell>
@@ -3456,7 +3460,7 @@
3456
3460
  <xsl:if test="normalize-space($key_iso) = 'true'">
3457
3461
  <xsl:attribute name="margin-top">0</xsl:attribute>
3458
3462
  </xsl:if>
3459
- <xsl:text> </xsl:text>
3463
+ <xsl:text>&#xA0;</xsl:text>
3460
3464
  </fo:block>
3461
3465
  </fo:table-cell>
3462
3466
  <fo:table-cell>
@@ -3466,7 +3470,7 @@
3466
3470
  </fo:table-cell>
3467
3471
  </fo:table-row>
3468
3472
  </xsl:if>
3469
-
3473
+ </xsl:if> -->
3470
3474
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
3471
3475
  <xsl:apply-templates/>
3472
3476
  </xsl:template><xsl:template match="*[local-name()='dd']"/><xsl:template match="*[local-name()='dd']" mode="process">
@@ -4224,22 +4228,30 @@
4224
4228
  </fo:block>
4225
4229
  </xsl:template><xsl:template match="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
4226
4230
  <fo:block-container margin-left="0mm" margin-right="0mm" margin-bottom="12pt">
4231
+ <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
4232
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
4233
+ </xsl:if>
4227
4234
  <fo:block-container margin-left="0mm" margin-right="0mm">
4228
- <fo:table id="{@id}" table-layout="fixed" width="100%" border="0pt solid black">
4235
+ <fo:table id="{@id}" table-layout="fixed" width="100%" border="1pt solid black">
4236
+ <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
4237
+ <xsl:attribute name="border">0.5pt solid black</xsl:attribute>
4238
+ </xsl:if>
4229
4239
  <xsl:variable name="simple-table">
4230
4240
  <xsl:call-template name="getSimpleTable"/>
4231
4241
  </xsl:variable>
4232
4242
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
4233
4243
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
4234
- <fo:table-column column-width="35mm"/>
4235
- <fo:table-column column-width="115mm"/>
4244
+ <!-- <fo:table-column column-width="35mm"/>
4245
+ <fo:table-column column-width="115mm"/> -->
4246
+ <fo:table-column column-width="25%"/>
4247
+ <fo:table-column column-width="75%"/>
4236
4248
  </xsl:if>
4237
4249
  <xsl:apply-templates mode="requirement"/>
4238
4250
  </fo:table>
4239
4251
  <!-- fn processing -->
4240
4252
  <xsl:if test=".//*[local-name() = 'fn']">
4241
4253
  <xsl:for-each select="*[local-name() = 'tbody']">
4242
- <fo:block font-size="90%" border-bottom="1.pt solid black">
4254
+ <fo:block font-size="90%" border-bottom="1pt solid black">
4243
4255
  <xsl:call-template name="fn_display"/>
4244
4256
  </fo:block>
4245
4257
  </xsl:for-each>
@@ -4255,17 +4267,20 @@
4255
4267
  <xsl:apply-templates mode="requirement"/>
4256
4268
  </fo:table-body>
4257
4269
  </xsl:template><xsl:template match="*[local-name()='tr']" mode="requirement">
4258
- <fo:table-row>
4270
+ <fo:table-row height="7mm">
4271
+ <xsl:if test="parent::*[local-name()='thead'] and not(ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission'])">
4272
+ <xsl:attribute name="border">1pt solid black</xsl:attribute>
4273
+ </xsl:if>
4259
4274
  <xsl:apply-templates mode="requirement"/>
4260
4275
  </fo:table-row>
4261
4276
  </xsl:template><xsl:template match="*[local-name()='th']" mode="requirement">
4262
- <fo:table-cell text-align="{@align}">
4277
+ <fo:table-cell text-align="{@align}" display-align="center" padding="1mm" padding-left="2mm" border="0.5pt solid black">
4263
4278
  <xsl:attribute name="text-align">
4264
4279
  <xsl:choose>
4265
4280
  <xsl:when test="@align">
4266
4281
  <xsl:value-of select="@align"/>
4267
4282
  </xsl:when>
4268
- <xsl:otherwise>center</xsl:otherwise>
4283
+ <xsl:otherwise>left</xsl:otherwise>
4269
4284
  </xsl:choose>
4270
4285
  </xsl:attribute>
4271
4286
  <xsl:if test="@colspan">
@@ -4279,21 +4294,25 @@
4279
4294
  </xsl:attribute>
4280
4295
  </xsl:if>
4281
4296
 
4282
- <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommend'">
4297
+ <!-- <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommend'">
4283
4298
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
4284
4299
  <xsl:attribute name="background-color">rgb(165, 165, 165)</xsl:attribute>
4285
4300
  </xsl:if>
4286
4301
  <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommendtest'">
4287
4302
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
4288
4303
  <xsl:attribute name="background-color">rgb(201, 201, 201)</xsl:attribute>
4289
- </xsl:if>
4304
+ </xsl:if> -->
4290
4305
 
4291
4306
  <fo:block>
4292
4307
  <xsl:apply-templates/>
4293
4308
  </fo:block>
4294
4309
  </fo:table-cell>
4295
4310
  </xsl:template><xsl:template match="*[local-name()='td']" mode="requirement">
4296
- <fo:table-cell text-align="{@align}">
4311
+ <fo:table-cell text-align="{@align}" display-align="center" padding="1mm" padding-left="2mm" border="0.5pt solid black">
4312
+ <xsl:if test="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
4313
+ <xsl:attribute name="padding">0mm</xsl:attribute>
4314
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
4315
+ </xsl:if>
4297
4316
  <xsl:attribute name="text-align">
4298
4317
  <xsl:choose>
4299
4318
  <xsl:when test="@align">
@@ -4313,24 +4332,25 @@
4313
4332
  </xsl:attribute>
4314
4333
  </xsl:if>
4315
4334
 
4316
- <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommend'">
4335
+ <!-- <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommend'">
4317
4336
  <xsl:attribute name="padding-left">0.5mm</xsl:attribute>
4318
- <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
4319
- <xsl:if test="parent::*[local-name()='tr']/preceding-sibling::*[local-name()='tr'] and not(*[local-name()='table'])"> <!-- 2nd line and below -->
4337
+ <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
4338
+ <xsl:if test="parent::*[local-name()='tr']/preceding-sibling::*[local-name()='tr'] and not(*[local-name()='table'])">
4320
4339
  <xsl:attribute name="background-color">rgb(201, 201, 201)</xsl:attribute>
4321
4340
  </xsl:if>
4322
- </xsl:if>
4341
+ </xsl:if> -->
4342
+ <!-- 2nd line and below -->
4323
4343
 
4324
4344
  <fo:block>
4325
4345
  <xsl:apply-templates/>
4326
4346
  </fo:block>
4327
4347
  </fo:table-cell>
4328
4348
  </xsl:template><xsl:template match="*[local-name() = 'p'][@class='RecommendationTitle' or @class = 'RecommendationTestTitle']" priority="2">
4329
- <fo:block font-size="11pt" font-weight="bold" text-align="center" margin-bottom="4pt">
4349
+ <fo:block font-size="11pt" font-weight="bold"> <!-- margin-bottom="4pt" text-align="center" -->
4330
4350
  <xsl:apply-templates/>
4331
4351
  </fo:block>
4332
- </xsl:template><xsl:template match="*[local-name() = 'p'][ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']]">
4333
- <fo:block margin-bottom="10pt">
4352
+ </xsl:template><xsl:template match="*[local-name() = 'p2'][ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']]">
4353
+ <fo:block> <!-- margin-bottom="10pt" -->
4334
4354
  <xsl:apply-templates/>
4335
4355
  </fo:block>
4336
4356
  </xsl:template><xsl:template match="*[local-name() = 'termexample']">
@@ -4614,6 +4634,8 @@
4614
4634
  </fo:block>
4615
4635
  </xsl:template><xsl:template match="/*/*[local-name() = 'bibliography']/*[local-name() = 'references'][@normative='true']">
4616
4636
 
4637
+ <fo:block break-after="page"/>
4638
+
4617
4639
  <fo:block id="{@id}">
4618
4640
  <xsl:apply-templates/>
4619
4641
  </fo:block>
@@ -4661,6 +4683,44 @@
4661
4683
  <fo:table-cell border="1pt solid black" padding-left="1mm" padding-top="0.5mm">
4662
4684
  <fo:block><xsl:apply-templates/></fo:block>
4663
4685
  </fo:table-cell>
4686
+ </xsl:template><xsl:template name="processBibitem">
4687
+
4688
+ </xsl:template><xsl:template name="processPersonalAuthor">
4689
+ <xsl:choose>
4690
+ <xsl:when test="*[local-name() = 'name']/*[local-name() = 'completename']">
4691
+ <author>
4692
+ <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'completename']"/>
4693
+ </author>
4694
+ </xsl:when>
4695
+ <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'initial']">
4696
+ <author>
4697
+ <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
4698
+ <xsl:text> </xsl:text>
4699
+ <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'initial']" mode="strip"/>
4700
+ </author>
4701
+ </xsl:when>
4702
+ <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'forename']">
4703
+ <author>
4704
+ <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
4705
+ <xsl:text> </xsl:text>
4706
+ <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'forename']" mode="strip"/>
4707
+ </author>
4708
+ </xsl:when>
4709
+ <xsl:otherwise>
4710
+ <xsl:apply-templates/>
4711
+ </xsl:otherwise>
4712
+ </xsl:choose>
4713
+ </xsl:template><xsl:template name="renderDate">
4714
+ <xsl:if test="normalize-space(*[local-name() = 'on']) != ''">
4715
+ <xsl:value-of select="*[local-name() = 'on']"/>
4716
+ </xsl:if>
4717
+ <xsl:if test="normalize-space(*[local-name() = 'from']) != ''">
4718
+ <xsl:value-of select="concat(*[local-name() = 'from'], '–', *[local-name() = 'to'])"/>
4719
+ </xsl:if>
4720
+ </xsl:template><xsl:template match="*[local-name() = 'name']/*[local-name() = 'initial']/text()" mode="strip">
4721
+ <xsl:value-of select="translate(.,'. ','')"/>
4722
+ </xsl:template><xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
4723
+ <xsl:value-of select="substring(.,1,1)"/>
4664
4724
  </xsl:template><xsl:template name="convertDate">
4665
4725
  <xsl:param name="date"/>
4666
4726
  <xsl:param name="format" select="'short'"/>
@@ -1,6 +1,18 @@
1
1
  module IsoDoc
2
2
  module NIST
3
3
  module BaseConvert
4
+ def keywords(docxml, out)
5
+ f = docxml.at(ns("//preface/clause[@type = 'keyword']")) || return
6
+ preface1(f, f&.at(ns("./title")), false, out)
7
+ end
8
+
9
+ def skip_render(c, isoxml)
10
+ return false unless c.name == "reviewernote"
11
+ status = isoxml&.at(ns("//bibdata/status/stage"))&.text
12
+ return true if status.nil?
13
+ /^final/.match status
14
+ end
15
+
4
16
  def abstract(isoxml, out)
5
17
  f = isoxml.at(ns("//preface/abstract")) || return
6
18
  out.div **attr_code(id: f["id"]) do |s|
@@ -11,13 +23,13 @@ module IsoDoc
11
23
  end
12
24
 
13
25
  FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or "\
14
- "local-name() = 'foreword') or @type = 'keyword']".freeze
26
+ "local-name() = 'foreword' or @type = 'keyword')]".freeze
15
27
 
16
28
  # All "[preface]" sections should have class "IntroTitle" to prevent
17
29
  # page breaks, but for the Exec Summary
18
30
  def preface(isoxml, out)
19
31
  isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
20
- next if skip_render(c, isoxml)
32
+ next if skip_render(c, isoxml) || !is_clause?(c.name)
21
33
  title = c&.at(ns("./title"))
22
34
  patent = ["Call for Patent Claims",
23
35
  "Patent Disclosure Notice"].include? title&.text
@@ -37,12 +49,6 @@ module IsoDoc
37
49
  end
38
50
  end
39
51
 
40
- def middle(isoxml, out)
41
- clause isoxml, out
42
- bibliography isoxml, out
43
- annex isoxml, out
44
- end
45
-
46
52
  def foreword(isoxml, out)
47
53
  f = isoxml.at(ns("//foreword")) || return
48
54
  out.div **attr_code(id: f["id"]) do |s|
@@ -53,6 +59,11 @@ module IsoDoc
53
59
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
54
60
  end
55
61
  end
62
+
63
+ def is_clause?(name)
64
+ return true if %w(reviewernote executivesummary).include? name
65
+ super
66
+ end
56
67
  end
57
68
  end
58
69
  end
@@ -14,6 +14,10 @@ module IsoDoc
14
14
  def initialize(options)
15
15
  @libdir = File.dirname(__FILE__)
16
16
  super
17
+ @wordToClevels = options[:doctoclevels].to_i
18
+ @wordToClevels = 3 if @wordToClevels.zero?
19
+ @htmlToClevels = options[:htmltoclevels].to_i
20
+ @htmlToClevels = 3 if @htmlToClevels.zero?
17
21
  end
18
22
 
19
23
  def convert1(docxml, filename, dir)
@@ -62,8 +66,10 @@ module IsoDoc
62
66
  body.div **{ class: "WordSection2" } do |div2|
63
67
  @prefacenum = 0
64
68
  info docxml, div2
69
+ preface_block docxml, div2
65
70
  foreword docxml, div2
66
71
  abstract docxml, div2
72
+ keywords docxml, div2
67
73
  boilerplate docxml, div2
68
74
  preface docxml, div2
69
75
  div2.p { |p| p << "&nbsp;" } # placeholder
@@ -71,6 +77,24 @@ module IsoDoc
71
77
  section_break(body)
72
78
  end
73
79
 
80
+ def toWord(result, filename, dir, header)
81
+ result = populate_template(result, :word)
82
+ result = from_xhtml(word_cleanup(to_xhtml(result)))
83
+ unless @landscapestyle.nil? || @landscapestyle.empty?
84
+ @wordstylesheet&.open
85
+ @wordstylesheet&.write(@landscapestyle)
86
+ @wordstylesheet&.close
87
+ end
88
+ Html2Doc.process(result, filename: filename,
89
+ stylesheet: @wordstylesheet&.path,
90
+ header_file: header&.path, dir: dir,
91
+ asciimathdelims: [@openmathdelim, @closemathdelim],
92
+ liststyles: { ul: @ulstyle, ol: @olstyle,
93
+ steps: "l4" })
94
+ header&.unlink
95
+ @wordstylesheet&.unlink
96
+ end
97
+
74
98
  def authority_cleanup(docxml)
75
99
  docxml&.xpath("//div[@class = 'authority']//h1 | "\
76
100
  "//div[@class = 'authority']//h2")&.each do |h|
@@ -125,6 +149,7 @@ module IsoDoc
125
149
  end
126
150
 
127
151
  def word_annex_cleanup(docxml)
152
+ word_annex_cleanup1(docxml, 1)
128
153
  word_annex_cleanup1(docxml, 2)
129
154
  word_annex_cleanup1(docxml, 3)
130
155
  word_annex_cleanup1(docxml, 4)
@@ -165,6 +190,22 @@ module IsoDoc
165
190
  end
166
191
  end
167
192
 
193
+ def glossary_parse(node, out)
194
+ out.table **attr_code(id: node["id"], class: "terms_dl") do |t|
195
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
196
+ t.tr do |v|
197
+ v.td **attr_code(id: dt["id"], valign: "top", align: "left") do |term|
198
+ dt_parse(dt, term)
199
+ end
200
+ v.td **attr_code(id: dd["id"], valign: "top") do |listitem|
201
+ dd.children.each { |n| parse(n, listitem) }
202
+ end
203
+ end
204
+ end
205
+ end
206
+ node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
207
+ end
208
+
168
209
  include BaseConvert
169
210
  include Init
170
211
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-nist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities