metanorma-iec 1.3.3 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,560 +1,549 @@
1
1
  require "spec_helper"
2
-
2
+
3
3
  RSpec.describe IsoDoc do
4
4
  it "processes introductions under IEV" do
5
5
  input = <<~INPUT
6
- <iso-standard xmlns="http://riboseinc.com/isoxml">
7
- <bibdata>
8
- <docidentifier type="iso">IEC/PWI 60050-871 ED 2</docidentifier>
9
- <docnumber>60050</docnumber>
10
- </bibdata>
11
- <preface>
12
- <foreword obligation="informative">
13
- <title>Foreword</title>
14
- <p id="A">This is a preamble</p>
15
- </foreword>
16
- <introduction id="B" obligation="informative"><title>Introduction</title>
17
- <clause id="C" inline-header="false" obligation="informative">
18
- <title>Introduction Subsection</title>
19
- </clause>
20
- </introduction></preface><sections/>
21
- </iso-standard>
22
- INPUT
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <bibdata>
8
+ <docidentifier type="iso">IEC/PWI 60050-871 ED 2</docidentifier>
9
+ <docnumber>60050</docnumber>
10
+ </bibdata>
11
+ <preface>
12
+ <foreword obligation="informative">
13
+ <title>Foreword</title>
14
+ <p id="A">This is a preamble</p>
15
+ </foreword>
16
+ <introduction id="B" obligation="informative"><title>Introduction</title>
17
+ <clause id="C" inline-header="false" obligation="informative">
18
+ <title>Introduction Subsection</title>
19
+ </clause>
20
+ </introduction></preface><sections/>
21
+ </iso-standard>
22
+ INPUT
23
23
 
24
- presxml = <<~OUTPUT
25
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
26
- <bibdata>
27
- <docidentifier type='iso'>IEC/PWI 60050-871 ED 2</docidentifier>
28
- <docnumber>60050</docnumber>
29
- </bibdata>
30
- <preface>
31
- <foreword obligation='informative'>
32
- <title>Foreword</title>
33
- <p id='A'>This is a preamble</p>
34
- </foreword>
35
- <introduction id='B' obligation='informative'>
36
- <title depth='1'>Introduction</title>
37
- <clause id='C' inline-header='false' obligation='informative'>
38
- <title depth='2'>Introduction Subsection</title>
39
- </clause>
40
- </introduction>
41
- </preface>
42
- <sections/>
43
- </iso-standard>
44
- OUTPUT
24
+ presxml = <<~OUTPUT
25
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
26
+ <bibdata>
27
+ <docidentifier type='iso'>IEC/PWI 60050-871 ED 2</docidentifier>
28
+ <docnumber>60050</docnumber>
29
+ </bibdata>
30
+ <preface>
31
+ <foreword obligation='informative' displayorder="1">
32
+ <title>Foreword</title>
33
+ <p id='A'>This is a preamble</p>
34
+ </foreword>
35
+ <introduction id='B' obligation='informative' displayorder="2">
36
+ <title depth='1'>Introduction</title>
37
+ <clause id='C' inline-header='false' obligation='informative'>
38
+ <title depth='2'>Introduction Subsection</title>
39
+ </clause>
40
+ </introduction>
41
+ </preface>
42
+ <sections/>
43
+ </iso-standard>
44
+ OUTPUT
45
45
 
46
- html = <<~OUTPUT
47
- #{HTML_HDR}
48
- <div>
49
- <h1 class='ForewordTitle'>FOREWORD</h1>
50
- <div class='boilerplate_legal'/>
51
- <p id='A'>This is a preamble</p>
52
- </div>
53
- <br/>
54
- <div class='Section3' id='B'>
55
- <h1 class='IntroTitle'>
56
- Introduction
57
- </h1>
58
- <div id='C'>
59
- <h2>Introduction Subsection</h2>
60
- </div>
61
- </div>
62
- #{IEC_TITLE1}
63
- </div>
64
- </body>
65
- </html>
66
- OUTPUT
46
+ html = <<~OUTPUT
47
+ #{HTML_HDR}
48
+ <div>
49
+ <h1 class='ForewordTitle'>FOREWORD</h1>
50
+ <div class='boilerplate_legal'/>
51
+ <p id='A'>This is a preamble</p>
52
+ </div>
53
+ <br/>
54
+ <div class='Section3' id='B'>
55
+ <h1 class='IntroTitle'>
56
+ Introduction
57
+ </h1>
58
+ <div id='C'>
59
+ <h2>Introduction Subsection</h2>
60
+ </div>
61
+ </div>
62
+ #{IEC_TITLE1}
63
+ </div>
64
+ </body>
65
+ </html>
66
+ OUTPUT
67
67
  expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
68
68
  expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
69
69
  end
70
70
 
71
71
  it "processes bibliographies under IEV" do
72
72
  input = <<~INPUT
73
- <iec-standard xmlns='https://www.metanorma.org/ns/iec'>
74
- <bibdata type='standard'>
75
- <docidentifier type='iso'>IEC 60050 ED 1</docidentifier>
76
- <docnumber>60050</docnumber>
77
- <contributor>
78
- <role type='author'/>
79
- <organization>
80
- <name>International Electrotechnical Commission</name>
81
- <abbreviation>IEC</abbreviation>
82
- </organization>
83
- </contributor>
84
- <contributor>
85
- <role type='publisher'/>
86
- <organization>
87
- <name>International Electrotechnical Commission</name>
88
- <abbreviation>IEC</abbreviation>
89
- </organization>
90
- </contributor>
91
- <language>en</language>
92
- <script>Latn</script>
93
- <status>
94
- <stage>60</stage>
95
- <substage>60</substage>
96
- </status>
97
- <copyright>
98
- <from>2020</from>
99
- <owner>
100
- <organization>
101
- <name>International Electrotechnical Commission</name>
102
- <abbreviation>IEC</abbreviation>
103
- </organization>
104
- </owner>
105
- </copyright>
106
- <ext>
107
- <doctype>article</doctype>
108
- <editorialgroup>
109
- <technical-committee/>
110
- <subcommittee/>
111
- <workgroup/>
112
- </editorialgroup>
113
- <structuredidentifier>
114
- <project-number>IEC 60050</project-number>
115
- </structuredidentifier>
116
- </ext>
117
- </bibdata>
118
- <sections> </sections>
119
- <bibliography>
120
- <references obligation='informative' normative="true" id="X">
121
- <title>Normative References</title>
122
- <p id='_'>There are no normative references in this document.</p>
123
- <bibitem id='A'>
124
- <formattedref format='application/x-isodoc+xml'>
125
- <em>TITLE</em>
126
- </formattedref>
127
- <docidentifier>B</docidentifier>
128
- </bibitem>
129
- </references>
130
- <references id='_' obligation='informative' normative="false">
131
- <title>Bibliography</title>
132
- <p id='_'>There are no normative references in this document.</p>
133
- <bibitem id='A'>
134
- <formattedref format='application/x-isodoc+xml'>
135
- <em>TITLE</em>
136
- </formattedref>
137
- <docidentifier>B</docidentifier>
138
- </bibitem>
139
- </references>
73
+ <iec-standard xmlns='https://www.metanorma.org/ns/iec'>
74
+ <bibdata type='standard'>
75
+ <docidentifier type='iso'>IEC 60050 ED 1</docidentifier>
76
+ <docnumber>60050</docnumber>
77
+ <contributor>
78
+ <role type='author'/>
79
+ <organization>
80
+ <name>International Electrotechnical Commission</name>
81
+ <abbreviation>IEC</abbreviation>
82
+ </organization>
83
+ </contributor>
84
+ <contributor>
85
+ <role type='publisher'/>
86
+ <organization>
87
+ <name>International Electrotechnical Commission</name>
88
+ <abbreviation>IEC</abbreviation>
89
+ </organization>
90
+ </contributor>
91
+ <language>en</language>
92
+ <script>Latn</script>
93
+ <status>
94
+ <stage>60</stage>
95
+ <substage>60</substage>
96
+ </status>
97
+ <copyright>
98
+ <from>2020</from>
99
+ <owner>
100
+ <organization>
101
+ <name>International Electrotechnical Commission</name>
102
+ <abbreviation>IEC</abbreviation>
103
+ </organization>
104
+ </owner>
105
+ </copyright>
106
+ <ext>
107
+ <doctype>article</doctype>
108
+ <editorialgroup>
109
+ <technical-committee/>
110
+ <subcommittee/>
111
+ <workgroup/>
112
+ </editorialgroup>
113
+ <structuredidentifier>
114
+ <project-number>IEC 60050</project-number>
115
+ </structuredidentifier>
116
+ </ext>
117
+ </bibdata>
118
+ <sections> </sections>
119
+ <bibliography>
120
+ <references obligation='informative' normative="true" id="X">
121
+ <title>Normative References</title>
122
+ <p id='_'>There are no normative references in this document.</p>
123
+ <bibitem id='A'>
124
+ <formattedref format='application/x-isodoc+xml'>
125
+ <em>TITLE</em>
126
+ </formattedref>
127
+ <docidentifier>B</docidentifier>
128
+ </bibitem>
129
+ </references>
130
+ <references id='_' obligation='informative' normative="false">
131
+ <title>Bibliography</title>
132
+ <p id='_'>There are no normative references in this document.</p>
133
+ <bibitem id='A'>
134
+ <formattedref format='application/x-isodoc+xml'>
135
+ <em>TITLE</em>
136
+ </formattedref>
137
+ <docidentifier>B</docidentifier>
138
+ </bibitem>
139
+ </references>
140
140
 
141
- </bibliography>
142
- </iec-standard>
143
- INPUT
144
- presxml = <<~OUTPUT
145
- <iec-standard xmlns='https://www.metanorma.org/ns/iec' type="presentation">
146
- <bibdata type='standard'>
147
- <docidentifier type='iso'>IEC 60050 ED 1</docidentifier>
148
- <docnumber>60050</docnumber>
149
- <contributor>
150
- <role type='author'/>
151
- <organization>
152
- <name>International Electrotechnical Commission</name>
153
- <abbreviation>IEC</abbreviation>
154
- </organization>
155
- </contributor>
156
- <contributor>
157
- <role type='publisher'/>
158
- <organization>
159
- <name>International Electrotechnical Commission</name>
160
- <abbreviation>IEC</abbreviation>
161
- </organization>
162
- </contributor>
163
- <language current="true">en</language>
164
- <script current="true">Latn</script>
165
- <status>
166
- <stage language="">60</stage>
167
- <substage language="">60</substage>
168
- </status>
169
- <copyright>
170
- <from>2020</from>
171
- <owner>
172
- <organization>
173
- <name>International Electrotechnical Commission</name>
174
- <abbreviation>IEC</abbreviation>
175
- </organization>
176
- </owner>
177
- </copyright>
178
- <ext>
179
- <doctype language="">article</doctype>
180
- <editorialgroup>
181
- <technical-committee/>
182
- <subcommittee/>
183
- <workgroup/>
184
- </editorialgroup>
185
- <structuredidentifier>
186
- <project-number>IEC 60050</project-number>
187
- </structuredidentifier>
188
- </ext>
189
- </bibdata>
190
- <sections> </sections>
191
- <bibliography>
192
- <references obligation='informative' normative='true' id="X">
193
- <title depth='1'>1<tab/>Normative References</title>
194
- <p id='_'>There are no normative references in this document.</p>
195
- <bibitem id='A'>
196
- <formattedref format='application/x-isodoc+xml'>
197
- <em>TITLE</em>
198
- </formattedref>
199
- <docidentifier>B</docidentifier>
200
- </bibitem>
201
- </references>
202
- <references id='_' obligation='informative' normative='false'>
203
- <title depth='1'>Bibliography</title>
204
- <p id='_'>There are no normative references in this document.</p>
205
- <bibitem id='A'>
206
- <formattedref format='application/x-isodoc+xml'>
207
- <em>TITLE</em>
208
- </formattedref>
209
- <docidentifier>B</docidentifier>
210
- </bibitem>
211
- </references>
212
- </bibliography>
213
- </iec-standard>
214
- OUTPUT
215
- html = <<~OUTPUT
216
- #{HTML_HDR}
217
- <div id=''>
218
- <h1 class='ForewordTitle'>FOREWORD</h1>
219
- <div class='boilerplate_legal'/>
220
- </div>
221
- #{IEC_TITLE1}
222
- <div>
223
- <h1>1&#160; Normative References</h1>
224
- <p id='_'>There are no normative references in this document.</p>
225
- </div>
226
- </div>
227
- </body>
228
- </html>
229
- OUTPUT
141
+ </bibliography>
142
+ </iec-standard>
143
+ INPUT
144
+ presxml = <<~OUTPUT
145
+ <iec-standard xmlns='https://www.metanorma.org/ns/iec' type="presentation">
146
+ <bibdata type='standard'>
147
+ <docidentifier type='iso'>IEC 60050 ED 1</docidentifier>
148
+ <docnumber>60050</docnumber>
149
+ <contributor>
150
+ <role type='author'/>
151
+ <organization>
152
+ <name>International Electrotechnical Commission</name>
153
+ <abbreviation>IEC</abbreviation>
154
+ </organization>
155
+ </contributor>
156
+ <contributor>
157
+ <role type='publisher'/>
158
+ <organization>
159
+ <name>International Electrotechnical Commission</name>
160
+ <abbreviation>IEC</abbreviation>
161
+ </organization>
162
+ </contributor>
163
+ <language current="true">en</language>
164
+ <script current="true">Latn</script>
165
+ <status>
166
+ <stage language="">60</stage>
167
+ <substage language="">60</substage>
168
+ </status>
169
+ <copyright>
170
+ <from>2020</from>
171
+ <owner>
172
+ <organization>
173
+ <name>International Electrotechnical Commission</name>
174
+ <abbreviation>IEC</abbreviation>
175
+ </organization>
176
+ </owner>
177
+ </copyright>
178
+ <ext>
179
+ <doctype language="">article</doctype>
180
+ <editorialgroup>
181
+ <technical-committee/>
182
+ <subcommittee/>
183
+ <workgroup/>
184
+ </editorialgroup>
185
+ <structuredidentifier>
186
+ <project-number>IEC 60050</project-number>
187
+ </structuredidentifier>
188
+ </ext>
189
+ </bibdata>
190
+ <sections> </sections>
191
+ <bibliography>
192
+ <references obligation='informative' normative='true' id="X" displayorder="1">
193
+ <title depth='1'>1<tab/>Normative References</title>
194
+ <p id='_'>There are no normative references in this document.</p>
195
+ <bibitem id='A'>
196
+ <formattedref format='application/x-isodoc+xml'>
197
+ <em>TITLE</em>
198
+ </formattedref>
199
+ <docidentifier>B</docidentifier>
200
+ </bibitem>
201
+ </references>
202
+ <references id='_' obligation='informative' normative='false' displayorder="2">
203
+ <title depth='1'>Bibliography</title>
204
+ <p id='_'>There are no normative references in this document.</p>
205
+ <bibitem id='A'>
206
+ <formattedref format='application/x-isodoc+xml'>
207
+ <em>TITLE</em>
208
+ </formattedref>
209
+ <docidentifier>B</docidentifier>
210
+ </bibitem>
211
+ </references>
212
+ </bibliography>
213
+ </iec-standard>
214
+ OUTPUT
215
+ html = <<~OUTPUT
216
+ #{HTML_HDR}
217
+ <div id=''>
218
+ <h1 class='ForewordTitle'>FOREWORD</h1>
219
+ <div class='boilerplate_legal'/>
220
+ </div>
221
+ #{IEC_TITLE1}
222
+ <div>
223
+ <h1>1&#160; Normative References</h1>
224
+ <p id='_'>There are no normative references in this document.</p>
225
+ </div>
226
+ </div>
227
+ </body>
228
+ </html>
229
+ OUTPUT
230
230
  expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
231
231
  expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
232
232
  end
233
233
 
234
- it "processes IEV terms" do
235
- input = <<~INPUT
236
- <iso-standard xmlns="http://riboseinc.com/isoxml">
237
- <bibdata type='standard'>
238
- <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
239
- <docnumber>60050</docnumber>
240
- </bibdata>
241
- <sections>
242
- <clause id="_terms_and_definitions" obligation="normative"><title>Terms and definitions</title>
243
- <terms id="_general" obligation="normative"><title>General</title>
244
-
245
- <term id="paddy1"><preferred>paddy</preferred>
246
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
247
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
248
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
249
- <ul>
250
- <li>A</li>
251
- </ul>
252
- </termexample>
253
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
254
- <ul>
255
- <li>A</li>
256
- </ul>
257
- </termexample>
258
-
259
- <termsource status="modified">
260
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
261
- <modification>
262
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
263
- </modification>
264
- </termsource></term>
265
-
266
- <term id="paddy"><preferred>paddy</preferred><admitted>paddy rice</admitted>
267
- <admitted>rough rice</admitted>
268
- <deprecates>cargo rice</deprecates>
269
- <domain>rice</domain>
270
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
271
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
272
- <ul>
273
- <li>A</li>
274
- </ul>
275
- </termexample>
276
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
277
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
278
- </termnote>
279
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
280
- <ul><li>A</li></ul>
281
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
282
- </termnote>
283
- <termsource status="identical">
284
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
285
- </termsource></term>
286
- </terms>
287
- </clause>
288
- </sections>
289
- </iso-standard>
290
- INPUT
291
-
292
- presxml = <<~INPUT
293
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
294
- <bibdata type='standard'>
295
- <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
296
- <docnumber>60050</docnumber>
297
- </bibdata>
298
- <sections>
299
- <clause id="_terms_and_definitions" obligation="normative"><title depth="1">1<tab/>Terms and definitions</title>
300
- <terms id="_general" obligation="normative"><title>192-01 General</title>
301
-
302
- <term id="paddy1">
303
- <name>192-01-01</name>
304
- <preferred>paddy</preferred>
305
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
306
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
307
- <name>EXAMPLE 1</name>
308
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
309
- <ul>
310
- <li>A</li>
311
- </ul>
312
- </termexample>
313
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
314
- <name>EXAMPLE 2</name>
315
- <ul>
316
- <li>A</li>
317
- </ul>
318
- </termexample>
319
-
320
- <termsource status="modified">
321
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
322
- <modification>
323
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
324
- </modification>
325
- </termsource></term>
234
+ it "processes IEV terms" do
235
+ input = <<~INPUT
236
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
237
+ <bibdata type='standard'>
238
+ <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
239
+ <docnumber>60050</docnumber>
240
+ </bibdata>
241
+ <sections>
242
+ <clause id="_terms_and_definitions" obligation="normative"><title>Terms and definitions</title>
243
+ <terms id="_general" obligation="normative"><title>General</title>
244
+ <term id="paddy1"><preferred>paddy</preferred>
245
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
246
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
247
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
248
+ <ul>
249
+ <li>A</li>
250
+ </ul>
251
+ </termexample>
252
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
253
+ <ul>
254
+ <li>A</li>
255
+ </ul>
256
+ </termexample>
257
+ <termsource status="modified">
258
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
259
+ <modification>
260
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
261
+ </modification>
262
+ </termsource></term>
263
+ <term id="paddy"><preferred>paddy</preferred><admitted>paddy rice</admitted>
264
+ <admitted>rough rice</admitted>
265
+ <deprecates>cargo rice</deprecates>
266
+ <domain>rice</domain>
267
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
268
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
269
+ <ul>
270
+ <li>A</li>
271
+ </ul>
272
+ </termexample>
273
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
274
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
275
+ </termnote>
276
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
277
+ <ul><li>A</li></ul>
278
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
279
+ </termnote>
280
+ <termsource status="identical">
281
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
282
+ </termsource></term>
283
+ </terms>
284
+ </clause>
285
+ </sections>
286
+ </iso-standard>
287
+ INPUT
326
288
 
327
- <term id="paddy">
328
- <name>192-01-02</name>
329
- <preferred>paddy</preferred><admitted>paddy rice</admitted>
330
- <admitted>rough rice</admitted>
331
- <deprecates>cargo rice</deprecates>
332
- <domain>rice</domain>
333
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
334
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
335
- <name>EXAMPLE</name>
336
- <ul>
337
- <li>A</li>
338
- </ul>
339
- </termexample>
340
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
341
- <name>Note 1 to entry</name>
342
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
343
- </termnote>
344
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
345
- <name>Note 2 to entry</name>
346
- <ul><li>A</li></ul>
347
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
348
- </termnote>
349
- <termsource status="identical">
350
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
351
- </termsource></term>
352
- </terms>
353
- </clause>
354
- </sections>
355
- </iso-standard>
356
- INPUT
289
+ presxml = <<~INPUT
290
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
291
+ <bibdata type='standard'>
292
+ <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
293
+ <docnumber>60050</docnumber>
294
+ </bibdata>
295
+ <sections>
296
+ <clause id="_terms_and_definitions" obligation="normative" displayorder="1"><title depth="1">1<tab/>Terms and definitions</title>
297
+ <terms id="_general" obligation="normative"><title>192-01 General</title>
298
+ <term id="paddy1">
299
+ <name>192-01-01</name>
300
+ <preferred>paddy</preferred>
301
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
302
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
303
+ <name>EXAMPLE 1</name>
304
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
305
+ <ul>
306
+ <li>A</li>
307
+ </ul>
308
+ </termexample>
309
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
310
+ <name>EXAMPLE 2</name>
311
+ <ul>
312
+ <li>A</li>
313
+ </ul>
314
+ </termexample>
315
+ <termsource status="modified">
316
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
317
+ <modification>
318
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
319
+ </modification>
320
+ </termsource></term>
321
+ <term id="paddy">
322
+ <name>192-01-02</name>
323
+ <preferred>paddy</preferred><admitted>paddy rice</admitted>
324
+ <admitted>rough rice</admitted>
325
+ <deprecates>cargo rice</deprecates>
326
+ <domain>rice</domain>
327
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
328
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
329
+ <name>EXAMPLE</name>
330
+ <ul>
331
+ <li>A</li>
332
+ </ul>
333
+ </termexample>
334
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
335
+ <name>Note 1 to entry</name>
336
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
337
+ </termnote>
338
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
339
+ <name>Note 2 to entry</name>
340
+ <ul><li>A</li></ul>
341
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
342
+ </termnote>
343
+ <termsource status="identical">
344
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
345
+ </termsource></term>
346
+ </terms>
347
+ </clause>
348
+ </sections>
349
+ </iso-standard>
350
+ INPUT
357
351
 
358
- html = <<~OUTPUT
359
- #{HTML_HDR}
360
- <div id=''>
361
- <h1 class='ForewordTitle'>FOREWORD</h1>
362
- <div class='boilerplate_legal'/>
363
- </div>
364
- #{IEC_TITLE1}
365
- <div id='_terms_and_definitions'>
366
- <h1>1&#160; Terms and definitions</h1>
367
- <br/>
368
- <div id='_general'>
369
- <p class='zzSTDTitle2'>
370
- <b>192-01 General</b>
371
- </p>
372
- <p class='TermNum' id='paddy1'>192-01-01</p>
373
- <p class='Terms' style='text-align:left;'>paddy</p>
374
- <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
375
- <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f892' class='example'>
376
- <p>
377
- <span class='example_label'>EXAMPLE 1</span>
378
- &#160; Foreign seeds, husks, bran, sand, dust.
379
- </p>
380
- <ul>
381
- <li>A</li>
382
- </ul>
383
- </div>
384
- <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f894' class='example'>
385
- <p>
386
- <span class='example_label'>EXAMPLE 2</span>
387
- &#160;
388
- </p>
389
- <ul>
390
- <li>A</li>
391
- </ul>
392
- </div>
393
- <p>
394
- [TERMREF]
395
- <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
396
- [MODIFICATION]The term "cargo rice" is shown as deprecated, and
397
- Note 1 to entry is not included here [/TERMREF]
398
- </p>
399
- <p class='TermNum' id='paddy'>192-01-02</p>
400
- <p class='Terms' style='text-align:left;'>paddy, &lt;rice&gt;</p>
401
- <p class='AltTerms' style='text-align:left;'>paddy rice, &lt;rice&gt;</p>
402
- <p class='AltTerms' style='text-align:left;'>rough rice, &lt;rice&gt;</p>
403
- <p class='DeprecatedTerms' style='text-align:left;'>DEPRECATED: cargo rice, &lt;rice&gt;</p>
404
- <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
405
- <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f893' class='example'>
406
- <p>
407
- <span class='example_label'>EXAMPLE</span>
408
- &#160;
409
- </p>
410
- <ul>
411
- <li>A</li>
412
- </ul>
413
- </div>
414
- <div class='Note' id='_671a1994-4783-40d0-bc81-987d06ffb74e'>
415
- <p>
416
- Note 1 to entry: The starch of waxy rice consists almost entirely
417
- of amylopectin. The kernels have a tendency to stick together
418
- after cooking.
419
- </p>
420
- </div>
421
- <div class='Note' id='_671a1994-4783-40d0-bc81-987d06ffb74f'>
422
- <p>
423
- Note 2 to entry:
424
- <ul>
425
- <li>A</li>
426
- </ul>
427
- <p id='_19830f33-e46c-42cc-94ca-a5ef101132d5'>
428
- The starch of waxy rice consists almost entirely of amylopectin.
429
- The kernels have a tendency to stick together after cooking.
430
- </p>
431
- </p>
352
+ html = <<~OUTPUT
353
+ #{HTML_HDR}
354
+ <div id=''>
355
+ <h1 class='ForewordTitle'>FOREWORD</h1>
356
+ <div class='boilerplate_legal'/>
357
+ </div>
358
+ #{IEC_TITLE1}
359
+ <div id='_terms_and_definitions'>
360
+ <h1>1&#160; Terms and definitions</h1>
361
+ <br/>
362
+ <div id='_general'>
363
+ <p class='zzSTDTitle2'>
364
+ <b>192-01 General</b>
365
+ </p>
366
+ <p class='TermNum' id='paddy1'>192-01-01</p>
367
+ <p class='Terms' style='text-align:left;'>paddy</p>
368
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
369
+ <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f892' class='example'>
370
+ <p>
371
+ <span class='example_label'>EXAMPLE 1</span>
372
+ &#160; Foreign seeds, husks, bran, sand, dust.
373
+ </p>
374
+ <ul>
375
+ <li>A</li>
376
+ </ul>
377
+ </div>
378
+ <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f894' class='example'>
379
+ <p>
380
+ <span class='example_label'>EXAMPLE 2</span>
381
+ &#160;
382
+ </p>
383
+ <ul>
384
+ <li>A</li>
385
+ </ul>
386
+ </div>
387
+ <p>
388
+ [TERMREF]
389
+ <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
390
+ [MODIFICATION]The term "cargo rice" is shown as deprecated, and
391
+ Note 1 to entry is not included here [/TERMREF]
392
+ </p>
393
+ <p class='TermNum' id='paddy'>192-01-02</p>
394
+ <p class='Terms' style='text-align:left;'>paddy, &lt;rice&gt;</p>
395
+ <p class='AltTerms' style='text-align:left;'>paddy rice, &lt;rice&gt;</p>
396
+ <p class='AltTerms' style='text-align:left;'>rough rice, &lt;rice&gt;</p>
397
+ <p class='DeprecatedTerms' style='text-align:left;'>DEPRECATED: cargo rice, &lt;rice&gt;</p>
398
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
399
+ <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f893' class='example'>
400
+ <p>
401
+ <span class='example_label'>EXAMPLE</span>
402
+ &#160;
403
+ </p>
404
+ <ul>
405
+ <li>A</li>
406
+ </ul>
407
+ </div>
408
+ <div class='Note' id='_671a1994-4783-40d0-bc81-987d06ffb74e'>
409
+ <p>
410
+ Note 1 to entry: The starch of waxy rice consists almost entirely
411
+ of amylopectin. The kernels have a tendency to stick together
412
+ after cooking.
413
+ </p>
414
+ </div>
415
+ <div class='Note' id='_671a1994-4783-40d0-bc81-987d06ffb74f'>
416
+ <p>
417
+ Note 2 to entry:
418
+ <ul>
419
+ <li>A</li>
420
+ </ul>
421
+ <p id='_19830f33-e46c-42cc-94ca-a5ef101132d5'>
422
+ The starch of waxy rice consists almost entirely of amylopectin.
423
+ The kernels have a tendency to stick together after cooking.
424
+ </p>
425
+ </p>
426
+ </div>
427
+ <p>
428
+ [TERMREF]
429
+ <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
430
+ [/TERMREF]
431
+ </p>
432
+ </div>
433
+ </div>
432
434
  </div>
433
- <p>
434
- [TERMREF]
435
- <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
436
- [/TERMREF]
437
- </p>
438
- </div>
439
- </div>
440
- </div>
441
- </body>
442
- </html>
435
+ </body>
436
+ </html>
443
437
  OUTPUT
444
438
  expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
445
439
  expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
446
- end
440
+ end
447
441
 
448
- it "populates Word template with terms reference labels" do
442
+ it "populates Word template with terms reference labels" do
449
443
  FileUtils.rm_f "test.doc"
450
444
  FileUtils.rm_f "test.html"
451
445
  input = <<~INPUT
452
- <iso-standard xmlns="http://riboseinc.com/isoxml">
453
- <bibdata type='standard'>
454
- <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
455
- <docnumber>60050</docnumber>
456
- </bibdata>
457
- <sections>
458
- <clause id="_terms_and_definitions" obligation="normative"><title>Terms and definitions</title>
459
- <terms id="_general" obligation="normative"><title>General</title>
460
-
461
- <term id="paddy1"><preferred>paddy</preferred>
462
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
463
- <termsource status="modified">
464
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
465
- <modification>
466
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
467
- </modification>
468
- </termsource></term>
469
-
470
- </terms>
471
- </clause>
472
- </sections>
473
- </iso-standard>
446
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
447
+ <bibdata type='standard'>
448
+ <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
449
+ <docnumber>60050</docnumber>
450
+ </bibdata>
451
+ <sections>
452
+ <clause id="_terms_and_definitions" obligation="normative" displayorder="1"><title>Terms and definitions</title>
453
+ <terms id="_general" obligation="normative"><title>General</title>
454
+ <term id="paddy1"><preferred>paddy</preferred>
455
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
456
+ <termsource status="modified">
457
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
458
+ <modification>
459
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
460
+ </modification>
461
+ </termsource></term>
462
+ </terms>
463
+ </clause>
464
+ </sections>
465
+ </iso-standard>
474
466
  INPUT
475
467
  presxml = <<~OUTPUT
476
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
477
- <bibdata type='standard'>
478
- <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
479
- <docnumber>60050</docnumber>
480
- </bibdata>
481
- <sections>
482
- <clause id='_terms_and_definitions' obligation='normative'>
483
- <title depth='1'>1<tab/>Terms and definitions</title>
484
- <terms id='_general' obligation='normative'>
485
- <title>192-01 General</title>
486
- <term id='paddy1'>
487
- <name>192-01-01</name>
488
- <preferred>paddy</preferred>
489
- <definition>
490
- <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
491
- </definition>
492
- <termsource status='modified'>
493
- <origin bibitemid='ISO7301' type='inline' citeas='ISO 7301:2011'>
494
- <locality type='clause'>
495
- <referenceFrom>3.1</referenceFrom>
496
- </locality>
497
- ISO 7301:2011, 3.1
498
- </origin>
499
- <modification>
500
- <p id='_e73a417d-ad39-417d-a4c8-20e4e2529489'>
501
- The term "cargo rice" is shown as deprecated, and Note 1 to
502
- entry is not included here
503
- </p>
504
- </modification>
505
- </termsource>
506
- </term>
507
- </terms>
508
- </clause>
509
- </sections>
510
- </iso-standard>
511
- OUTPUT
468
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
469
+ <bibdata type='standard'>
470
+ <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
471
+ <docnumber>60050</docnumber>
472
+ </bibdata>
473
+ <sections>
474
+ <clause id='_terms_and_definitions' obligation='normative' displayorder="1">
475
+ <title depth='1'>1<tab/>Terms and definitions</title>
476
+ <terms id='_general' obligation='normative'>
477
+ <title>192-01 General</title>
478
+ <term id='paddy1'>
479
+ <name>192-01-01</name>
480
+ <preferred>paddy</preferred>
481
+ <definition>
482
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
483
+ </definition>
484
+ <termsource status='modified'>
485
+ <origin bibitemid='ISO7301' type='inline' citeas='ISO 7301:2011'>
486
+ <locality type='clause'>
487
+ <referenceFrom>3.1</referenceFrom>
488
+ </locality>
489
+ ISO 7301:2011, 3.1
490
+ </origin>
491
+ <modification>
492
+ <p id='_e73a417d-ad39-417d-a4c8-20e4e2529489'>
493
+ The term "cargo rice" is shown as deprecated, and Note 1 to
494
+ entry is not included here
495
+ </p>
496
+ </modification>
497
+ </termsource>
498
+ </term>
499
+ </terms>
500
+ </clause>
501
+ </sections>
502
+ </iso-standard>
503
+ OUTPUT
512
504
  expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
513
505
  IsoDoc::Iec::WordConvert.new({}).convert("test", presxml, false)
514
- word = File.read("test.doc").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
515
- sub(%r{<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>.*$}m, "")
506
+ word = File.read("test.doc").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
507
+ .sub(%r{<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>.*$}m, "")
516
508
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
517
- <div class='WordSection3'>
518
- <p class='zzSTDTitle1'>
519
- <b/>
520
- </p>
521
- <p class='zzSTDTitle1'>&#xA0;</p>
522
- <div>
523
- <a name='_terms_and_definitions' id='_terms_and_definitions'/>
524
- <h1 class='main'>
525
- 1
526
- <span style='mso-tab-count:1'>&#xA0; </span>
527
- Terms and definitions
528
- </h1>
529
- <p class='MsoNormal'>
530
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
509
+ <div class='WordSection3'>
510
+ <p class='zzSTDTitle1'>
511
+ <b/>
531
512
  </p>
513
+ <p class='zzSTDTitle1'>&#xA0;</p>
532
514
  <div>
533
- <a name='_general' id='_general'/>
534
- <p class='zzSTDTitle2'>
535
- <b>192-01 General</b>
536
- </p>
537
- <p class='TermNum'>
538
- <a name='paddy1' id='paddy1'/>
539
- 192-01-01
540
- </p>
541
- <p class='Terms' style='text-align:left;'>paddy</p>
542
- <p class='MsoNormal'>
543
- <a name='_eb29b35e-123e-4d1c-b50b-2714d41e747f' id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'/>
544
- rice retaining its husk after threshing
545
- </p>
515
+ <a name='_terms_and_definitions' id='_terms_and_definitions'/>
516
+ <h1 class='main'>
517
+ 1
518
+ <span style='mso-tab-count:1'>&#xA0; </span>
519
+ Terms and definitions
520
+ </h1>
546
521
  <p class='MsoNormal'>
547
- SOURCE:
548
- <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
549
- , modified &#x2014; The term "cargo rice" is shown as deprecated, and
550
- Note 1 to entry is not included here
522
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
551
523
  </p>
524
+ <div>
525
+ <a name='_general' id='_general'/>
526
+ <p class='zzSTDTitle2'>
527
+ <b>192-01 General</b>
528
+ </p>
529
+ <p class='TermNum'>
530
+ <a name='paddy1' id='paddy1'/>
531
+ 192-01-01
532
+ </p>
533
+ <p class='Terms' style='text-align:left;'>paddy</p>
534
+ <p class='MsoNormal'>
535
+ <a name='_eb29b35e-123e-4d1c-b50b-2714d41e747f' id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'/>
536
+ rice retaining its husk after threshing
537
+ </p>
538
+ <p class='MsoNormal'>
539
+ SOURCE:
540
+ <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
541
+ , modified &#x2014; The term "cargo rice" is shown as deprecated, and
542
+ Note 1 to entry is not included here
543
+ </p>
544
+ </div>
552
545
  </div>
553
546
  </div>
554
- </div>
555
547
  OUTPUT
556
548
  end
557
-
558
-
559
549
  end
560
-