slaw 0.6.11 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32f937272e68d3b5ebb089d674c5b1bc922c8701
4
- data.tar.gz: 1db5a51f4e907f62a24d1161431307cc08532fcb
3
+ metadata.gz: abd66cac7464d7d0e76983e97002f39e0ad85b6e
4
+ data.tar.gz: 681cfe499a8e96bc7183415b2ab795e834efa48a
5
5
  SHA512:
6
- metadata.gz: 3f8efd5235fc15f73ff3541740162239eaa836d929254761fa0a1c18172f99a50903e2ee2893bd6a1bdf5b860bf1a5882e039964489d456bfe0e890dfe9bad30
7
- data.tar.gz: f1df7fcc8ae78241881576a4faf0d8032f995fa6a23b0267fc7c2364788b8bd9845079d9ba91b818c2e649d1c80b50856e469868f5e6b3d66fe8f22d89302851
6
+ metadata.gz: e1cc2cdbb8626fe61e8f688100d2b1c32b12772aadd4166f766c346fa27c69549358696b50e06797968f52ec1a7e9ce28df75060b8f4648ceca55dd280581dac
7
+ data.tar.gz: 485ddceb9b8efd4b8f9275735603e8c1edcbce766b6c541d82c1a0801a53045b83da833ab5e057b628e533f31d1fc97f13b84c4e03441a06ef3c393922cfeda9
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "0.6.11"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -15,8 +15,8 @@ module Slaw
15
15
  empty_line*
16
16
  preface:preface?
17
17
  preamble:preamble?
18
- chapters:chapter*
19
- schedules:schedules <Act>
18
+ body
19
+ schedules:schedules_container? <Act>
20
20
  end
21
21
 
22
22
  rule preface
@@ -30,14 +30,20 @@ module Slaw
30
30
  statements:naked_statement* <Preamble>
31
31
  end
32
32
 
33
+ rule body
34
+ children:(chapter / part / section / block_paragraphs / subsection)+ <Body>
35
+ end
36
+
33
37
  rule chapter
34
- heading:chapter_heading?
35
- parts:part+ <Chapter>
38
+ heading:chapter_heading
39
+ children:(part / section / block_paragraphs / subsection)+
40
+ <Chapter>
36
41
  end
37
42
 
38
43
  rule part
39
- heading:part_heading?
40
- sections:section+ <Part>
44
+ heading:part_heading
45
+ children:(section / block_paragraphs / subsection)+
46
+ <Part>
41
47
  end
42
48
 
43
49
  rule section
@@ -50,25 +56,56 @@ module Slaw
50
56
  blocklist:blocklist? <Subsection>
51
57
  end
52
58
 
59
+ rule schedules_container
60
+ schedules:schedules <ScheduleContainer>
61
+ end
62
+
53
63
  rule schedules
54
- schedules:schedule* <ScheduleContainer>
64
+ children:schedule+ <GroupNode>
55
65
  end
56
66
 
57
67
  rule schedule
58
68
  schedule_heading
59
- statements:(table / schedule_statement)* <Schedule>
69
+ body
70
+ <Schedule>
71
+ end
72
+
73
+ rule block_paragraphs
74
+ block_element+ <BlockParagraph>
75
+ end
76
+
77
+ rule block_element
78
+ (table / blocklist / naked_statement)
79
+ end
80
+
81
+ ##########
82
+ # group elements
83
+ #
84
+ # these are used externally and provide support when parsing just
85
+ # a particular portion of a document
86
+
87
+ rule chapters
88
+ children:chapter+ <GroupNode>
89
+ end
90
+
91
+ rule parts
92
+ children:part+ <GroupNode>
93
+ end
94
+
95
+ rule sections
96
+ children:section+ <GroupNode>
60
97
  end
61
98
 
62
99
  ##########
63
100
  # headings
64
101
 
65
102
  rule chapter_heading
66
- space? chapter_heading_prefix heading:(whitespace content)? eol
103
+ space? chapter_heading_prefix heading:(newline? content)? eol
67
104
  <ChapterHeading>
68
105
  end
69
106
 
70
107
  rule part_heading
71
- space? part_heading_prefix eol? space? content eol
108
+ space? part_heading_prefix heading:(newline? content)? eol
72
109
  <PartHeading>
73
110
  end
74
111
 
@@ -120,7 +157,7 @@ module Slaw
120
157
  end
121
158
 
122
159
  rule naked_statement
123
- space? !(part / chapter / section / schedule) clauses eol
160
+ space? !(chapter_heading / part_heading / section_title / schedule_heading) clauses eol
124
161
  <NakedStatement>
125
162
  end
126
163
 
@@ -160,11 +197,11 @@ module Slaw
160
197
  # prefixes
161
198
 
162
199
  rule part_heading_prefix
163
- 'part'i space alphanums whitespace [:-]?
200
+ 'part'i space alphanums [ :-]*
164
201
  end
165
202
 
166
203
  rule chapter_heading_prefix
167
- 'chapter'i space alphanums
204
+ 'chapter'i space alphanums [ :-]*
168
205
  end
169
206
 
170
207
  rule schedule_heading_prefix
@@ -9,7 +9,7 @@ module Slaw
9
9
  EXPRESSION_URI = "#{FRBR_URI}/eng@"
10
10
  MANIFESTATION_URI = EXPRESSION_URI
11
11
 
12
- def to_xml(b, idprefix)
12
+ def to_xml(b, idprefix=nil, i=0)
13
13
  b.act(contains: "originalVersion") { |b|
14
14
  write_meta(b)
15
15
  write_preface(b)
@@ -26,7 +26,6 @@ module Slaw
26
26
  b.references(source: "#this") {
27
27
  b.TLCOrganization(id: 'slaw', href: 'https://github.com/longhotsummer/slaw', showAs: "Slaw")
28
28
  b.TLCOrganization(id: 'council', href: '/ontology/organization/za/council', showAs: "Council")
29
- b.TLCRole(id: 'author', href: '/ontology/role/author', showAs: 'Author')
30
29
  }
31
30
  }
32
31
  end
@@ -39,21 +38,21 @@ module Slaw
39
38
  b.FRBRuri(value: WORK_URI)
40
39
  b.FRBRalias(value: 'Short Title')
41
40
  b.FRBRdate(date: '1980-01-01', name: 'Generation')
42
- b.FRBRauthor(href: '#council', as: '#author')
41
+ b.FRBRauthor(href: '#council')
43
42
  b.FRBRcountry(value: 'za')
44
43
  }
45
44
  b.FRBRExpression { |b|
46
45
  b.FRBRthis(value: "#{EXPRESSION_URI}/main")
47
46
  b.FRBRuri(value: EXPRESSION_URI)
48
47
  b.FRBRdate(date: '1980-01-01', name: 'Generation')
49
- b.FRBRauthor(href: '#council', as: '#author')
48
+ b.FRBRauthor(href: '#council')
50
49
  b.FRBRlanguage(language: 'eng')
51
50
  }
52
51
  b.FRBRManifestation { |b|
53
52
  b.FRBRthis(value: "#{MANIFESTATION_URI}/main")
54
53
  b.FRBRuri(value: MANIFESTATION_URI)
55
54
  b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation')
56
- b.FRBRauthor(href: '#slaw', as: '#author')
55
+ b.FRBRauthor(href: '#slaw')
57
56
  }
58
57
  }
59
58
  end
@@ -67,18 +66,32 @@ module Slaw
67
66
  end
68
67
 
69
68
  def write_body(b)
69
+ body.to_xml(b)
70
+ end
71
+
72
+ def write_schedules(b)
73
+ if schedules.text_value != ""
74
+ schedules.to_xml(b)
75
+ end
76
+ end
77
+ end
78
+
79
+ class Body < Treetop::Runtime::SyntaxNode
80
+ def to_xml(b)
70
81
  b.body { |b|
71
- chapters.elements.each { |e| e.to_xml(b) }
82
+ children.elements.each { |e| e.to_xml(b, '') }
72
83
  }
73
84
  end
85
+ end
74
86
 
75
- def write_schedules(b)
76
- schedules.to_xml(b)
87
+ class GroupNode < Treetop::Runtime::SyntaxNode
88
+ def to_xml(b, *args)
89
+ children.elements.each { |e| e.to_xml(b, *args) }
77
90
  end
78
91
  end
79
92
 
80
93
  class Preface < Treetop::Runtime::SyntaxNode
81
- def to_xml(b)
94
+ def to_xml(b, *args)
82
95
  if text_value != ""
83
96
  b.preface { |b|
84
97
  statements.elements.each { |element|
@@ -92,7 +105,7 @@ module Slaw
92
105
  end
93
106
 
94
107
  class Preamble < Treetop::Runtime::SyntaxNode
95
- def to_xml(b)
108
+ def to_xml(b, *args)
96
109
  if text_value != ""
97
110
  b.preamble { |b|
98
111
  statements.elements.each { |e|
@@ -105,27 +118,21 @@ module Slaw
105
118
 
106
119
  class Part < Treetop::Runtime::SyntaxNode
107
120
  def num
108
- heading.empty? ? nil : heading.num
121
+ heading.num
109
122
  end
110
123
 
111
- def to_xml(b)
112
- # do we have a part heading?
113
- if not heading.empty?
114
- id = "part-#{num}"
115
-
116
- # include a chapter number in the id if our parent has one
117
- if parent and parent.parent.is_a?(Chapter) and parent.parent.num
118
- id = "chapter-#{parent.parent.num}.#{id}"
119
- end
124
+ def to_xml(b, *args)
125
+ id = "part-#{num}"
120
126
 
121
- b.part(id: id) { |b|
122
- heading.to_xml(b)
123
- sections.elements.each { |e| e.to_xml(b) }
124
- }
125
- else
126
- # no parts
127
- sections.elements.each { |e| e.to_xml(b) }
127
+ # include a chapter number in the id if our parent has one
128
+ if parent and parent.parent.is_a?(Chapter) and parent.parent.num
129
+ id = "chapter-#{parent.parent.num}.#{id}"
128
130
  end
131
+
132
+ b.part(id: id) { |b|
133
+ heading.to_xml(b)
134
+ children.elements.each_with_index { |e, i| e.to_xml(b, id + '.', i) }
135
+ }
129
136
  end
130
137
  end
131
138
 
@@ -135,38 +142,34 @@ module Slaw
135
142
  end
136
143
 
137
144
  def title
138
- content.text_value
145
+ if heading.text_value and heading.respond_to? :content
146
+ heading.content.text_value
147
+ end
139
148
  end
140
149
 
141
150
  def to_xml(b)
142
151
  b.num(num)
143
- b.heading(title)
152
+ b.heading(title) if title
144
153
  end
145
154
  end
146
155
 
147
156
  class Chapter < Treetop::Runtime::SyntaxNode
148
157
  def num
149
- heading.empty? ? nil : heading.num
158
+ heading.num
150
159
  end
151
160
 
152
- def to_xml(b)
153
- # do we have a chapter heading?
154
- if not heading.empty?
155
- id = "chapter-#{num}"
156
-
157
- # include a part number in the id if our parent has one
158
- if parent and parent.parent.is_a?(Part) and parent.parent.num
159
- id = "part-#{parent.parent.num}.#{id}"
160
- end
161
+ def to_xml(b, *args)
162
+ id = "chapter-#{num}"
161
163
 
162
- b.chapter(id: id) { |b|
163
- heading.to_xml(b)
164
- parts.elements.each { |e| e.to_xml(b) }
165
- }
166
- else
167
- # no chapters
168
- parts.elements.each { |e| e.to_xml(b) }
164
+ # include a part number in the id if our parent has one
165
+ if parent and parent.parent.is_a?(Part) and parent.parent.num
166
+ id = "part-#{parent.parent.num}.#{id}"
169
167
  end
168
+
169
+ b.chapter(id: id) { |b|
170
+ heading.to_xml(b)
171
+ children.elements.each_with_index { |e, i| e.to_xml(b, id + '.', i) }
172
+ }
170
173
  end
171
174
  end
172
175
 
@@ -176,10 +179,8 @@ module Slaw
176
179
  end
177
180
 
178
181
  def title
179
- if self.respond_to? :heading
182
+ if heading.text_value and heading.respond_to? :content
180
183
  heading.content.text_value
181
- elsif self.respond_to? :content
182
- content.text_value
183
184
  end
184
185
  end
185
186
 
@@ -198,7 +199,7 @@ module Slaw
198
199
  section_title.title
199
200
  end
200
201
 
201
- def to_xml(b)
202
+ def to_xml(b, *args)
202
203
  id = "section-#{num}"
203
204
  b.section(id: id) { |b|
204
205
  b.num("#{num}.")
@@ -274,6 +275,16 @@ module Slaw
274
275
  end
275
276
  end
276
277
 
278
+ class BlockParagraph < Treetop::Runtime::SyntaxNode
279
+ def to_xml(b, idprefix='', i=0)
280
+ b.paragraph(id: "#{idprefix}paragraph-0") { |b|
281
+ b.content { |b|
282
+ elements.each_with_index { |e, i| e.to_xml(b, idprefix) }
283
+ }
284
+ }
285
+ end
286
+ end
287
+
277
288
  class NumberedStatement < Treetop::Runtime::SyntaxNode
278
289
  def num
279
290
  numbered_statement_prefix.num.text_value
@@ -386,13 +397,9 @@ module Slaw
386
397
 
387
398
  class ScheduleContainer < Treetop::Runtime::SyntaxNode
388
399
  def to_xml(b)
389
- return if schedules.elements.empty?
390
-
391
400
  b.components { |b|
392
- schedules.elements.each_with_index { |e, i|
393
- b.component(id: "component-#{i+1}") { |b|
394
- e.to_xml(b, "", i+1)
395
- }
401
+ schedules.children.elements.each_with_index { |e, i|
402
+ e.to_xml(b, "", i+1)
396
403
  }
397
404
  }
398
405
  end
@@ -420,47 +427,47 @@ module Slaw
420
427
  end
421
428
  end
422
429
 
423
- def to_xml(b, idprefix, i=1)
430
+ def to_xml(b, idprefix=nil, i=1)
424
431
  n = num.nil? ? i : num
425
432
 
426
433
  # component name
427
434
  comp = "schedule#{n}"
428
435
  id = "#{idprefix}schedule-#{n}"
429
436
 
430
- b.doc_(name: "schedule#{n}") { |b|
431
- b.meta { |b|
432
- b.identification(source: "#slaw") { |b|
433
- b.FRBRWork { |b|
434
- b.FRBRthis(value: "#{Act::WORK_URI}/#{comp}")
435
- b.FRBRuri(value: Act::WORK_URI)
436
- b.FRBRalias(value: self.alias)
437
- b.FRBRdate(date: '1980-01-01', name: 'Generation')
438
- b.FRBRauthor(href: '#council', as: '#author')
439
- b.FRBRcountry(value: 'za')
440
- }
441
- b.FRBRExpression { |b|
442
- b.FRBRthis(value: "#{Act::EXPRESSION_URI}/#{comp}")
443
- b.FRBRuri(value: Act::EXPRESSION_URI)
444
- b.FRBRdate(date: '1980-01-01', name: 'Generation')
445
- b.FRBRauthor(href: '#council', as: '#author')
446
- b.FRBRlanguage(language: 'eng')
447
- }
448
- b.FRBRManifestation { |b|
449
- b.FRBRthis(value: "#{Act::MANIFESTATION_URI}/#{comp}")
450
- b.FRBRuri(value: Act::MANIFESTATION_URI)
451
- b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation')
452
- b.FRBRauthor(href: '#slaw', as: '#author')
437
+ b.component(id: "component-#{id}") { |b|
438
+ b.doc_(name: "schedule#{n}") { |b|
439
+ b.meta { |b|
440
+ b.identification(source: "#slaw") { |b|
441
+ b.FRBRWork { |b|
442
+ b.FRBRthis(value: "#{Act::WORK_URI}/#{comp}")
443
+ b.FRBRuri(value: Act::WORK_URI)
444
+ b.FRBRalias(value: self.alias)
445
+ b.FRBRdate(date: '1980-01-01', name: 'Generation')
446
+ b.FRBRauthor(href: '#council')
447
+ b.FRBRcountry(value: 'za')
448
+ }
449
+ b.FRBRExpression { |b|
450
+ b.FRBRthis(value: "#{Act::EXPRESSION_URI}/#{comp}")
451
+ b.FRBRuri(value: Act::EXPRESSION_URI)
452
+ b.FRBRdate(date: '1980-01-01', name: 'Generation')
453
+ b.FRBRauthor(href: '#council')
454
+ b.FRBRlanguage(language: 'eng')
455
+ }
456
+ b.FRBRManifestation { |b|
457
+ b.FRBRthis(value: "#{Act::MANIFESTATION_URI}/#{comp}")
458
+ b.FRBRuri(value: Act::MANIFESTATION_URI)
459
+ b.FRBRdate(date: Time.now.strftime('%Y-%m-%d'), name: 'Generation')
460
+ b.FRBRauthor(href: '#slaw')
461
+ }
453
462
  }
454
463
  }
455
- }
456
464
 
457
- b.mainBody { |b|
458
- # there is no good AKN hierarchy container for schedules, so we
459
- # just use article because we don't use it anywhere else.
460
- b.article(id: id) { |b|
461
- b.heading(heading) if heading
462
- b.content { |b|
463
- statements.elements.each { |e| e.to_xml(b, id + '.') }
465
+ b.mainBody { |b|
466
+ # there is no good AKN hierarchy container for schedules, so we
467
+ # just use article because we don't use it anywhere else.
468
+ b.article(id: id) { |b|
469
+ b.heading(heading) if heading
470
+ body.children.elements.each { |e| e.to_xml(b) }
464
471
  }
465
472
  }
466
473
  }
data/spec/za/act_spec.rb CHANGED
@@ -27,19 +27,85 @@ describe Slaw::ActGenerator do
27
27
  b.doc.root.to_xml(encoding: 'UTF-8')
28
28
  end
29
29
 
30
+ #-------------------------------------------------------------------------------
31
+ # General body
32
+
33
+ describe 'body' do
34
+ it 'should handle general content before chapters' do
35
+ node = parse :body, <<EOS
36
+ Some content before the section
37
+
38
+ 1. Section
39
+ Hello there
40
+ EOS
41
+ to_xml(node).should == '<body>
42
+ <paragraph id="paragraph-0">
43
+ <content>
44
+ <p>Some content before the section</p>
45
+ </content>
46
+ </paragraph>
47
+ <section id="section-1">
48
+ <num>1.</num>
49
+ <heading>Section</heading>
50
+ <subsection id="section-1.subsection-0">
51
+ <content>
52
+ <p>Hello there</p>
53
+ </content>
54
+ </subsection>
55
+ </section>
56
+ </body>'
57
+ end
58
+
59
+ it 'should handle blocklists before chapters' do
60
+ node = parse :body, <<EOS
61
+ Some content before the section
62
+
63
+ (a) foo
64
+ (b) bar
65
+
66
+ 1. Section
67
+ Hello there
68
+ EOS
69
+ to_xml(node).should == '<body>
70
+ <paragraph id="paragraph-0">
71
+ <content>
72
+ <p>Some content before the section</p>
73
+ <blockList id="list0">
74
+ <item id="list0.a">
75
+ <num>(a)</num>
76
+ <p>foo</p>
77
+ </item>
78
+ <item id="list0.b">
79
+ <num>(b)</num>
80
+ <p>bar</p>
81
+ </item>
82
+ </blockList>
83
+ </content>
84
+ </paragraph>
85
+ <section id="section-1">
86
+ <num>1.</num>
87
+ <heading>Section</heading>
88
+ <subsection id="section-1.subsection-0">
89
+ <content>
90
+ <p>Hello there</p>
91
+ </content>
92
+ </subsection>
93
+ </section>
94
+ </body>'
95
+ end
96
+ end
97
+
30
98
  #-------------------------------------------------------------------------------
31
99
  # Chapters
32
100
  #
33
101
  describe 'chapters' do
34
102
  it 'should handle chapter headers' do
35
103
  node = parse :chapter, <<EOS
36
- ChaPTEr 2
104
+ ChaPTEr 2 -
37
105
  The Chapter Heading
38
106
  1. Section
39
107
  Hello there
40
108
  EOS
41
- node.num.should == "2"
42
- node.heading.title.should == 'The Chapter Heading'
43
109
  to_xml(node).should == '<chapter id="chapter-2">
44
110
  <num>2</num>
45
111
  <heading>The Chapter Heading</heading>
@@ -52,6 +118,79 @@ EOS
52
118
  </content>
53
119
  </subsection>
54
120
  </section>
121
+ </chapter>'
122
+ end
123
+
124
+ it 'should handle chapters without titles' do
125
+ node = parse :chapter, <<EOS
126
+ ChaPTEr 2:
127
+
128
+ 1. Section
129
+ Hello there
130
+ EOS
131
+ to_xml(node).should == '<chapter id="chapter-2">
132
+ <num>2</num>
133
+ <section id="section-1">
134
+ <num>1.</num>
135
+ <heading>Section</heading>
136
+ <subsection id="section-1.subsection-0">
137
+ <content>
138
+ <p>Hello there</p>
139
+ </content>
140
+ </subsection>
141
+ </section>
142
+ </chapter>'
143
+ end
144
+
145
+ it 'should handle general content at the start of a chapter' do
146
+ node = parse :chapter, <<EOS
147
+ Chapter 2
148
+ The Chapter Heading
149
+
150
+ Some lines at the start of the chapter.
151
+ EOS
152
+ node.num.should == "2"
153
+ node.heading.title.should == 'The Chapter Heading'
154
+ to_xml(node).should == '<chapter id="chapter-2">
155
+ <num>2</num>
156
+ <heading>The Chapter Heading</heading>
157
+ <paragraph id="chapter-2.paragraph-0">
158
+ <content>
159
+ <p>Some lines at the start of the chapter.</p>
160
+ </content>
161
+ </paragraph>
162
+ </chapter>'
163
+ end
164
+
165
+ it 'should handle general content at the start of a chapter with other content' do
166
+ node = parse :chapter, <<EOS
167
+ Chapter 2 - The Chapter Heading
168
+
169
+ Some lines at the start of the chapter.
170
+
171
+ 1. Section 1
172
+
173
+ Section text.
174
+ EOS
175
+ node.num.should == "2"
176
+ node.heading.title.should == 'The Chapter Heading'
177
+ to_xml(node).should == '<chapter id="chapter-2">
178
+ <num>2</num>
179
+ <heading>The Chapter Heading</heading>
180
+ <paragraph id="chapter-2.paragraph-0">
181
+ <content>
182
+ <p>Some lines at the start of the chapter.</p>
183
+ </content>
184
+ </paragraph>
185
+ <section id="section-1">
186
+ <num>1.</num>
187
+ <heading>Section 1</heading>
188
+ <subsection id="section-1.subsection-0">
189
+ <content>
190
+ <p>Section text.</p>
191
+ </content>
192
+ </subsection>
193
+ </section>
55
194
  </chapter>'
56
195
  end
57
196
  end
@@ -67,8 +206,6 @@ The Part Heading
67
206
  1. Section
68
207
  Hello there
69
208
  EOS
70
- node.num.should == "2"
71
- node.heading.title.should == 'The Part Heading'
72
209
  to_xml(node).should == '<part id="part-2">
73
210
  <num>2</num>
74
211
  <heading>The Part Heading</heading>
@@ -90,8 +227,6 @@ Part 2 - The Part Heading
90
227
  1. Section
91
228
  Hello there
92
229
  EOS
93
- node.num.should == "2"
94
- node.heading.title.should == 'The Part Heading'
95
230
  to_xml(node).should == '<part id="part-2">
96
231
  <num>2</num>
97
232
  <heading>The Part Heading</heading>
@@ -113,8 +248,6 @@ Part 2: The Part Heading
113
248
  1. Section
114
249
  Hello there
115
250
  EOS
116
- node.num.should == "2"
117
- node.heading.title.should == 'The Part Heading'
118
251
  to_xml(node).should == '<part id="part-2">
119
252
  <num>2</num>
120
253
  <heading>The Part Heading</heading>
@@ -130,22 +263,80 @@ EOS
130
263
  </part>'
131
264
  end
132
265
 
266
+ it 'should handle part headers without titles' do
267
+ node = parse :part, <<EOS
268
+ Part 2:
269
+
270
+ 1. Section
271
+ Hello there
272
+ EOS
273
+ to_xml(node).should == '<part id="part-2">
274
+ <num>2</num>
275
+ <section id="section-1">
276
+ <num>1.</num>
277
+ <heading>Section</heading>
278
+ <subsection id="section-1.subsection-0">
279
+ <content>
280
+ <p>Hello there</p>
281
+ </content>
282
+ </subsection>
283
+ </section>
284
+ </part>'
285
+ end
286
+
133
287
  it 'should handle parts and odd section numbers' do
134
288
  subject.parser.options = {section_number_after_title: false}
135
- node = parse :act, <<EOS
289
+ node = parse :parts, <<EOS
136
290
  PART 1
137
291
  PREVENTION AND SUPPRESSION OF HEALTH NUISANCES
138
292
  1.
139
293
  No owner or occupier of any shop or business premises or vacant land adjoining a shop or business premises shall cause a health nuisance.
140
294
  EOS
295
+ to_xml(node).should == '<part id="part-1">
296
+ <num>1</num>
297
+ <heading>PREVENTION AND SUPPRESSION OF HEALTH NUISANCES</heading>
298
+ <section id="section-1">
299
+ <num>1.</num>
300
+ <heading/>
301
+ <subsection id="section-1.subsection-0">
302
+ <content>
303
+ <p>No owner or occupier of any shop or business premises or vacant land adjoining a shop or business premises shall cause a health nuisance.</p>
304
+ </content>
305
+ </subsection>
306
+ </section>
307
+ </part>'
308
+ end
309
+
310
+ it 'should handle general content after the part heading' do
311
+ node = parse :part, <<EOS
312
+ Part 2
313
+ The Part Heading
141
314
 
142
- part = node.chapters.elements[0].parts.elements[0]
143
- part.heading.num.should == "1"
144
- part.heading.title.should == "PREVENTION AND SUPPRESSION OF HEALTH NUISANCES"
315
+ Some text before the part.
145
316
 
146
- section = part.elements[1].elements[0]
147
- section.section_title.title.should == ""
148
- section.section_title.section_title_prefix.number_letter.text_value.should == "1"
317
+ 1. Section
318
+ Hello there
319
+ EOS
320
+ node.num.should == "2"
321
+ node.heading.title.should == 'The Part Heading'
322
+ to_xml(node).should == '<part id="part-2">
323
+ <num>2</num>
324
+ <heading>The Part Heading</heading>
325
+ <paragraph id="part-2.paragraph-0">
326
+ <content>
327
+ <p>Some text before the part.</p>
328
+ </content>
329
+ </paragraph>
330
+ <section id="section-1">
331
+ <num>1.</num>
332
+ <heading>Section</heading>
333
+ <subsection id="section-1.subsection-0">
334
+ <content>
335
+ <p>Hello there</p>
336
+ </content>
337
+ </subsection>
338
+ </section>
339
+ </part>'
149
340
  end
150
341
  end
151
342
 
@@ -414,44 +605,48 @@ EOS
414
605
  EOS
415
606
 
416
607
  today = Time.now.strftime('%Y-%m-%d')
417
- to_xml(node, "").should == '<doc name="schedule1">
418
- <meta>
419
- <identification source="#slaw">
420
- <FRBRWork>
421
- <FRBRthis value="/za/act/1980/01/schedule1"/>
422
- <FRBRuri value="/za/act/1980/01"/>
423
- <FRBRalias value="Schedule 1"/>
424
- <FRBRdate date="1980-01-01" name="Generation"/>
425
- <FRBRauthor href="#council" as="#author"/>
426
- <FRBRcountry value="za"/>
427
- </FRBRWork>
428
- <FRBRExpression>
429
- <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
430
- <FRBRuri value="/za/act/1980/01/eng@"/>
431
- <FRBRdate date="1980-01-01" name="Generation"/>
432
- <FRBRauthor href="#council" as="#author"/>
433
- <FRBRlanguage language="eng"/>
434
- </FRBRExpression>
435
- <FRBRManifestation>
436
- <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
437
- <FRBRuri value="/za/act/1980/01/eng@"/>
438
- <FRBRdate date="' + today + '" name="Generation"/>
439
- <FRBRauthor href="#slaw" as="#author"/>
440
- </FRBRManifestation>
441
- </identification>
442
- </meta>
443
- <mainBody>
444
- <article id="schedule-1">
445
- <heading>A Title</heading>
446
- <content>
447
- <p>
448
- <remark status="editorial">[Schedule 1 added by Act 23 of 2004]</remark>
449
- </p>
450
- <p>Some content</p>
451
- </content>
452
- </article>
453
- </mainBody>
454
- </doc>'
608
+ to_xml(node, "").should == '<component id="component-schedule-1">
609
+ <doc name="schedule1">
610
+ <meta>
611
+ <identification source="#slaw">
612
+ <FRBRWork>
613
+ <FRBRthis value="/za/act/1980/01/schedule1"/>
614
+ <FRBRuri value="/za/act/1980/01"/>
615
+ <FRBRalias value="Schedule 1"/>
616
+ <FRBRdate date="1980-01-01" name="Generation"/>
617
+ <FRBRauthor href="#council"/>
618
+ <FRBRcountry value="za"/>
619
+ </FRBRWork>
620
+ <FRBRExpression>
621
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
622
+ <FRBRuri value="/za/act/1980/01/eng@"/>
623
+ <FRBRdate date="1980-01-01" name="Generation"/>
624
+ <FRBRauthor href="#council"/>
625
+ <FRBRlanguage language="eng"/>
626
+ </FRBRExpression>
627
+ <FRBRManifestation>
628
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
629
+ <FRBRuri value="/za/act/1980/01/eng@"/>
630
+ <FRBRdate date="' + today + '" name="Generation"/>
631
+ <FRBRauthor href="#slaw"/>
632
+ </FRBRManifestation>
633
+ </identification>
634
+ </meta>
635
+ <mainBody>
636
+ <article id="schedule-1">
637
+ <heading>A Title</heading>
638
+ <paragraph id="paragraph-0">
639
+ <content>
640
+ <p>
641
+ <remark status="editorial">[Schedule 1 added by Act 23 of 2004]</remark>
642
+ </p>
643
+ <p>Some content</p>
644
+ </content>
645
+ </paragraph>
646
+ </article>
647
+ </mainBody>
648
+ </doc>
649
+ </component>'
455
650
  end
456
651
  end
457
652
 
@@ -503,27 +698,26 @@ baz
503
698
  <FRBRuri value="/za/act/1980/01"/>
504
699
  <FRBRalias value="Short Title"/>
505
700
  <FRBRdate date="1980-01-01" name="Generation"/>
506
- <FRBRauthor href="#council" as="#author"/>
701
+ <FRBRauthor href="#council"/>
507
702
  <FRBRcountry value="za"/>
508
703
  </FRBRWork>
509
704
  <FRBRExpression>
510
705
  <FRBRthis value="/za/act/1980/01/eng@/main"/>
511
706
  <FRBRuri value="/za/act/1980/01/eng@"/>
512
707
  <FRBRdate date="1980-01-01" name="Generation"/>
513
- <FRBRauthor href="#council" as="#author"/>
708
+ <FRBRauthor href="#council"/>
514
709
  <FRBRlanguage language="eng"/>
515
710
  </FRBRExpression>
516
711
  <FRBRManifestation>
517
712
  <FRBRthis value="/za/act/1980/01/eng@/main"/>
518
713
  <FRBRuri value="/za/act/1980/01/eng@"/>
519
714
  <FRBRdate date="' + today + '" name="Generation"/>
520
- <FRBRauthor href="#slaw" as="#author"/>
715
+ <FRBRauthor href="#slaw"/>
521
716
  </FRBRManifestation>
522
717
  </identification>
523
718
  <references source="#this">
524
719
  <TLCOrganization id="slaw" href="https://github.com/longhotsummer/slaw" showAs="Slaw"/>
525
720
  <TLCOrganization id="council" href="/ontology/organization/za/council" showAs="Council"/>
526
- <TLCRole id="author" href="/ontology/role/author" showAs="Author"/>
527
721
  </references>
528
722
  </meta>
529
723
  <preface>
@@ -696,58 +890,99 @@ EOS
696
890
  context 'sections' do
697
891
  it 'should handle section numbers after title' do
698
892
  subject.parser.options = {section_number_after_title: true}
699
- node = parse :act, <<EOS
893
+ node = parse :section, <<EOS
700
894
  Section
701
895
  1. (1) hello
702
896
  EOS
703
897
 
704
- section = node.chapters.elements.first.parts.elements.first.sections.elements.first
705
- section.section_title.content.text_value.should == "Section"
706
- section.section_title.section_title_prefix.number_letter.text_value.should == "1"
898
+ s = to_xml(node)
899
+ s.should == '<section id="section-1">
900
+ <num>1.</num>
901
+ <heading>Section</heading>
902
+ <subsection id="section-1.1">
903
+ <num>(1)</num>
904
+ <content>
905
+ <p>hello</p>
906
+ </content>
907
+ </subsection>
908
+ </section>'
707
909
  end
708
910
 
709
911
  it 'should handle section numbers before title' do
710
912
  subject.parser.options = {section_number_after_title: false}
711
- node = parse :act, <<EOS
913
+ node = parse :section, <<EOS
712
914
  1. Section
713
915
  (1) hello
714
916
  EOS
715
-
716
- section = node.chapters.elements.first.parts.elements.first.sections.elements.first
717
- section.section_title.title.should == "Section"
718
- section.section_title.num.should == "1"
917
+ s = to_xml(node)
918
+ s.should == '<section id="section-1">
919
+ <num>1.</num>
920
+ <heading>Section</heading>
921
+ <subsection id="section-1.1">
922
+ <num>(1)</num>
923
+ <content>
924
+ <p>hello</p>
925
+ </content>
926
+ </subsection>
927
+ </section>'
719
928
  end
720
929
 
721
930
  it 'should handle section numbers without a dot' do
722
931
  subject.parser.options = {section_number_after_title: false}
723
- node = parse :act, <<EOS
932
+ node = parse :body, <<EOS
724
933
  1 A section
725
934
  (1) hello
726
935
  2 Another section
727
936
  (2) Another line
728
937
  EOS
729
-
730
- section = node.chapters.elements.first.parts.elements.first.sections.elements.first
731
- section.section_title.title.should == "A section"
732
- section.section_title.num.should == "1"
733
-
734
- section = node.chapters.elements[0].parts.elements.first.sections.elements[1]
735
- section.section_title.title.should == "Another section"
736
- section.section_title.num.should == "2"
938
+ s = to_xml(node)
939
+ s.should == '<body>
940
+ <section id="section-1">
941
+ <num>1.</num>
942
+ <heading>A section</heading>
943
+ <subsection id="section-1.1">
944
+ <num>(1)</num>
945
+ <content>
946
+ <p>hello</p>
947
+ </content>
948
+ </subsection>
949
+ </section>
950
+ <section id="section-2">
951
+ <num>2.</num>
952
+ <heading>Another section</heading>
953
+ <subsection id="section-2.2">
954
+ <num>(2)</num>
955
+ <content>
956
+ <p>Another line</p>
957
+ </content>
958
+ </subsection>
959
+ </section>
960
+ </body>'
737
961
  end
738
962
 
739
963
  it 'should handle sections without titles and with subsections' do
740
964
  subject.parser.options = {section_number_after_title: false}
741
- node = parse :act, <<EOS
965
+ node = parse :section, <<EOS
742
966
  10. (1) Transporters must remove medical waste.
743
967
  (2) Without limiting generality, stuff.
744
968
  EOS
745
-
746
- section = node.chapters.elements.first.parts.elements.first.sections.elements.first
747
- section.section_title.title.should == ""
748
- section.section_title.num.should == "10"
749
- section.subsections.elements[0].statement.num.should == "(1)"
750
- section.subsections.elements[0].statement.content.text_value.should == "Transporters must remove medical waste."
969
+ s = to_xml(node)
970
+ s.should == '<section id="section-10">
971
+ <num>10.</num>
972
+ <heading/>
973
+ <subsection id="section-10.1">
974
+ <num>(1)</num>
975
+ <content>
976
+ <p>Transporters must remove medical waste.</p>
977
+ </content>
978
+ </subsection>
979
+ <subsection id="section-10.2">
980
+ <num>(2)</num>
981
+ <content>
982
+ <p>Without limiting generality, stuff.</p>
983
+ </content>
984
+ </subsection>
985
+ </section>'
751
986
  end
752
987
  end
753
988
 
@@ -762,43 +997,58 @@ Subject to approval in terms of this By-Law, the erection:
762
997
  1. Foo
763
998
  2. Bar
764
999
  EOS
765
-
766
- sched = node.schedules.elements[0]
767
- sched.schedule_heading.schedule_heading_prefix.text_value.should == "Schedule"
768
- sched.statements.elements[0].clauses.text_value.should == "Subject to approval in terms of this By-Law, the erection:"
769
- sched.statements.elements[1].clauses.text_value.should == "1. Foo"
770
- sched.statements.elements[2].clauses.text_value.should == "2. Bar"
771
- end
772
-
773
- it 'should handle many schedules' do
774
- node = parse :schedules, <<EOS
775
- Schedule "1"
776
- A Title
777
- 1. Foo
778
- 2. Bar
779
- Schedule 2
780
- Another Title
781
- Baz
782
- Boom
783
- EOS
784
-
785
- sched = node.schedules.elements[0]
786
- sched.schedule_heading.schedule_heading_prefix.text_value.should == "Schedule"
787
- sched.schedule_heading.schedule_title.content.text_value.should == "A Title"
788
- sched.schedule_heading.num.text_value.should == "1"
789
- sched.statements.elements[0].clauses.text_value.should == "1. Foo"
790
- sched.statements.elements[1].clauses.text_value.should == "2. Bar"
791
-
792
- sched = node.schedules.elements[1]
793
- sched.schedule_heading.schedule_heading_prefix.text_value.should == "Schedule"
794
- sched.schedule_heading.schedule_title.content.text_value.should == "Another Title"
795
- sched.schedule_heading.num.text_value.should == "2"
796
- sched.statements.elements[0].clauses.text_value.should == "Baz"
797
- sched.statements.elements[1].clauses.text_value.should == "Boom"
1000
+ s = to_xml(node)
1001
+ today = Time.now.strftime('%Y-%m-%d')
1002
+ s.should == '<component id="component-schedule-1">
1003
+ <doc name="schedule1">
1004
+ <meta>
1005
+ <identification source="#slaw">
1006
+ <FRBRWork>
1007
+ <FRBRthis value="/za/act/1980/01/schedule1"/>
1008
+ <FRBRuri value="/za/act/1980/01"/>
1009
+ <FRBRalias value="Schedule"/>
1010
+ <FRBRdate date="1980-01-01" name="Generation"/>
1011
+ <FRBRauthor href="#council"/>
1012
+ <FRBRcountry value="za"/>
1013
+ </FRBRWork>
1014
+ <FRBRExpression>
1015
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1016
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1017
+ <FRBRdate date="1980-01-01" name="Generation"/>
1018
+ <FRBRauthor href="#council"/>
1019
+ <FRBRlanguage language="eng"/>
1020
+ </FRBRExpression>
1021
+ <FRBRManifestation>
1022
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1023
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1024
+ <FRBRdate date="' + today + '" name="Generation"/>
1025
+ <FRBRauthor href="#slaw"/>
1026
+ </FRBRManifestation>
1027
+ </identification>
1028
+ </meta>
1029
+ <mainBody>
1030
+ <article id="schedule-1">
1031
+ <paragraph id="paragraph-0">
1032
+ <content>
1033
+ <p>Subject to approval in terms of this By-Law, the erection:</p>
1034
+ </content>
1035
+ </paragraph>
1036
+ <section id="section-1">
1037
+ <num>1.</num>
1038
+ <heading>Foo</heading>
1039
+ </section>
1040
+ <section id="section-2">
1041
+ <num>2.</num>
1042
+ <heading>Bar</heading>
1043
+ </section>
1044
+ </article>
1045
+ </mainBody>
1046
+ </doc>
1047
+ </component>'
798
1048
  end
799
1049
 
800
1050
  it 'should serialise many schedules correctly' do
801
- node = parse :schedules, <<EOS
1051
+ node = parse :schedules_container, <<EOS
802
1052
  Schedule "2"
803
1053
  A Title
804
1054
  1. Foo
@@ -813,7 +1063,7 @@ EOS
813
1063
  today = Time.now.strftime('%Y-%m-%d')
814
1064
  s.should == <<EOS
815
1065
  <components>
816
- <component id="component-1">
1066
+ <component id="component-schedule-2">
817
1067
  <doc name="schedule2">
818
1068
  <meta>
819
1069
  <identification source="#slaw">
@@ -822,36 +1072,40 @@ EOS
822
1072
  <FRBRuri value="/za/act/1980/01"/>
823
1073
  <FRBRalias value="Schedule 2"/>
824
1074
  <FRBRdate date="1980-01-01" name="Generation"/>
825
- <FRBRauthor href="#council" as="#author"/>
1075
+ <FRBRauthor href="#council"/>
826
1076
  <FRBRcountry value="za"/>
827
1077
  </FRBRWork>
828
1078
  <FRBRExpression>
829
1079
  <FRBRthis value="/za/act/1980/01/eng@/schedule2"/>
830
1080
  <FRBRuri value="/za/act/1980/01/eng@"/>
831
1081
  <FRBRdate date="1980-01-01" name="Generation"/>
832
- <FRBRauthor href="#council" as="#author"/>
1082
+ <FRBRauthor href="#council"/>
833
1083
  <FRBRlanguage language="eng"/>
834
1084
  </FRBRExpression>
835
1085
  <FRBRManifestation>
836
1086
  <FRBRthis value="/za/act/1980/01/eng@/schedule2"/>
837
1087
  <FRBRuri value="/za/act/1980/01/eng@"/>
838
1088
  <FRBRdate date="#{today}" name="Generation"/>
839
- <FRBRauthor href="#slaw" as="#author"/>
1089
+ <FRBRauthor href="#slaw"/>
840
1090
  </FRBRManifestation>
841
1091
  </identification>
842
1092
  </meta>
843
1093
  <mainBody>
844
1094
  <article id="schedule-2">
845
1095
  <heading>A Title</heading>
846
- <content>
847
- <p>1. Foo</p>
848
- <p>2. Bar</p>
849
- </content>
1096
+ <section id="section-1">
1097
+ <num>1.</num>
1098
+ <heading>Foo</heading>
1099
+ </section>
1100
+ <section id="section-2">
1101
+ <num>2.</num>
1102
+ <heading>Bar</heading>
1103
+ </section>
850
1104
  </article>
851
1105
  </mainBody>
852
1106
  </doc>
853
1107
  </component>
854
- <component id="component-2">
1108
+ <component id="component-schedule-3">
855
1109
  <doc name="schedule3">
856
1110
  <meta>
857
1111
  <identification source="#slaw">
@@ -860,31 +1114,33 @@ EOS
860
1114
  <FRBRuri value="/za/act/1980/01"/>
861
1115
  <FRBRalias value="Schedule 3"/>
862
1116
  <FRBRdate date="1980-01-01" name="Generation"/>
863
- <FRBRauthor href="#council" as="#author"/>
1117
+ <FRBRauthor href="#council"/>
864
1118
  <FRBRcountry value="za"/>
865
1119
  </FRBRWork>
866
1120
  <FRBRExpression>
867
1121
  <FRBRthis value="/za/act/1980/01/eng@/schedule3"/>
868
1122
  <FRBRuri value="/za/act/1980/01/eng@"/>
869
1123
  <FRBRdate date="1980-01-01" name="Generation"/>
870
- <FRBRauthor href="#council" as="#author"/>
1124
+ <FRBRauthor href="#council"/>
871
1125
  <FRBRlanguage language="eng"/>
872
1126
  </FRBRExpression>
873
1127
  <FRBRManifestation>
874
1128
  <FRBRthis value="/za/act/1980/01/eng@/schedule3"/>
875
1129
  <FRBRuri value="/za/act/1980/01/eng@"/>
876
1130
  <FRBRdate date="#{today}" name="Generation"/>
877
- <FRBRauthor href="#slaw" as="#author"/>
1131
+ <FRBRauthor href="#slaw"/>
878
1132
  </FRBRManifestation>
879
1133
  </identification>
880
1134
  </meta>
881
1135
  <mainBody>
882
1136
  <article id="schedule-3">
883
1137
  <heading>Another Title</heading>
884
- <content>
885
- <p>Baz</p>
886
- <p>Boom</p>
887
- </content>
1138
+ <paragraph id="paragraph-0">
1139
+ <content>
1140
+ <p>Baz</p>
1141
+ <p>Boom</p>
1142
+ </content>
1143
+ </paragraph>
888
1144
  </article>
889
1145
  </mainBody>
890
1146
  </doc>
@@ -906,51 +1162,135 @@ EOS
906
1162
  s = to_xml(node)
907
1163
  today = Time.now.strftime('%Y-%m-%d')
908
1164
  s.should == <<EOS
909
- <components>
910
- <component id="component-1">
911
- <doc name="schedule1">
912
- <meta>
913
- <identification source="#slaw">
914
- <FRBRWork>
915
- <FRBRthis value="/za/act/1980/01/schedule1"/>
916
- <FRBRuri value="/za/act/1980/01"/>
917
- <FRBRalias value="Schedule 1"/>
918
- <FRBRdate date="1980-01-01" name="Generation"/>
919
- <FRBRauthor href="#council" as="#author"/>
920
- <FRBRcountry value="za"/>
921
- </FRBRWork>
922
- <FRBRExpression>
923
- <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
924
- <FRBRuri value="/za/act/1980/01/eng@"/>
925
- <FRBRdate date="1980-01-01" name="Generation"/>
926
- <FRBRauthor href="#council" as="#author"/>
927
- <FRBRlanguage language="eng"/>
928
- </FRBRExpression>
929
- <FRBRManifestation>
930
- <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
931
- <FRBRuri value="/za/act/1980/01/eng@"/>
932
- <FRBRdate date="#{today}" name="Generation"/>
933
- <FRBRauthor href="#slaw" as="#author"/>
934
- </FRBRManifestation>
935
- </identification>
936
- </meta>
937
- <mainBody>
938
- <article id="schedule-1">
1165
+ <component id="component-schedule-1">
1166
+ <doc name="schedule1">
1167
+ <meta>
1168
+ <identification source="#slaw">
1169
+ <FRBRWork>
1170
+ <FRBRthis value="/za/act/1980/01/schedule1"/>
1171
+ <FRBRuri value="/za/act/1980/01"/>
1172
+ <FRBRalias value="Schedule 1"/>
1173
+ <FRBRdate date="1980-01-01" name="Generation"/>
1174
+ <FRBRauthor href="#council"/>
1175
+ <FRBRcountry value="za"/>
1176
+ </FRBRWork>
1177
+ <FRBRExpression>
1178
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1179
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1180
+ <FRBRdate date="1980-01-01" name="Generation"/>
1181
+ <FRBRauthor href="#council"/>
1182
+ <FRBRlanguage language="eng"/>
1183
+ </FRBRExpression>
1184
+ <FRBRManifestation>
1185
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1186
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1187
+ <FRBRdate date="#{today}" name="Generation"/>
1188
+ <FRBRauthor href="#slaw"/>
1189
+ </FRBRManifestation>
1190
+ </identification>
1191
+ </meta>
1192
+ <mainBody>
1193
+ <article id="schedule-1">
1194
+ <paragraph id="paragraph-0">
939
1195
  <content>
940
1196
  <p>Other than as is set out hereinbelow, no signs other than locality bound signs, temporary signs including loose portable sign, estate agents signs, newspaper headline posters and posters (the erection of which must comply with the appropriate schedules pertinent thereto) shall be erected on Municipal owned land.</p>
941
- <p>1. Foo</p>
942
- <p>2. Bar</p>
943
1197
  </content>
944
- </article>
945
- </mainBody>
946
- </doc>
947
- </component>
948
- </components>
1198
+ </paragraph>
1199
+ <section id="section-1">
1200
+ <num>1.</num>
1201
+ <heading>Foo</heading>
1202
+ </section>
1203
+ <section id="section-2">
1204
+ <num>2.</num>
1205
+ <heading>Bar</heading>
1206
+ </section>
1207
+ </article>
1208
+ </mainBody>
1209
+ </doc>
1210
+ </component>
1211
+ EOS
1212
+ .strip
1213
+ end
1214
+
1215
+ it 'should support rich parts, chapters and sections in a schedule' do
1216
+ node = parse :schedules, <<EOS
1217
+ Schedule 1
1218
+ Forms
1219
+
1220
+ Part I
1221
+ Form of authentication statement
1222
+
1223
+ This printed impression has been carefully compared by me with the bill which was passed by Parliament and found by me to be a true copy of the bill.
1224
+
1225
+ Part II
1226
+ Form of statement of the President’s assent.
1227
+
1228
+ I signify my assent to the bill and a whole bunch of other stuff.
1229
+ EOS
1230
+
1231
+ s = to_xml(node)
1232
+ today = Time.now.strftime('%Y-%m-%d')
1233
+ s.should == <<EOS
1234
+ <component id="component-schedule-1">
1235
+ <doc name="schedule1">
1236
+ <meta>
1237
+ <identification source="#slaw">
1238
+ <FRBRWork>
1239
+ <FRBRthis value="/za/act/1980/01/schedule1"/>
1240
+ <FRBRuri value="/za/act/1980/01"/>
1241
+ <FRBRalias value="Schedule 1"/>
1242
+ <FRBRdate date="1980-01-01" name="Generation"/>
1243
+ <FRBRauthor href="#council"/>
1244
+ <FRBRcountry value="za"/>
1245
+ </FRBRWork>
1246
+ <FRBRExpression>
1247
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1248
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1249
+ <FRBRdate date="1980-01-01" name="Generation"/>
1250
+ <FRBRauthor href="#council"/>
1251
+ <FRBRlanguage language="eng"/>
1252
+ </FRBRExpression>
1253
+ <FRBRManifestation>
1254
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1255
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1256
+ <FRBRdate date="#{today}" name="Generation"/>
1257
+ <FRBRauthor href="#slaw"/>
1258
+ </FRBRManifestation>
1259
+ </identification>
1260
+ </meta>
1261
+ <mainBody>
1262
+ <article id="schedule-1">
1263
+ <heading>Forms</heading>
1264
+ <part id="part-I">
1265
+ <num>I</num>
1266
+ <heading>Form of authentication statement</heading>
1267
+ <paragraph id="part-I.paragraph-0">
1268
+ <content>
1269
+ <p>This printed impression has been carefully compared by me with the bill which was passed by Parliament and found by me to be a true copy of the bill.</p>
1270
+ </content>
1271
+ </paragraph>
1272
+ </part>
1273
+ <part id="part-II">
1274
+ <num>II</num>
1275
+ <heading>Form of statement of the President’s assent.</heading>
1276
+ <paragraph id="part-II.paragraph-0">
1277
+ <content>
1278
+ <p>I signify my assent to the bill and a whole bunch of other stuff.</p>
1279
+ </content>
1280
+ </paragraph>
1281
+ </part>
1282
+ </article>
1283
+ </mainBody>
1284
+ </doc>
1285
+ </component>
949
1286
  EOS
950
1287
  .strip
951
1288
  end
952
1289
  end
953
1290
 
1291
+ #-------------------------------------------------------------------------------
1292
+ # tables
1293
+
954
1294
  describe 'tables' do
955
1295
  it 'should parse basic tables' do
956
1296
  node = parse :table, <<EOS
@@ -1022,44 +1362,48 @@ EOS
1022
1362
 
1023
1363
  xml = to_xml(node, "")
1024
1364
  today = Time.now.strftime('%Y-%m-%d')
1025
- xml.should == '<doc name="schedule1">
1026
- <meta>
1027
- <identification source="#slaw">
1028
- <FRBRWork>
1029
- <FRBRthis value="/za/act/1980/01/schedule1"/>
1030
- <FRBRuri value="/za/act/1980/01"/>
1031
- <FRBRalias value="Schedule 1"/>
1032
- <FRBRdate date="1980-01-01" name="Generation"/>
1033
- <FRBRauthor href="#council" as="#author"/>
1034
- <FRBRcountry value="za"/>
1035
- </FRBRWork>
1036
- <FRBRExpression>
1037
- <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1038
- <FRBRuri value="/za/act/1980/01/eng@"/>
1039
- <FRBRdate date="1980-01-01" name="Generation"/>
1040
- <FRBRauthor href="#council" as="#author"/>
1041
- <FRBRlanguage language="eng"/>
1042
- </FRBRExpression>
1043
- <FRBRManifestation>
1044
- <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1045
- <FRBRuri value="/za/act/1980/01/eng@"/>
1046
- <FRBRdate date="' + today + '" name="Generation"/>
1047
- <FRBRauthor href="#slaw" as="#author"/>
1048
- </FRBRManifestation>
1049
- </identification>
1050
- </meta>
1051
- <mainBody>
1052
- <article id="schedule-1">
1053
- <content>
1054
- <p>Heres a table:</p>
1055
- <table id="schedule-1.table0"><tr><td><p>r1c1</p></td>
1365
+ xml.should == '<component id="component-schedule-1">
1366
+ <doc name="schedule1">
1367
+ <meta>
1368
+ <identification source="#slaw">
1369
+ <FRBRWork>
1370
+ <FRBRthis value="/za/act/1980/01/schedule1"/>
1371
+ <FRBRuri value="/za/act/1980/01"/>
1372
+ <FRBRalias value="Schedule 1"/>
1373
+ <FRBRdate date="1980-01-01" name="Generation"/>
1374
+ <FRBRauthor href="#council"/>
1375
+ <FRBRcountry value="za"/>
1376
+ </FRBRWork>
1377
+ <FRBRExpression>
1378
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1379
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1380
+ <FRBRdate date="1980-01-01" name="Generation"/>
1381
+ <FRBRauthor href="#council"/>
1382
+ <FRBRlanguage language="eng"/>
1383
+ </FRBRExpression>
1384
+ <FRBRManifestation>
1385
+ <FRBRthis value="/za/act/1980/01/eng@/schedule1"/>
1386
+ <FRBRuri value="/za/act/1980/01/eng@"/>
1387
+ <FRBRdate date="' + today + '" name="Generation"/>
1388
+ <FRBRauthor href="#slaw"/>
1389
+ </FRBRManifestation>
1390
+ </identification>
1391
+ </meta>
1392
+ <mainBody>
1393
+ <article id="schedule-1">
1394
+ <paragraph id="paragraph-0">
1395
+ <content>
1396
+ <p>Heres a table:</p>
1397
+ <table id="table0"><tr><td><p>r1c1</p></td>
1056
1398
  <td><p>r1c2</p></td></tr>
1057
1399
  <tr><td><p>r2c1</p></td>
1058
1400
  <td><p>r2c2</p></td></tr></table>
1059
- </content>
1060
- </article>
1061
- </mainBody>
1062
- </doc>'
1401
+ </content>
1402
+ </paragraph>
1403
+ </article>
1404
+ </mainBody>
1405
+ </doc>
1406
+ </component>'
1063
1407
  end
1064
1408
  end
1065
1409