metanorma-ieee 0.0.7 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,9 +33,10 @@
33
33
  <param name="pattern">([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?</param>
34
34
  </data>
35
35
  </define>
36
- <start>
37
- <ref name="bibitem"/>
38
- </start>
36
+ <!-- start = bibitem -->
37
+ <define name="BibData">
38
+ <ref name="BibliographicItem"/>
39
+ </define>
39
40
  <define name="status">
40
41
  <element name="status">
41
42
  <ref name="stage"/>
@@ -170,27 +171,25 @@
170
171
  </define>
171
172
  <define name="contributor">
172
173
  <element name="contributor">
173
- <zeroOrMore>
174
+ <oneOrMore>
174
175
  <ref name="role"/>
175
- </zeroOrMore>
176
+ </oneOrMore>
176
177
  <ref name="ContributorInfo"/>
177
178
  </element>
178
179
  </define>
179
180
  <define name="role">
180
181
  <element name="role">
181
- <optional>
182
- <attribute name="type">
183
- <choice>
184
- <value>author</value>
185
- <value>performer</value>
186
- <value>publisher</value>
187
- <value>editor</value>
188
- <value>adapter</value>
189
- <value>translator</value>
190
- <value>distributor</value>
191
- </choice>
192
- </attribute>
193
- </optional>
182
+ <attribute name="type">
183
+ <choice>
184
+ <value>author</value>
185
+ <value>performer</value>
186
+ <value>publisher</value>
187
+ <value>editor</value>
188
+ <value>adapter</value>
189
+ <value>translator</value>
190
+ <value>distributor</value>
191
+ </choice>
192
+ </attribute>
194
193
  <zeroOrMore>
195
194
  <ref name="roledescription"/>
196
195
  </zeroOrMore>
@@ -512,6 +511,17 @@
512
511
  </define>
513
512
  <define name="localityStack">
514
513
  <element name="localityStack">
514
+ <optional>
515
+ <attribute name="connective">
516
+ <choice>
517
+ <value>and</value>
518
+ <value>or</value>
519
+ <value>from</value>
520
+ <value>to</value>
521
+ <value/>
522
+ </choice>
523
+ </attribute>
524
+ </optional>
515
525
  <zeroOrMore>
516
526
  <ref name="locality"/>
517
527
  </zeroOrMore>
@@ -524,6 +534,17 @@
524
534
  </define>
525
535
  <define name="sourceLocalityStack">
526
536
  <element name="sourceLocalityStack">
537
+ <optional>
538
+ <attribute name="connective">
539
+ <choice>
540
+ <value>and</value>
541
+ <value>or</value>
542
+ <value>from</value>
543
+ <value>to</value>
544
+ <value/>
545
+ </choice>
546
+ </attribute>
547
+ </optional>
527
548
  <zeroOrMore>
528
549
  <ref name="sourceLocality"/>
529
550
  </zeroOrMore>
@@ -626,6 +647,9 @@
626
647
  <ref name="BibItemType"/>
627
648
  </attribute>
628
649
  </optional>
650
+ <optional>
651
+ <attribute name="schema-version"/>
652
+ </optional>
629
653
  <optional>
630
654
  <ref name="fetched"/>
631
655
  </optional>
@@ -720,6 +744,9 @@
720
744
  <ref name="BibItemType"/>
721
745
  </attribute>
722
746
  </optional>
747
+ <optional>
748
+ <attribute name="schema-version"/>
749
+ </optional>
723
750
  <optional>
724
751
  <ref name="fetched"/>
725
752
  </optional>
@@ -10,6 +10,9 @@ module Metanorma
10
10
  initial_note(xml)
11
11
  word_usage(xml)
12
12
  participants(xml)
13
+ xml.xpath("//dl[not(@id)]").each do |dl|
14
+ dl["id"] = "_#{UUIDTools::UUID.random_create}"
15
+ end
13
16
  end
14
17
 
15
18
  def intro_boilerplate(xml, isodoc)
@@ -53,22 +56,36 @@ module Metanorma
53
56
  end
54
57
 
55
58
  def overview_cleanup(xml)
59
+ overview_once_cleanup(xml)
60
+ overview_children_cleanup(xml)
61
+ end
62
+
63
+ def overview_children_cleanup(xml)
56
64
  %w(scope purpose word-usage).each do |x|
57
65
  (xml.xpath("//clause[@type = '#{x}']") -
58
- xml.xpath("//sections/clause[1][@type = 'overview']"\
66
+ xml.xpath("//sections/clause[@type = 'overview']" \
59
67
  "//clause[@type = '#{x}']"))
60
68
  .each { |c| c.delete("type") }
61
69
  end
62
- (xml.xpath("//clause[@type = 'overview']") -
63
- xml.xpath("//sections/clause[1]"))
64
- .each { |c| c.delete("type") }
70
+ end
71
+
72
+ def overview_once_cleanup(xml)
73
+ found = false
74
+ xml.xpath("//sections//clause[@type = 'overview']").each do |c|
75
+ found and c.delete("type")
76
+ found = true if c.parent.name == "sections"
77
+ end
78
+ xml.xpath("//annex//clause[@type = 'overview'] | " \
79
+ "//preface//clause[@type = 'overview']").each do |c|
80
+ c.delete("type")
81
+ end
65
82
  end
66
83
 
67
84
  def note_cleanup(xmldoc)
68
85
  super
69
- n = xmldoc.at("//preface//note[not(@type = 'boilerplate')]"\
70
- "[not(./ancestor::abstract)] | "\
71
- "//sections//note[not(@type = 'boilerplate')] | "\
86
+ n = xmldoc.at("//preface//note[not(@type = 'boilerplate')]" \
87
+ "[not(./ancestor::abstract)] | " \
88
+ "//sections//note[not(@type = 'boilerplate')] | " \
72
89
  "//annex//note[not(@type = 'boilerplate')]") or
73
90
  return
74
91
  ins = n.at("./p[last()]")
@@ -172,7 +189,7 @@ module Metanorma
172
189
  "<dt>#{k}</dt><dd>#{ret[k]}</dd>"
173
190
  end.join
174
191
  else
175
- list.children = "<dl><dt>name</dt><dd>#{list.children.to_xml}</dd>"\
192
+ list.children = "<dl><dt>name</dt><dd>#{list.children.to_xml}</dd>" \
176
193
  "<dt>role</dt><dd>member</dd></dl>"
177
194
  end
178
195
  end
@@ -199,7 +216,7 @@ module Metanorma
199
216
  u.empty? and m.empty? and return
200
217
  ins = xmldoc.at("//bibdata/title")
201
218
  t = provenance_title1(u, m)
202
- ins.next = "<title type='provenance' language='en' "\
219
+ ins.next = "<title type='provenance' language='en' " \
203
220
  "format='application/xml'>#{t}</title>"
204
221
  end
205
222
 
@@ -20,6 +20,9 @@ module Metanorma
20
20
  @hierarchical_assets = node.attr("hierarchical-object-numbering")
21
21
  end
22
22
 
23
+ PREFACE_CLAUSE_NAMES = %w(abstract foreword introduction
24
+ acknowledgements participants).freeze
25
+
23
26
  def sectiontype_streamline(ret)
24
27
  case ret
25
28
  when "definitions", "definitions, acronyms and abbreviations"
@@ -60,7 +63,8 @@ module Metanorma
60
63
 
61
64
  def html_extract_attributes(node)
62
65
  super.merge(hierarchical_assets:
63
- node.attr("hierarchical-object-numbering"))
66
+ node.attr("hierarchical-object-numbering"),
67
+ ieeedtd: node.attr("ieee-dtd"))
64
68
  end
65
69
 
66
70
  def doc_extract_attributes(node)
@@ -78,12 +82,20 @@ module Metanorma
78
82
  end
79
83
 
80
84
  def pdf_converter(node)
85
+ return nil if node.attr("no-pdf")
86
+
81
87
  IsoDoc::IEEE::PdfConvert.new(pdf_extract_attributes(node))
82
88
  end
83
89
 
84
90
  def doc_converter(node)
85
91
  IsoDoc::IEEE::WordConvert.new(doc_extract_attributes(node))
86
92
  end
93
+
94
+ def ieee_xml_converter(node)
95
+ return nil if node.attr("no-pdf")
96
+
97
+ IsoDoc::Iso::IEEEXMLConvert.new(html_extract_attributes(node))
98
+ end
87
99
  end
88
100
  end
89
101
  end
@@ -1,158 +1,16 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns="https://www.metanorma.org/ns/ieee" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
2
+ <grammar ns="https://www.metanorma.org/ns/ieee" xmlns="http://relaxng.org/ns/structure/1.0">
3
3
  <!--
4
4
  Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
5
  we cannot have a new default namespace: we will end up with a grammar with two different
6
6
  namespaces, one for isostandard and one for csand additions. And we do not want that.
7
7
  -->
8
+ <include href="relaton-ieee.rng"/>
8
9
  <include href="isodoc.rng">
9
10
  <start>
10
11
  <ref name="ieee-standard"/>
11
12
  </start>
12
- <define name="DocumentType">
13
- <choice>
14
- <value>guide</value>
15
- <value>recommended-practice</value>
16
- <value>standard</value>
17
- <value>whitepaper</value>
18
- <value>redline</value>
19
- <value>other</value>
20
- </choice>
21
- </define>
22
- <define name="stage">
23
- <element name="stage">
24
- <choice>
25
- <value>draft</value>
26
- <value>approved</value>
27
- <value>superseded</value>
28
- <value>withdrawn</value>
29
- </choice>
30
- </element>
31
- </define>
32
- <define name="editorialgroup">
33
- <element name="editorialgroup">
34
- <optional>
35
- <ref name="society"/>
36
- </optional>
37
- <optional>
38
- <ref name="balloting-group"/>
39
- </optional>
40
- <optional>
41
- <ref name="working-group"/>
42
- </optional>
43
- <oneOrMore>
44
- <ref name="committee"/>
45
- </oneOrMore>
46
- </element>
47
- </define>
48
- <define name="DocumentSubtype">
49
- <choice>
50
- <value>amendment</value>
51
- <value>corrigendum</value>
52
- <value>erratum</value>
53
- </choice>
54
- </define>
55
- <define name="BibDataExtensionType">
56
- <optional>
57
- <ref name="doctype"/>
58
- </optional>
59
- <optional>
60
- <ref name="docsubtype"/>
61
- </optional>
62
- <optional>
63
- <ref name="trialuse"/>
64
- </optional>
65
- <optional>
66
- <ref name="editorialgroup"/>
67
- </optional>
68
- <zeroOrMore>
69
- <ref name="ics"/>
70
- </zeroOrMore>
71
- <optional>
72
- <ref name="standard_status"/>
73
- </optional>
74
- <optional>
75
- <ref name="standard_modified"/>
76
- </optional>
77
- <optional>
78
- <ref name="pubstatus"/>
79
- </optional>
80
- <optional>
81
- <ref name="holdstatus"/>
82
- </optional>
83
- </define>
84
13
  </include>
85
- <define name="standard_status">
86
- <element name="standard_status">
87
- <choice>
88
- <value>Inactive</value>
89
- <value>Active</value>
90
- <value>Superseded</value>
91
- </choice>
92
- </element>
93
- </define>
94
- <define name="standard_modified">
95
- <element name="standard_modified">
96
- <choice>
97
- <value>Draft</value>
98
- <value>Withdrawn</value>
99
- <value>Superseded</value>
100
- <value>Approved</value>
101
- <value>Reserved</value>
102
- <value>Redline</value>
103
- </choice>
104
- </element>
105
- </define>
106
- <define name="pubstatus">
107
- <element name="pubstatus">
108
- <choice>
109
- <value>Active</value>
110
- <value>Inactive</value>
111
- </choice>
112
- </element>
113
- </define>
114
- <define name="holdstatus">
115
- <element name="holdstatus">
116
- <choice>
117
- <value>Hold</value>
118
- <value>Publish</value>
119
- </choice>
120
- </element>
121
- </define>
122
- <define name="BibliographicDateType" combine="choice">
123
- <value>feedback-ended</value>
124
- </define>
125
- <define name="trialuse">
126
- <element name="trial-use">
127
- <data type="boolean"/>
128
- </element>
129
- </define>
130
- <define name="balloting-group">
131
- <element name="balloting-group">
132
- <attribute name="type">
133
- <choice>
134
- <value>individual</value>
135
- <value>entity</value>
136
- </choice>
137
- </attribute>
138
- <text/>
139
- </element>
140
- </define>
141
- <define name="working-group">
142
- <element name="working-group">
143
- <text/>
144
- </element>
145
- </define>
146
- <define name="committee">
147
- <element name="committee">
148
- <text/>
149
- </element>
150
- </define>
151
- <define name="society">
152
- <element name="society">
153
- <text/>
154
- </element>
155
- </define>
156
14
  <define name="ieee-standard">
157
15
  <element name="ieee-standard">
158
16
  <attribute name="version"/>
@@ -19,19 +19,7 @@
19
19
  -->
20
20
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
21
21
  <include href="reqt.rng"/>
22
- <!-- include "biblio.rnc" { } -->
23
22
  <include href="basicdoc.rng">
24
- <start>
25
- <ref name="standard-document"/>
26
- </start>
27
- <define name="doctype">
28
- <element name="doctype">
29
- <optional>
30
- <attribute name="abbreviation"/>
31
- </optional>
32
- <ref name="DocumentType"/>
33
- </element>
34
- </define>
35
23
  <define name="admonition">
36
24
  <element name="admonition">
37
25
  <attribute name="type">
@@ -117,24 +105,6 @@
117
105
  </optional>
118
106
  </element>
119
107
  </define>
120
- <define name="bibitem">
121
- <element name="bibitem">
122
- <attribute name="id">
123
- <data type="ID"/>
124
- </attribute>
125
- <optional>
126
- <attribute name="hidden">
127
- <data type="boolean"/>
128
- </attribute>
129
- </optional>
130
- <optional>
131
- <attribute name="suppress_identifier">
132
- <data type="boolean"/>
133
- </attribute>
134
- </optional>
135
- <ref name="BibliographicItem"/>
136
- </element>
137
- </define>
138
108
  <define name="section-title">
139
109
  <element name="title">
140
110
  <zeroOrMore>
@@ -205,6 +175,15 @@
205
175
  <data type="boolean"/>
206
176
  </attribute>
207
177
  </optional>
178
+ <optional>
179
+ <attribute name="style">
180
+ <choice>
181
+ <value>basic</value>
182
+ <value>full</value>
183
+ <value>short</value>
184
+ </choice>
185
+ </attribute>
186
+ </optional>
208
187
  <ref name="XrefBody"/>
209
188
  </element>
210
189
  </define>
@@ -239,42 +218,6 @@
239
218
  <ref name="PureTextElement"/>
240
219
  </oneOrMore>
241
220
  </define>
242
- <define name="localityStack">
243
- <element name="localityStack">
244
- <optional>
245
- <attribute name="connective">
246
- <choice>
247
- <value>and</value>
248
- <value>or</value>
249
- <value>from</value>
250
- <value>to</value>
251
- <value/>
252
- </choice>
253
- </attribute>
254
- </optional>
255
- <zeroOrMore>
256
- <ref name="locality"/>
257
- </zeroOrMore>
258
- </element>
259
- </define>
260
- <define name="sourceLocalityStack">
261
- <element name="sourceLocalityStack">
262
- <optional>
263
- <attribute name="connective">
264
- <choice>
265
- <value>and</value>
266
- <value>or</value>
267
- <value>from</value>
268
- <value>to</value>
269
- <value/>
270
- </choice>
271
- </attribute>
272
- </optional>
273
- <zeroOrMore>
274
- <ref name="sourceLocality"/>
275
- </zeroOrMore>
276
- </element>
277
- </define>
278
221
  <define name="ul">
279
222
  <element name="ul">
280
223
  <attribute name="id">
@@ -818,21 +761,6 @@
818
761
  </zeroOrMore>
819
762
  </element>
820
763
  </define>
821
- <define name="BibDataExtensionType">
822
- <ref name="doctype"/>
823
- <optional>
824
- <ref name="docsubtype"/>
825
- </optional>
826
- <optional>
827
- <ref name="editorialgroup"/>
828
- </optional>
829
- <zeroOrMore>
830
- <ref name="ics"/>
831
- </zeroOrMore>
832
- <zeroOrMore>
833
- <ref name="structuredidentifier"/>
834
- </zeroOrMore>
835
- </define>
836
764
  <!-- TitleType = text -->
837
765
  <define name="sections">
838
766
  <element name="sections">
@@ -872,7 +800,7 @@
872
800
  <ref name="BasicBlock"/>
873
801
  </zeroOrMore>
874
802
  <zeroOrMore>
875
- <ref name="bibitem"/>
803
+ <ref name="doc_bibitem"/>
876
804
  <zeroOrMore>
877
805
  <ref name="note"/>
878
806
  </zeroOrMore>
@@ -1210,6 +1138,24 @@
1210
1138
  </define>
1211
1139
  </include>
1212
1140
  <!-- end overrides -->
1141
+ <define name="doc_bibitem">
1142
+ <element name="bibitem">
1143
+ <attribute name="id">
1144
+ <data type="ID"/>
1145
+ </attribute>
1146
+ <optional>
1147
+ <attribute name="hidden">
1148
+ <data type="boolean"/>
1149
+ </attribute>
1150
+ </optional>
1151
+ <optional>
1152
+ <attribute name="suppress_identifier">
1153
+ <data type="boolean"/>
1154
+ </attribute>
1155
+ </optional>
1156
+ <ref name="BibliographicItem"/>
1157
+ </element>
1158
+ </define>
1213
1159
  <define name="image" combine="choice">
1214
1160
  <element name="svg">
1215
1161
  <oneOrMore>
@@ -1228,14 +1174,6 @@
1228
1174
  <value>tag</value>
1229
1175
  </choice>
1230
1176
  </define>
1231
- <define name="docsubtype">
1232
- <element name="subdoctype">
1233
- <ref name="DocumentSubtype"/>
1234
- </element>
1235
- </define>
1236
- <define name="DocumentSubtype">
1237
- <text/>
1238
- </define>
1239
1177
  <define name="colgroup">
1240
1178
  <element name="colgroup">
1241
1179
  <oneOrMore>
@@ -1597,45 +1535,6 @@
1597
1535
  </choice>
1598
1536
  </element>
1599
1537
  </define>
1600
- <define name="editorialgroup">
1601
- <element name="editorialgroup">
1602
- <oneOrMore>
1603
- <ref name="technical-committee"/>
1604
- </oneOrMore>
1605
- </element>
1606
- </define>
1607
- <define name="technical-committee">
1608
- <element name="technical-committee">
1609
- <ref name="IsoWorkgroup"/>
1610
- </element>
1611
- </define>
1612
- <define name="IsoWorkgroup">
1613
- <optional>
1614
- <attribute name="number"/>
1615
- </optional>
1616
- <optional>
1617
- <attribute name="type"/>
1618
- </optional>
1619
- <optional>
1620
- <attribute name="identifier"/>
1621
- </optional>
1622
- <optional>
1623
- <attribute name="prefix"/>
1624
- </optional>
1625
- <text/>
1626
- </define>
1627
- <define name="ics">
1628
- <element name="ics">
1629
- <element name="code">
1630
- <text/>
1631
- </element>
1632
- <optional>
1633
- <element name="text">
1634
- <text/>
1635
- </element>
1636
- </optional>
1637
- </element>
1638
- </define>
1639
1538
  <define name="standard-document">
1640
1539
  <element name="standard-document">
1641
1540
  <attribute name="version"/>
@@ -2466,71 +2365,6 @@
2466
2365
  </optional>
2467
2366
  </element>
2468
2367
  </define>
2469
- <define name="structuredidentifier">
2470
- <element name="structuredidentifier">
2471
- <optional>
2472
- <attribute name="type"/>
2473
- </optional>
2474
- <oneOrMore>
2475
- <element name="agency">
2476
- <text/>
2477
- </element>
2478
- </oneOrMore>
2479
- <optional>
2480
- <element name="class">
2481
- <text/>
2482
- </element>
2483
- </optional>
2484
- <element name="docnumber">
2485
- <text/>
2486
- </element>
2487
- <optional>
2488
- <element name="partnumber">
2489
- <text/>
2490
- </element>
2491
- </optional>
2492
- <optional>
2493
- <element name="edition">
2494
- <text/>
2495
- </element>
2496
- </optional>
2497
- <optional>
2498
- <element name="version">
2499
- <text/>
2500
- </element>
2501
- </optional>
2502
- <optional>
2503
- <element name="supplementtype">
2504
- <text/>
2505
- </element>
2506
- </optional>
2507
- <optional>
2508
- <element name="supplementnumber">
2509
- <text/>
2510
- </element>
2511
- </optional>
2512
- <optional>
2513
- <element name="amendment">
2514
- <text/>
2515
- </element>
2516
- </optional>
2517
- <optional>
2518
- <element name="corrigendum">
2519
- <text/>
2520
- </element>
2521
- </optional>
2522
- <optional>
2523
- <element name="language">
2524
- <text/>
2525
- </element>
2526
- </optional>
2527
- <optional>
2528
- <element name="year">
2529
- <text/>
2530
- </element>
2531
- </optional>
2532
- </element>
2533
- </define>
2534
2368
  <define name="term-clause">
2535
2369
  <element name="clause">
2536
2370
  <optional>
@@ -2804,4 +2638,7 @@
2804
2638
  </attribute>
2805
2639
  </element>
2806
2640
  </define>
2641
+ <start>
2642
+ <ref name="standard-document"/>
2643
+ </start>
2807
2644
  </grammar>