xmlutils 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +77 -0
- data/bin/xmltogdl +88 -0
- data/docs/README.txt +20 -0
- data/lib/xmlutils/contextlistener.rb +432 -0
- data/lib/xmlutils/contextparser.rb +111 -0
- data/lib/xmlutils/dumplistener.rb +57 -0
- data/lib/xmlutils/gdlcontext.rb +305 -0
- data/lib/xmlutils/gdlcontextobjs.rb +286 -0
- data/lib/xmlutils/gdldoc.rb +547 -0
- data/lib/xmlutils/gdldocbuilder.rb +181 -0
- data/lib/xmlutils/gdllistener.rb +265 -0
- data/lib/xmlutils/gdltemplate.rb +488 -0
- data/lib/xmlutils/lineparser.rb +193 -0
- data/lib/xmlutils/listener.rb +459 -0
- data/lib/xmlutils/rulelistener.rb +414 -0
- data/lib/xmlutils/ruleparser.rb +112 -0
- data/lib/xmlutils/varlistener.rb +86 -0
- data/lib/xmlutils/version.rb +5 -0
- data/lib/xmlutils/xmlrulevisitor.rb +704 -0
- data/lib/xmlutils/xmltogdlcontroller.rb +93 -0
- data/lib/xmlutils/xmltogdltask.rb +23 -0
- data/lib/xmlutils/xmlvisitor.rb +690 -0
- data/lib/xmlutils.rb +40 -0
- data/rakefile.rb +34 -0
- data/unittests/2830.xml +1 -0
- data/unittests/chunks.rb +31 -0
- data/unittests/curDirTest.rb +2 -0
- data/unittests/data/2830-GENERATED.gdl +309 -0
- data/unittests/data/2830-GENERATED.xml +1 -0
- data/unittests/data/AUGuideline.xml +12 -0
- data/unittests/data/AUGuideline.xml.gdl +19190 -0
- data/unittests/data/BAKUP.DCTEST1.xml +1 -0
- data/unittests/data/DCTEST.xml +1 -0
- data/unittests/data/DCTEST1.xml +1 -0
- data/unittests/data/DCTEST1.xml.gdl +14890 -0
- data/unittests/data/DCTEST1.xml.rename.csv +180 -0
- data/unittests/data/DCTEST1wLookups.xml +174 -0
- data/unittests/data/DCTEST1wLookups.xml.gdl +127 -0
- data/unittests/data/GENERATED.gdl.xml +1 -0
- data/unittests/data/Message.xml +1 -0
- data/unittests/data/Message.xml.gdl +142 -0
- data/unittests/data/Pricing2ndGuideline.xml +1 -0
- data/unittests/data/Pricing2ndGuideline.xml.gdl +52670 -0
- data/unittests/data/Z-TEMP-Jeff.xml +1 -0
- data/unittests/data/Z-TEMP-Jeff.xml.gdl +288 -0
- data/unittests/tc_convert_xml_to_gdl.rb +23 -0
- data/unittests/ts_allTests.rb +2 -0
- data/xmlutils.gemspec +25 -0
- metadata +139 -0
@@ -0,0 +1,459 @@
|
|
1
|
+
#
|
2
|
+
# File: listener.rb
|
3
|
+
#
|
4
|
+
# This class is an abstract listener base class
|
5
|
+
#
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rexml/streamlistener'
|
9
|
+
|
10
|
+
include REXML
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
#################################################
|
16
|
+
#
|
17
|
+
# class Listener
|
18
|
+
#
|
19
|
+
#################################################
|
20
|
+
class Listener
|
21
|
+
include StreamListener
|
22
|
+
|
23
|
+
attr_writer :verbose
|
24
|
+
|
25
|
+
def verbose?
|
26
|
+
@verbose
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
#-------------------------------------------------------------------------------------------------------------#
|
32
|
+
# initialize - Ctor
|
33
|
+
#
|
34
|
+
#
|
35
|
+
#------------------------------------------------------------------------------------------------------------#
|
36
|
+
def initialize()
|
37
|
+
@verbose = false
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
#-------------------------------------------------------------------------------------------------------------#
|
43
|
+
# tag_start - A start tag has been parsed
|
44
|
+
#
|
45
|
+
# tag - name of tag (element name)
|
46
|
+
# attributes - element tag attributes
|
47
|
+
#------------------------------------------------------------------------------------------------------------#
|
48
|
+
def tag_start(tag, attributes)
|
49
|
+
if ($DEBUG)
|
50
|
+
puts "tag_start: #{tag}"
|
51
|
+
|
52
|
+
if(!attributes.empty?)
|
53
|
+
puts " Attr:"
|
54
|
+
attributes.each do |attr|
|
55
|
+
puts " #{attr[0]}: #{attr[1]}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end # if $DEBUG
|
59
|
+
|
60
|
+
case tag
|
61
|
+
when 'DPM'
|
62
|
+
openDPM(attributes)
|
63
|
+
|
64
|
+
when 'PPM'
|
65
|
+
openPPM(attributes)
|
66
|
+
|
67
|
+
when 'Rule'
|
68
|
+
openRule(attributes)
|
69
|
+
|
70
|
+
when 'Ruleset'
|
71
|
+
openRuleset(attributes)
|
72
|
+
|
73
|
+
when 'Lookup'
|
74
|
+
openLookup(attributes)
|
75
|
+
|
76
|
+
when 'LOOKUPS'
|
77
|
+
openLOOKUPS(attributes)
|
78
|
+
|
79
|
+
when 'LOOKUP'
|
80
|
+
openLOOKUP(attributes)
|
81
|
+
|
82
|
+
when 'Message'
|
83
|
+
openMessage(attributes)
|
84
|
+
|
85
|
+
when 'XParameter'
|
86
|
+
openXParameter(attributes)
|
87
|
+
|
88
|
+
when 'YParameter'
|
89
|
+
openYParameter(attributes)
|
90
|
+
|
91
|
+
when 'Function'
|
92
|
+
openXmlFunction(attributes)
|
93
|
+
|
94
|
+
else
|
95
|
+
openUnknown(tag, attributes)
|
96
|
+
end # case
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
#-------------------------------------------------------------------------------------------------------------#
|
104
|
+
# tag_end - An ending tag has been parsed
|
105
|
+
#
|
106
|
+
# tag - name of tag (element name)
|
107
|
+
#------------------------------------------------------------------------------------------------------------#
|
108
|
+
def tag_end(tag)
|
109
|
+
puts "tag_end: #{tag}" unless !$DEBUG
|
110
|
+
puts "" if $DEBUG
|
111
|
+
|
112
|
+
case tag
|
113
|
+
when 'Ruleset'
|
114
|
+
closeRuleset()
|
115
|
+
|
116
|
+
when 'Lookup'
|
117
|
+
closeLookup()
|
118
|
+
|
119
|
+
when 'LOOKUPS'
|
120
|
+
closeLOOKUPS()
|
121
|
+
|
122
|
+
when 'LOOKUP'
|
123
|
+
closeLOOKUP()
|
124
|
+
|
125
|
+
when 'Message'
|
126
|
+
closeMessage()
|
127
|
+
|
128
|
+
when 'XParameter'
|
129
|
+
closeXParameter()
|
130
|
+
|
131
|
+
when 'YParameter'
|
132
|
+
closeYParameter()
|
133
|
+
|
134
|
+
when 'Function'
|
135
|
+
closeXmlFunction()
|
136
|
+
|
137
|
+
else
|
138
|
+
closeUnknown(tag)
|
139
|
+
end # case
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
#-------------------------------------------------------------------------------------------------------------#
|
147
|
+
# entity - An entity has been parsed
|
148
|
+
#
|
149
|
+
# content - entity content
|
150
|
+
#------------------------------------------------------------------------------------------------------------#
|
151
|
+
def entity(content)
|
152
|
+
puts "entity: #{content}" unless !$DEBUG
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
#-------------------------------------------------------------------------------------------------------------#
|
159
|
+
# text - A text node has been parsed
|
160
|
+
#
|
161
|
+
# txt - node text
|
162
|
+
#------------------------------------------------------------------------------------------------------------#
|
163
|
+
def text(txt)
|
164
|
+
puts "text: #{txt}" unless !$DEBUG
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
#-------------------------------------------------------------------------------------------------------------#
|
171
|
+
# cdata - A cdata node has been parsed
|
172
|
+
# Called when <![CDATA[ � ]]> is encountered in a document. @p content "�"
|
173
|
+
# txt - node text
|
174
|
+
#------------------------------------------------------------------------------------------------------------#
|
175
|
+
def cdata(txt)
|
176
|
+
puts "cdata: #{txt}" unless !$DEBUG
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
#-------------------------------------------------------------------------------------------------------------#
|
183
|
+
# openMessage - A Message element has been started
|
184
|
+
#
|
185
|
+
# attributes - Message element attributes
|
186
|
+
#
|
187
|
+
#------------------------------------------------------------------------------------------------------------#
|
188
|
+
def openMessage(attributes)
|
189
|
+
end # openMessage
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
#-------------------------------------------------------------------------------------------------------------#
|
195
|
+
# closeMessage - A Message element has been ended
|
196
|
+
#
|
197
|
+
#
|
198
|
+
#------------------------------------------------------------------------------------------------------------#
|
199
|
+
def closeMessage()
|
200
|
+
end # closeMessage
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
#-------------------------------------------------------------------------------------------------------------#
|
206
|
+
# openDPM - A DPM element has been started
|
207
|
+
#
|
208
|
+
# attributes - DPM element attributes
|
209
|
+
#
|
210
|
+
#------------------------------------------------------------------------------------------------------------#
|
211
|
+
def openDPM(attributes)
|
212
|
+
end # openDpm
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
#-------------------------------------------------------------------------------------------------------------#
|
218
|
+
# closeDPM - A DPM element has been ended
|
219
|
+
#
|
220
|
+
#
|
221
|
+
#------------------------------------------------------------------------------------------------------------#
|
222
|
+
def closeDPM()
|
223
|
+
end # closeDPM
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
#-------------------------------------------------------------------------------------------------------------#
|
229
|
+
# openPPM - A PPM element has been started
|
230
|
+
#
|
231
|
+
# attributes - PPM element attributes
|
232
|
+
#
|
233
|
+
#------------------------------------------------------------------------------------------------------------#
|
234
|
+
def openPPM(attributes)
|
235
|
+
end # openPPM
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
#-------------------------------------------------------------------------------------------------------------#
|
241
|
+
# closePPM - A PPM element has been ended
|
242
|
+
#
|
243
|
+
#
|
244
|
+
#------------------------------------------------------------------------------------------------------------#
|
245
|
+
def closePPM()
|
246
|
+
end # closePPM
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
#-------------------------------------------------------------------------------------------------------------#
|
252
|
+
# openRule - A Rule element has been started
|
253
|
+
#
|
254
|
+
# attributes - rule element attributes
|
255
|
+
#
|
256
|
+
#------------------------------------------------------------------------------------------------------------#
|
257
|
+
def openRule(attributes)
|
258
|
+
end # openRule
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
#-------------------------------------------------------------------------------------------------------------#
|
264
|
+
# closeRule - A Rule element has been ended
|
265
|
+
#
|
266
|
+
#
|
267
|
+
#------------------------------------------------------------------------------------------------------------#
|
268
|
+
def closeRule()
|
269
|
+
end # closeRule
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
#-------------------------------------------------------------------------------------------------------------#
|
275
|
+
# openRuleset - A Ruleset element has been started
|
276
|
+
#
|
277
|
+
# attributes - ruleset element attributes
|
278
|
+
#
|
279
|
+
#------------------------------------------------------------------------------------------------------------#
|
280
|
+
def openRuleset(attributes)
|
281
|
+
end # openRuleset
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
#-------------------------------------------------------------------------------------------------------------#
|
287
|
+
# closeRuleset - A Ruleset element has been ended
|
288
|
+
#
|
289
|
+
#
|
290
|
+
#------------------------------------------------------------------------------------------------------------#
|
291
|
+
def closeRuleset()
|
292
|
+
end # closeRuleset
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
#-------------------------------------------------------------------------------------------------------------#
|
298
|
+
# openLookup - A Lookup element has been started
|
299
|
+
#
|
300
|
+
# attributes - Lookup element attributes
|
301
|
+
#
|
302
|
+
#------------------------------------------------------------------------------------------------------------#
|
303
|
+
def openLookup(attributes)
|
304
|
+
end # openLookup
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
#-------------------------------------------------------------------------------------------------------------#
|
310
|
+
# closeLookup - A Lookup element has been ended
|
311
|
+
#
|
312
|
+
#
|
313
|
+
#------------------------------------------------------------------------------------------------------------#
|
314
|
+
def closeLookup()
|
315
|
+
end # closeLookup
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
#-------------------------------------------------------------------------------------------------------------#
|
321
|
+
# openLOOKUPS - A LOOKUPS element has been started
|
322
|
+
#
|
323
|
+
# attributes - LOOKUPS element attributes
|
324
|
+
#
|
325
|
+
#------------------------------------------------------------------------------------------------------------#
|
326
|
+
def openLOOKUPS(attributes)
|
327
|
+
end # openLOOKUPS
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
#-------------------------------------------------------------------------------------------------------------#
|
333
|
+
# closeLOOKUPS - A LOOKUPS element has been ended
|
334
|
+
#
|
335
|
+
#
|
336
|
+
#------------------------------------------------------------------------------------------------------------#
|
337
|
+
def closeLOOKUPS()
|
338
|
+
end # closeUnknown
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
#-------------------------------------------------------------------------------------------------------------#
|
344
|
+
# openLOOKUP - A LOOKUP element has been started
|
345
|
+
#
|
346
|
+
# attributes - LOOKUP element attributes
|
347
|
+
#
|
348
|
+
#------------------------------------------------------------------------------------------------------------#
|
349
|
+
def openLOOKUP(attributes)
|
350
|
+
end # openLOOKUP
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
#-------------------------------------------------------------------------------------------------------------#
|
356
|
+
# closeLOOKUP - A LOOKUP element has been ended
|
357
|
+
#
|
358
|
+
#
|
359
|
+
#------------------------------------------------------------------------------------------------------------#
|
360
|
+
def closeLOOKUP()
|
361
|
+
end # closeUnknown
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
#-------------------------------------------------------------------------------------------------------------#
|
367
|
+
# openXParameter - A XParameter element has been started
|
368
|
+
#
|
369
|
+
# attributes - XParameter element attributes
|
370
|
+
#
|
371
|
+
#------------------------------------------------------------------------------------------------------------#
|
372
|
+
def openXParameter(attributes)
|
373
|
+
end # openXParameter
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
#-------------------------------------------------------------------------------------------------------------#
|
379
|
+
# closeXParameter - A XParameter element has been ended
|
380
|
+
#
|
381
|
+
#
|
382
|
+
#------------------------------------------------------------------------------------------------------------#
|
383
|
+
def closeXParameter()
|
384
|
+
end # closeUnknown
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
#-------------------------------------------------------------------------------------------------------------#
|
390
|
+
# openYParameter - A YParameter element has been started
|
391
|
+
#
|
392
|
+
# attributes - YParameter element attributes
|
393
|
+
#
|
394
|
+
#------------------------------------------------------------------------------------------------------------#
|
395
|
+
def openYParameter(attributes)
|
396
|
+
end # openYParameter
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
#-------------------------------------------------------------------------------------------------------------#
|
402
|
+
# closeYParameter - A YParameter element has been ended
|
403
|
+
#
|
404
|
+
#
|
405
|
+
#------------------------------------------------------------------------------------------------------------#
|
406
|
+
def closeYParameter()
|
407
|
+
end # closeYParameter
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
#-------------------------------------------------------------------------------------------------------------#
|
413
|
+
# openXmlFunction - A XmlFunction element has been started
|
414
|
+
#
|
415
|
+
# attributes - XmlFunction element attributes
|
416
|
+
#
|
417
|
+
#------------------------------------------------------------------------------------------------------------#
|
418
|
+
def openXmlFunction(attributes)
|
419
|
+
end # openXmlFunction
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
#-------------------------------------------------------------------------------------------------------------#
|
425
|
+
# closeXmlFunction - A XmlFunction element has been ended
|
426
|
+
#
|
427
|
+
#
|
428
|
+
#------------------------------------------------------------------------------------------------------------#
|
429
|
+
def closeXmlFunction()
|
430
|
+
end # closeXmlFunction
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
#-------------------------------------------------------------------------------------------------------------#
|
436
|
+
# openUnknown - A Unknown element has been started
|
437
|
+
#
|
438
|
+
# tag - Tag name of unknown element
|
439
|
+
# attributes - Unknown element attributes
|
440
|
+
#
|
441
|
+
#------------------------------------------------------------------------------------------------------------#
|
442
|
+
def openUnknown(tag, attributes)
|
443
|
+
puts "opening unknown tag: #{tag}" unless !$DEBUG
|
444
|
+
end # openUnknown
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
#-------------------------------------------------------------------------------------------------------------#
|
450
|
+
# closeUnknown - A Unknown element has been ended
|
451
|
+
#
|
452
|
+
# tag - Tag name of unknown element
|
453
|
+
#
|
454
|
+
#------------------------------------------------------------------------------------------------------------#
|
455
|
+
def closeUnknown(tag)
|
456
|
+
puts "closing unknown tag: #{tag}" unless !$DEBUG
|
457
|
+
end # closeUnknown
|
458
|
+
end # class Listener
|
459
|
+
|