1 # $Id: element.rb,v 1.5 2012/01/21 07:46:50 machan Exp $
2
3 require 'tmdoc/tmstd'
4 require 'tmdoc/tmstd/xml'
5 require 'tmdoc/tmstd/docbook/abstraction'
6
7
8 module TmStd
9
10 module DocBook
11
12 module Node
13
14 module Book
15
16 class Element < Abstraction::Division
17 def initialize(common_attrs = {}, &block)
18 Assertion.kind_of common_attrs, Hash
19
20 super Contents, Content, common_attrs, &block
21 end
22
23
24 def to_xml(opts = {})
25 Assertion.kind_of opts, Hash
26
27 xml_elem = super :book, opts
28
29 Assertion.kind_of xml_elem, Xml::Element
30 end
31 end
32
33 end
34
35
36
37 module BookInfo
38
39 class Element < Abstraction::Info
40 def initialize(common_attrs = {}, &block)
41 Assertion.kind_of common_attrs, Hash
42
43 super Contents, Content, common_attrs, &block
44 end
45
46
47 def to_xml
48 xml_elem = super :bookinfo
49
50 Assertion.kind_of xml_elem, Xml::Element
51 end
52 end
53
54 end
55
56
57
58 module Chapter
59
60 class Element < Abstraction::Division
61 def initialize(common_attrs = {}, &block)
62 Assertion.kind_of common_attrs, Hash
63
64 super Contents, Content, common_attrs, &block
65 end
66
67
68 def to_xml(opts = {})
69 Assertion.kind_of opts, Hash
70
71 xml_elem = super :chapter, opts
72
73 Assertion.kind_of xml_elem, Xml::Element
74 end
75 end
76
77 end
78
79
80
81 module ChapterInfo
82
83 class Element < Abstraction::Info
84 def initialize(common_attrs = {}, &block)
85 Assertion.kind_of common_attrs, Hash
86
87 super Contents, Content, common_attrs, &block
88 end
89
90
91 def to_xml
92 xml_elem = super :chapterinfo
93
94 Assertion.kind_of xml_elem, Xml::Element
95 end
96 end
97
98 end
99
100
101
102 module Section
103
104 class Element < Abstraction::Division
105 def initialize(common_attrs = {}, &block)
106 Assertion.kind_of common_attrs, Hash
107
108 super Contents, Content, common_attrs, &block
109 end
110
111
112 def to_xml(opts = {})
113 Assertion.kind_of opts, Hash
114
115 xml_elem = super :section, opts
116
117 Assertion.kind_of xml_elem, Xml::Element
118 end
119 end
120
121 end
122
123
124
125 module SectionInfo
126
127 class Element < Abstraction::Info
128 def initialize(common_attrs = {}, &block)
129 Assertion.kind_of common_attrs, Hash
130
131 super Contents, Content, common_attrs, &block
132 end
133
134
135 def to_xml
136 xml_elem = super :sectioninfo
137
138 Assertion.kind_of xml_elem, Xml::Element
139 end
140 end
141
142 end
143
144
145
146 module IndexTerm
147
148 class Element < Abstraction::NodeElement
149 def initialize(common_attrs = {}, &block)
150 Assertion.kind_of common_attrs, Hash
151
152 super Contents, Content, common_attrs, &block
153 end
154
155
156 def to_xml
157 xml_elem = super :indexterm
158
159 Assertion.kind_of xml_elem, Xml::Element
160 end
161 end
162
163 end
164
165
166
167 module Para
168
169 class Element < Abstraction::NodeElement
170 def initialize(common_attrs = {}, &block)
171 Assertion.kind_of common_attrs, Hash
172
173 super Contents, Content, common_attrs, &block
174 end
175
176
177 def to_xml
178 xml_elem = super :para
179
180 Assertion.kind_of xml_elem, Xml::Element
181 end
182 end
183
184 end
185
186
187
188 module ProgramListing
189
190 class Element < Abstraction::NodeElement
191 def initialize(common_attrs = {}, &block)
192 Assertion.kind_of common_attrs, Hash
193
194 super Contents, Content, common_attrs, &block
195 end
196
197
198 def to_xml
199 xml_elem = super :programlisting, {}, :in_verbatim => true
200
201 Assertion.kind_of xml_elem, Xml::Element
202 end
203 end
204
205 end
206
207
208
209 module ItemizedList
210
211 class Element < Abstraction::List
212 def initialize(common_attrs = {}, &block)
213 Assertion.kind_of common_attrs, Hash
214
215 super Contents, Content, common_attrs, &block
216 end
217
218
219 def to_xml
220 xml_elem = super :itemizedlist
221
222 Assertion.kind_of xml_elem, Xml::Element
223 end
224 end
225
226 end
227
228
229
230 module ListItem
231
232 class Element < Abstraction::NodeElement
233 def initialize(common_attrs = {}, &block)
234 Assertion.kind_of common_attrs, Hash
235
236 super Contents, Content, common_attrs, &block
237 end
238
239
240 def to_xml
241 xml_elem = super :listitem
242
243 Assertion.kind_of xml_elem, Xml::Element
244 end
245 end
246
247 end
248
249
250
251 module SimpleList
252
253 class Element < Abstraction::List
254 attr_reader :attr_type
255
256
257 def initialize(attrs = {}, &block)
258 Assertion.kind_of attrs, Hash
259
260 @attr_type = nil
261 common_attrs = parse_attributes(
262 attrs, :type => [ String, lambda { |val| @attr_type = val } ]
263 )
264
265 super Contents, Content, common_attrs, &block
266 end
267
268
269 def to_xml
270 attrs = attributes :type => @attr_type
271
272 xml_elem = super :simplelist, attrs, :in_verbatim => true
273
274 Assertion.kind_of xml_elem, Xml::Element
275 end
276 end
277
278 end
279
280
281
282 module Member
283
284 class Element < Abstraction::NodeElement
285 def initialize(common_attrs = {}, &block)
286 Assertion.kind_of common_attrs, Hash
287
288 super Contents, Content, common_attrs, &block
289 end
290
291
292 def to_xml
293 xml_elem = super :member
294
295 Assertion.kind_of xml_elem, Xml::Element
296 end
297 end
298
299 end
300
301
302
303 module VariableList
304
305 class Element < Abstraction::List
306 def initialize(common_attrs = {}, &block)
307 Assertion.kind_of common_attrs, Hash
308
309 super Contents, Content, common_attrs, &block
310 end
311
312
313 def to_xml
314 xml_elem = super :variablelist
315
316 Assertion.kind_of xml_elem, Xml::Element
317 end
318 end
319
320 end
321
322
323
324 module VarListEntry
325
326 class Element < Abstraction::NodeElement
327 def initialize(common_attrs = {}, &block)
328 Assertion.kind_of common_attrs, Hash
329
330 super Contents, Content, common_attrs, &block
331 end
332
333
334 def to_xml
335 xml_elem = super :varlistentry
336
337 Assertion.kind_of xml_elem, Xml::Element
338 end
339 end
340
341 end
342
343
344
345 module Term
346
347 class Element < Abstraction::NodeElement
348 def initialize(common_attrs = {}, &block)
349 Assertion.kind_of common_attrs, Hash
350
351 super Contents, Content, common_attrs, &block
352 end
353
354
355 def to_xml
356 xml_elem = super :term
357
358 Assertion.kind_of xml_elem, Xml::Element
359 end
360 end
361
362 end
363
364
365
366 module InformalTable
367
368 class Element < Abstraction::NodeElement
369 attr_reader :attr_frame, :attr_colsep, :attr_rowsep
370
371
372 def initialize(attrs = {}, &block)
373 Assertion.kind_of attrs, Hash
374
375 @attr_frame = @attr_colsep = @attr_rowsep = nil
376 common_attrs = parse_attributes(attrs,
377 :frame => [
378 String, lambda { |val| @attr_frame = val }
379 ],
380 :colsep => [
381 Integer, lambda { |val| @attr_colsep = val.to_s }
382 ],
383 :rowsep => [
384 Integer, lambda { |val| @attr_rowsep = val.to_s }
385 ]
386 )
387
388 super Contents, Content, common_attrs, &block
389 end
390
391
392 def to_xml
393 attrs = attributes(
394 :frame => @attr_frame,
395 :colsep => @attr_colsep,
396 :rowsep => @attr_rowsep
397 )
398
399 xml_elem = super :informaltable, attrs
400
401 Assertion.kind_of xml_elem, Xml::Element
402 end
403 end
404
405 end
406
407
408
409 module TGroup
410
411 class Element < Abstraction::Row
412 attr_reader :attr_cols
413
414
415 def initialize(attrs = {}, &block)
416 Assertion.kind_of attrs, Hash
417
418 @attr_cols = nil
419 common_attrs = parse_attributes(
420 attrs,
421 :cols => [ Integer, lambda { |val| @attr_cols = val.to_s } ]
422 )
423
424 super Contents, Content, common_attrs, &block
425 end
426
427
428 def to_xml
429 attrs = attributes :cols => @attr_cols
430
431 xml_elem = super :tgroup, attrs
432
433 Assertion.kind_of xml_elem, Xml::Element
434 end
435 end
436
437 end
438
439
440
441 module TBody
442
443 class Element < Abstraction::List
444 def initialize(common_attrs = {}, &block)
445 Assertion.kind_of common_attrs, Hash
446
447 super Contents, Content, common_attrs, &block
448 end
449
450
451 def to_xml
452 xml_elem = super :tbody
453
454 Assertion.kind_of xml_elem, Xml::Element
455 end
456 end
457
458 end
459
460
461
462 module Row
463
464 class Element < Abstraction::Row
465 def initialize(common_attrs = {}, &block)
466 Assertion.kind_of common_attrs, Hash
467
468 super Contents, Content, common_attrs, &block
469 end
470
471
472 def to_xml
473 xml_elem = super :row
474
475 Assertion.kind_of xml_elem, Xml::Element
476 end
477 end
478
479 end
480
481
482
483 module Entry
484
485 class Element < Abstraction::Entry
486 attr_reader :attr_valign
487
488
489 def initialize(attrs = {}, &block)
490 Assertion.kind_of attrs, Hash
491
492 @attr_valign = nil
493 common_attrs = parse_attributes(attrs,
494 :valign => [String, lambda { |val| @attr_valign = val } ]
495 )
496
497 super Contents, Content, common_attrs, &block
498 end
499
500
501 def to_xml
502 attrs = attributes :valign => @attr_valign
503
504 xml_elem = super :entry, attrs
505
506 Assertion.kind_of xml_elem, Xml::Element
507 end
508 end
509
510 end
511
512
513
514 module EntryTbl
515
516 class Element < Abstraction::Entry
517 attr_reader :attr_cols
518
519
520 def initialize(attrs = {}, &block)
521 Assertion.kind_of attrs, Hash
522
523 @attr_cols = nil
524 common_attrs = parse_attributes(
525 attrs,
526 :cols => [ Integer, lambda { |val| @attr_cols = val.to_s } ]
527 )
528
529 super Contents, Content, common_attrs, &block
530 end
531
532
533 def to_xml
534 attrs = attributes :cols => @attr_cols
535
536 xml_elem = super :entrytbl, attrs
537
538 Assertion.kind_of xml_elem, Xml::Element
539 end
540 end
541
542 end
543
544
545
546 module Link
547
548 class Element < Abstraction::NodeElement
549 attr_reader :attr_link_id
550
551
552 def initialize(attrs = {}, &block)
553 Assertion.kind_of attrs, Hash
554
555 @attr_link_id = nil
556 common_attrs = parse_attributes(
557 attrs,
558 :linkend => [ String, lambda { |val| @attr_link_id = val } ]
559 )
560
561 super Contents, Content, common_attrs, &block
562
563 end
564
565
566 def to_xml
567 attrs = attributes :linkend => @attr_link_id
568
569 xml_elem = super :link, attrs, :in_verbatim => true
570
571 Assertion.kind_of xml_elem, Xml::Element
572 end
573 end
574
575 end
576
577 end # TmStd::DocBook::Node
578
579 end # TmStd::DocBook
580
581 end # TmStd