rgen 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/CHANGELOG +28 -0
  2. data/Rakefile +3 -4
  3. data/lib/ea_support/uml13_ea_metamodel.rb +3 -3
  4. data/lib/ea_support/uml13_ea_to_uml13.rb +33 -2
  5. data/lib/ea_support/uml13_to_uml13_ea.rb +7 -0
  6. data/lib/mmgen/mm_ext/ecore_mmgen_ext.rb +4 -4
  7. data/lib/mmgen/templates/metamodel_generator.tpl +143 -143
  8. data/lib/rgen/ecore/ecore.rb +11 -1
  9. data/lib/rgen/ecore/ecore_interface.rb +47 -0
  10. data/lib/rgen/ecore/ecore_to_ruby.rb +166 -0
  11. data/lib/rgen/ecore/{ecore_transformer.rb → ruby_to_ecore.rb} +11 -11
  12. data/lib/rgen/environment.rb +15 -2
  13. data/lib/rgen/fragment/dump_file_cache.rb +63 -0
  14. data/lib/rgen/fragment/fragmented_model.rb +139 -0
  15. data/lib/rgen/fragment/model_fragment.rb +268 -0
  16. data/lib/rgen/instantiator/abstract_xml_instantiator.rb +44 -72
  17. data/lib/rgen/instantiator/default_xml_instantiator.rb +2 -2
  18. data/lib/rgen/instantiator/ecore_xml_instantiator.rb +16 -1
  19. data/lib/rgen/instantiator/json_instantiator.rb +16 -2
  20. data/lib/rgen/instantiator/nodebased_xml_instantiator.rb +118 -138
  21. data/lib/rgen/instantiator/qualified_name_resolver.rb +5 -1
  22. data/lib/rgen/instantiator/reference_resolver.rb +126 -24
  23. data/lib/rgen/instantiator/xmi11_instantiator.rb +6 -2
  24. data/lib/rgen/metamodel_builder.rb +18 -6
  25. data/lib/rgen/metamodel_builder/builder_extensions.rb +431 -407
  26. data/lib/rgen/metamodel_builder/builder_runtime.rb +8 -8
  27. data/lib/rgen/metamodel_builder/constant_order_helper.rb +4 -4
  28. data/lib/rgen/metamodel_builder/data_types.rb +5 -1
  29. data/lib/rgen/metamodel_builder/intermediate/feature.rb +167 -0
  30. data/lib/rgen/metamodel_builder/module_extension.rb +2 -2
  31. data/lib/rgen/model_builder.rb +10 -5
  32. data/lib/rgen/model_builder/builder_context.rb +17 -1
  33. data/lib/rgen/serializer/opposite_reference_filter.rb +18 -0
  34. data/lib/rgen/serializer/qualified_name_provider.rb +45 -0
  35. data/lib/rgen/template_language/template_container.rb +3 -1
  36. data/lib/rgen/{auto_class_creator.rb → util/auto_class_creator.rb} +6 -1
  37. data/lib/rgen/util/cached_glob.rb +67 -0
  38. data/lib/rgen/util/file_cache_map.rb +104 -0
  39. data/lib/rgen/util/file_change_detector.rb +78 -0
  40. data/lib/rgen/{method_delegation.rb → util/method_delegation.rb} +18 -3
  41. data/lib/rgen/{model_comparator.rb → util/model_comparator.rb} +17 -5
  42. data/lib/rgen/{model_comparator_base.rb → util/model_comparator_base.rb} +6 -1
  43. data/lib/rgen/{model_dumper.rb → util/model_dumper.rb} +6 -1
  44. data/lib/rgen/{name_helper.rb → util/name_helper.rb} +6 -1
  45. data/lib/rgen/util/pattern_matcher.rb +329 -0
  46. data/lib/transformers/uml13_to_ecore.rb +103 -60
  47. data/test/ecore_self_test.rb +43 -42
  48. data/test/json_test.rb +15 -0
  49. data/test/metamodel_builder_test.rb +361 -206
  50. data/test/metamodel_from_ecore_test.rb +45 -0
  51. data/test/metamodel_order_test.rb +10 -4
  52. data/test/metamodel_roundtrip_test.rb +2 -2
  53. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +1 -1
  54. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +50 -50
  55. data/test/method_delegation_test.rb +9 -9
  56. data/test/model_builder/ecore_internal.rb +19 -9
  57. data/test/model_builder/serializer_test.rb +1 -1
  58. data/test/reference_resolver_test.rb +79 -12
  59. data/test/rgen_test.rb +2 -0
  60. data/test/template_language_test.rb +7 -0
  61. data/test/template_language_test/templates/callback_indent_test/a.tpl +12 -0
  62. data/test/template_language_test/templates/callback_indent_test/b.tpl +5 -0
  63. data/test/testmodel/ea_testmodel_regenerated.xml +588 -583
  64. data/test/transformer_test.rb +3 -3
  65. data/test/util/file_cache_map_test.rb +91 -0
  66. data/test/util/file_cache_map_test/testdir/fileA +1 -0
  67. data/test/util_test.rb +4 -0
  68. data/test/xml_instantiator_test.rb +139 -135
  69. metadata +49 -104
  70. data/lib/rgen/ecore/ecore_instantiator.rb +0 -31
  71. data/lib/rgen/metamodel_builder/metamodel_description.rb +0 -232
  72. data/redist/xmlscan/ChangeLog +0 -1301
  73. data/redist/xmlscan/README +0 -34
  74. data/redist/xmlscan/THANKS +0 -11
  75. data/redist/xmlscan/doc/changes.html +0 -74
  76. data/redist/xmlscan/doc/changes.rd +0 -80
  77. data/redist/xmlscan/doc/en/conformance.html +0 -136
  78. data/redist/xmlscan/doc/en/conformance.rd +0 -152
  79. data/redist/xmlscan/doc/en/manual.html +0 -356
  80. data/redist/xmlscan/doc/en/manual.rd +0 -402
  81. data/redist/xmlscan/doc/ja/conformance.ja.html +0 -118
  82. data/redist/xmlscan/doc/ja/conformance.ja.rd +0 -134
  83. data/redist/xmlscan/doc/ja/manual.ja.html +0 -325
  84. data/redist/xmlscan/doc/ja/manual.ja.rd +0 -370
  85. data/redist/xmlscan/doc/src/Makefile +0 -41
  86. data/redist/xmlscan/doc/src/conformance.rd.src +0 -256
  87. data/redist/xmlscan/doc/src/langsplit.rb +0 -110
  88. data/redist/xmlscan/doc/src/manual.rd.src +0 -614
  89. data/redist/xmlscan/install.rb +0 -41
  90. data/redist/xmlscan/lib/xmlscan/encoding.rb +0 -311
  91. data/redist/xmlscan/lib/xmlscan/htmlscan.rb +0 -289
  92. data/redist/xmlscan/lib/xmlscan/namespace.rb +0 -352
  93. data/redist/xmlscan/lib/xmlscan/parser.rb +0 -299
  94. data/redist/xmlscan/lib/xmlscan/scanner.rb +0 -1109
  95. data/redist/xmlscan/lib/xmlscan/version.rb +0 -22
  96. data/redist/xmlscan/lib/xmlscan/visitor.rb +0 -158
  97. data/redist/xmlscan/lib/xmlscan/xmlchar.rb +0 -441
  98. data/redist/xmlscan/memo/CONFORMANCE +0 -1249
  99. data/redist/xmlscan/memo/PRODUCTIONS +0 -195
  100. data/redist/xmlscan/memo/contentspec.ry +0 -335
  101. data/redist/xmlscan/samples/chibixml.rb +0 -105
  102. data/redist/xmlscan/samples/getxmlchar.rb +0 -122
  103. data/redist/xmlscan/samples/rexml.rb +0 -159
  104. data/redist/xmlscan/samples/xmlbench.rb +0 -88
  105. data/redist/xmlscan/samples/xmlbench/parser/chibixml.rb +0 -22
  106. data/redist/xmlscan/samples/xmlbench/parser/nqxml.rb +0 -29
  107. data/redist/xmlscan/samples/xmlbench/parser/rexml.rb +0 -62
  108. data/redist/xmlscan/samples/xmlbench/parser/xmlparser.rb +0 -22
  109. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-0.0.10.rb +0 -62
  110. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb +0 -22
  111. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb +0 -22
  112. data/redist/xmlscan/samples/xmlbench/parser/xmlscan.rb +0 -99
  113. data/redist/xmlscan/samples/xmlbench/xmlbench-lib.rb +0 -116
  114. data/redist/xmlscan/samples/xmlconftest.rb +0 -200
  115. data/redist/xmlscan/test.rb +0 -7
  116. data/redist/xmlscan/tests/deftestcase.rb +0 -73
  117. data/redist/xmlscan/tests/runtest.rb +0 -47
  118. data/redist/xmlscan/tests/testall.rb +0 -14
  119. data/redist/xmlscan/tests/testencoding.rb +0 -438
  120. data/redist/xmlscan/tests/testhtmlscan.rb +0 -752
  121. data/redist/xmlscan/tests/testnamespace.rb +0 -457
  122. data/redist/xmlscan/tests/testparser.rb +0 -591
  123. data/redist/xmlscan/tests/testscanner.rb +0 -1749
  124. data/redist/xmlscan/tests/testxmlchar.rb +0 -143
  125. data/redist/xmlscan/tests/visitor.rb +0 -34
@@ -1,457 +0,0 @@
1
- #
2
- # tests/namespace.rb
3
- #
4
- # Copyright (C) UENO Katsuhiro 2002
5
- #
6
- # $Id: testnamespace.rb,v 1.10 2003/02/28 12:31:07 katsu Exp $
7
- #
8
-
9
- require 'test/unit'
10
- require 'deftestcase'
11
- require 'xmlscan/namespace'
12
- require 'visitor'
13
-
14
-
15
- class TestXMLNamespace < Test::Unit::TestCase
16
-
17
- include DefTestCase
18
-
19
- class Visitor < RecordingVisitor.new_class(XMLScan::NSVisitor)
20
-
21
- def on_stag_end_ns(qname, ns)
22
- super qname, ns.dup
23
- end
24
-
25
- def on_stag_end_empty_ns(qname, ns)
26
- super qname, ns.dup
27
- end
28
-
29
- end
30
-
31
-
32
- private
33
-
34
- def setup
35
- @v = Visitor.new
36
- @s = XMLScan::XMLParserNS.new(@v)
37
- end
38
-
39
- def parse(src)
40
- @s.parse src
41
- @v.result
42
- end
43
-
44
-
45
-
46
- NS_XML = 'http://www.w3.org/XML/1998/namespace'
47
- NS_XMLNS = 'http://www.w3.org/2000/xmlns/'
48
-
49
-
50
- public
51
-
52
- deftestcase 'default', <<-'TESTCASEEND'
53
-
54
- '<hoge xmlns="fuga"></hoge>'
55
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
56
- [ :on_stag_end_ns, 'hoge', {''=>'fuga'} ]
57
- [ :on_etag, 'hoge' ]
58
-
59
- '<hoge xmlns="fuga"/>'
60
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
61
- [ :on_stag_end_empty_ns, 'hoge', {''=>'fuga'} ]
62
-
63
- '<hoge></hoge>'
64
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
65
- [ :on_stag_end_ns, 'hoge', {} ]
66
- [ :on_etag, 'hoge' ]
67
-
68
- '<hoge/>'
69
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
70
- [ :on_stag_end_empty_ns, 'hoge', {} ]
71
-
72
- '<hoge xmlns="fuga" foo="bar"/>'
73
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
74
- [ :on_attribute_ns, 'foo', nil, 'foo' ]
75
- [ :on_attr_value, 'bar' ]
76
- [ :on_attribute_end, 'foo' ]
77
- [ :on_stag_end_empty_ns, 'hoge', {''=>'fuga'} ]
78
-
79
- '<hoge foo="bar" xmlns="fuga"/>'
80
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
81
- [ :on_attribute_ns, 'foo', nil, 'foo' ]
82
- [ :on_attr_value, 'bar' ]
83
- [ :on_attribute_end, 'foo' ]
84
- [ :on_stag_end_empty_ns, 'hoge', {''=>'fuga'} ]
85
-
86
- '<hoge xmlns="fu&#103;a"/>'
87
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
88
- [ :on_stag_end_empty_ns, 'hoge', {''=>'fuga'} ]
89
-
90
- '<hoge xmlns="fu&#x67;a"/>'
91
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
92
- [ :on_stag_end_empty_ns, 'hoge', {''=>'fuga'} ]
93
-
94
- '<hoge xmlns="fu&foo;a"/>'
95
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
96
- [ :ns_wellformed_error, "xmlns includes undeclared entity reference" ]
97
- [ :on_stag_end_empty_ns, 'hoge', {''=>'fua'} ]
98
-
99
- '<hoge xmlns="foo"><fuga/></hoge>'
100
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
101
- [ :on_stag_end_ns, 'hoge', {''=>'foo'} ]
102
- [ :on_stag_ns, 'fuga', '', 'fuga' ]
103
- [ :on_stag_end_empty_ns, 'fuga', {''=>'foo'} ]
104
- [ :on_etag, 'hoge' ]
105
-
106
- '<hoge xmlns="foo"><fuga xmlns="bar"/><moga/></hoge>'
107
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
108
- [ :on_stag_end_ns, 'hoge', {''=>'foo'} ]
109
- [ :on_stag_ns, 'fuga', '', 'fuga' ]
110
- [ :on_stag_end_empty_ns, 'fuga', {''=>'bar'} ]
111
- [ :on_stag_ns, 'moga', '', 'moga' ]
112
- [ :on_stag_end_empty_ns, 'moga', {''=>'foo'} ]
113
- [ :on_etag, 'hoge' ]
114
-
115
- '<hoge xmlns="foo"><fuga xmlns=""><moga/></fuga></hoge>'
116
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
117
- [ :on_stag_end_ns, 'hoge', {''=>'foo'} ]
118
- [ :on_stag_ns, 'fuga', '', 'fuga' ]
119
- [ :on_stag_end_ns, 'fuga', {''=>nil} ]
120
- [ :on_stag_ns, 'moga', '', 'moga' ]
121
- [ :on_stag_end_empty_ns, 'moga', {''=>nil} ]
122
- [ :on_etag, 'fuga' ]
123
- [ :on_etag, 'hoge' ]
124
-
125
- TESTCASEEND
126
-
127
-
128
-
129
- deftestcase 'prefix', <<-'TESTCASEEND'
130
-
131
- '<foo:hoge xmlns:foo="fuga"></foo:hoge>'
132
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
133
- [ :on_stag_end_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
134
- [ :on_etag, 'foo:hoge' ]
135
-
136
- '<foo:hoge xmlns:foo="fuga"/>'
137
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
138
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
139
-
140
- '<foo:hoge></foo:hoge>'
141
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
142
- [ :ns_wellformed_error, "prefix `foo' is not declared" ]
143
- [ :on_stag_end_ns, 'foo:hoge', {} ]
144
- [ :on_etag, 'foo:hoge' ]
145
-
146
- '<foo:hoge/>'
147
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
148
- [ :ns_wellformed_error, "prefix `foo' is not declared" ]
149
- [ :on_stag_end_empty_ns, 'foo:hoge', {} ]
150
-
151
- '<foo:hoge:fuga/>'
152
- [ :ns_parse_error, "localpart `hoge:fuga' includes `:'" ]
153
- [ :on_stag_ns, 'foo:hoge:fuga', 'foo', 'hoge:fuga' ]
154
- [ :ns_wellformed_error, "prefix `foo' is not declared" ]
155
- [ :on_stag_end_empty_ns, 'foo:hoge:fuga', {} ]
156
-
157
- '<foo:hoge xmlns:foo="fuga" foo="bar"/>'
158
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
159
- [ :on_attribute_ns, 'foo', nil, 'foo' ]
160
- [ :on_attr_value, 'bar' ]
161
- [ :on_attribute_end, 'foo' ]
162
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
163
-
164
- '<foo:hoge foo="bar" xmlns:foo="fuga"/>'
165
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
166
- [ :on_attribute_ns, 'foo', nil, 'foo' ]
167
- [ :on_attr_value, 'bar' ]
168
- [ :on_attribute_end, 'foo' ]
169
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
170
-
171
- '<bar:hoge xmlns:foo="fuga"/>'
172
- [ :on_stag_ns, 'bar:hoge', 'bar', 'hoge' ]
173
- [ :ns_wellformed_error, "prefix `bar' is not declared" ]
174
- [ :on_stag_end_empty_ns, 'bar:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
175
-
176
- '<foo:hoge xmlns:foo=""/>'
177
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
178
- [ :ns_parse_error, "`foo' is bound to empty namespace name" ]
179
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>''} ]
180
-
181
- '<foo:hoge xmlns:foo="fu&#103;a"/>'
182
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
183
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
184
-
185
- '<foo:hoge xmlns:foo="fu&#x67;a"/>'
186
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
187
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fuga'} ]
188
-
189
- '<foo:hoge xmlns:foo="fu&foo;a"/>'
190
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
191
- [ :ns_wellformed_error, "xmlns includes undeclared entity reference" ]
192
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'fua'} ]
193
-
194
- '<foo:hoge xmlns:foo="foo"><foo:fuga/></foo:hoge>'
195
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
196
- [ :on_stag_end_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo'} ]
197
- [ :on_stag_ns, 'foo:fuga', 'foo', 'fuga' ]
198
- [ :on_stag_end_empty_ns, 'foo:fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'foo'} ]
199
- [ :on_etag, 'foo:hoge' ]
200
-
201
- '<foo:hoge xmlns:foo="foo"><foo:fuga xmlns:foo="bar"/><foo:moga/></foo:hoge>'
202
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
203
- [ :on_stag_end_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo'} ]
204
- [ :on_stag_ns, 'foo:fuga', 'foo', 'fuga' ]
205
- [ :on_stag_end_empty_ns, 'foo:fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
206
- [ :on_stag_ns, 'foo:moga', 'foo', 'moga' ]
207
- [ :on_stag_end_empty_ns, 'foo:moga', {'xmlns'=>NS_XMLNS, 'foo'=>'foo'} ]
208
- [ :on_etag, 'foo:hoge' ]
209
-
210
- '<foo:hoge xmlns:foo="foo"><foo:fuga xmlns:foo="bar"><foo:moga/></foo:fuga></foo:hoge>'
211
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
212
- [ :on_stag_end_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo'} ]
213
- [ :on_stag_ns, 'foo:fuga', 'foo', 'fuga' ]
214
- [ :on_stag_end_ns, 'foo:fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
215
- [ :on_stag_ns, 'foo:moga', 'foo', 'moga' ]
216
- [ :on_stag_end_empty_ns, 'foo:moga', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
217
- [ :on_etag, 'foo:fuga' ]
218
- [ :on_etag, 'foo:hoge' ]
219
-
220
- '<foo:hoge xmlns:foo="foo" xmlns:bar="bar"/>'
221
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
222
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo', 'bar'=>'bar'} ]
223
-
224
- '<foo:hoge xmlns:foo="foo" xmlns:bar="bar"><bar:fuga/></foo:hoge>'
225
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
226
- [ :on_stag_end_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo', 'bar'=>'bar'} ]
227
- [ :on_stag_ns, 'bar:fuga', 'bar', 'fuga' ]
228
- [ :on_stag_end_empty_ns, 'bar:fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'foo', 'bar'=>'bar'} ]
229
- [ :on_etag, 'foo:hoge' ]
230
-
231
- '<foo:hoge xmlns:foo="foo" xmlns:bar="bar"><bar:fuga xmlns:foo="baz"/><moga/></foo:hoge>'
232
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
233
- [ :on_stag_end_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo', 'bar'=>'bar'} ]
234
- [ :on_stag_ns, 'bar:fuga', 'bar', 'fuga' ]
235
- [ :on_stag_end_empty_ns, 'bar:fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'baz', 'bar'=>'bar'} ]
236
- [ :on_stag_ns, 'moga', '', 'moga' ]
237
- [ :on_stag_end_empty_ns, 'moga', {'xmlns'=>NS_XMLNS, 'foo'=>'foo', 'bar'=>'bar'} ]
238
- [ :on_etag, 'foo:hoge' ]
239
-
240
- '<hoge><foo:hoge xmlns:foo="foo" xmlns:bar="bar"/><fuga/></hoge>'
241
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
242
- [ :on_stag_end_ns, 'hoge', {} ]
243
- [ :on_stag_ns, 'foo:hoge', 'foo', 'hoge' ]
244
- [ :on_stag_end_empty_ns, 'foo:hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'foo', 'bar'=>'bar'} ]
245
- [ :on_stag_ns, 'fuga', '', 'fuga' ]
246
- [ :on_stag_end_empty_ns, 'fuga', {'xmlns'=>NS_XMLNS, 'foo'=>nil, 'bar'=>nil} ]
247
- [ :on_etag, 'hoge' ]
248
-
249
- TESTCASEEND
250
-
251
-
252
-
253
- deftestcase 'attribute', <<-'TESTCASEEND'
254
-
255
- '<hoge xmlns="bar" fuga="moga"/>'
256
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
257
- [ :on_attribute_ns, 'fuga', nil, 'fuga' ]
258
- [ :on_attr_value, 'moga' ]
259
- [ :on_attribute_end, 'fuga' ]
260
- [ :on_stag_end_empty_ns, 'hoge', {''=>'bar'} ]
261
-
262
- '<hoge xmlns:foo="bar" foo:fuga="moga"/>'
263
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
264
- [ :on_attribute_ns, 'foo:fuga', 'foo', 'fuga' ]
265
- [ :on_attr_value, 'moga' ]
266
- [ :on_attribute_end, 'foo:fuga' ]
267
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
268
-
269
- '<hoge xmlns:foo="bar" bar:fuga="moga"/>'
270
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
271
- [ :on_attribute_ns, 'bar:fuga', 'bar', 'fuga' ]
272
- [ :on_attr_value, 'moga' ]
273
- [ :on_attribute_end, 'bar:fuga' ]
274
- [ :ns_wellformed_error, "prefix `bar' is not declared" ]
275
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
276
-
277
- '<hoge xmlns:foo="bar"><fuga foo:baz="moga"/></hoge>'
278
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
279
- [ :on_stag_end_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
280
- [ :on_stag_ns, 'fuga', '', 'fuga' ]
281
- [ :on_attribute_ns, 'foo:baz', 'foo', 'baz' ]
282
- [ :on_attr_value, 'moga' ]
283
- [ :on_attribute_end, 'foo:baz' ]
284
- [ :on_stag_end_empty_ns, 'fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'bar'} ]
285
- [ :on_etag, 'hoge' ]
286
-
287
- '<hoge xmlns:foo="bar" xmlns:bar="baz" foo:fuga="moga" bar:fuga="gema"/>'
288
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
289
- [ :on_attribute_ns, 'foo:fuga', 'foo', 'fuga' ]
290
- [ :on_attr_value, 'moga' ]
291
- [ :on_attribute_end, 'foo:fuga' ]
292
- [ :on_attribute_ns, 'bar:fuga', 'bar', 'fuga' ]
293
- [ :on_attr_value, 'gema' ]
294
- [ :on_attribute_end, 'bar:fuga' ]
295
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'bar', 'bar'=>'baz'} ]
296
-
297
- '<hoge xmlns:foo="bar" xmlns:bar="bar" foo:fuga="moga" bar:fuga="gema"/>'
298
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
299
- [ :on_attribute_ns, 'foo:fuga', 'foo', 'fuga' ]
300
- [ :on_attr_value, 'moga' ]
301
- [ :on_attribute_end, 'foo:fuga' ]
302
- [ :on_attribute_ns, 'bar:fuga', 'bar', 'fuga' ]
303
- [ :on_attr_value, 'gema' ]
304
- [ :on_attribute_end, 'bar:fuga' ]
305
- [ :ns_wellformed_error, "doubled localpart `fuga' in the same namespace" ]
306
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'bar', 'bar'=>'bar'} ]
307
-
308
- '<hoge foo:fuga="moga" bar:fuga="gema" xmlns:foo="bar" xmlns:bar="bar"/>'
309
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
310
- [ :on_attribute_ns, 'foo:fuga', 'foo', 'fuga' ]
311
- [ :on_attr_value, 'moga' ]
312
- [ :on_attribute_end, 'foo:fuga' ]
313
- [ :on_attribute_ns, 'bar:fuga', 'bar', 'fuga' ]
314
- [ :on_attr_value, 'gema' ]
315
- [ :on_attribute_end, 'bar:fuga' ]
316
- [ :ns_wellformed_error, "doubled localpart `fuga' in the same namespace" ]
317
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'bar', 'bar'=>'bar'} ]
318
-
319
- '<hoge xmlns:foo="moga"><fuga foo:bar="a" baz:bar="a" xmlns:baz="moga"/></hoge>'
320
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
321
- [ :on_stag_end_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'foo'=>'moga'} ]
322
- [ :on_stag_ns, 'fuga', '', 'fuga' ]
323
- [ :on_attribute_ns, 'foo:bar', 'foo', 'bar' ]
324
- [ :on_attr_value, 'a' ]
325
- [ :on_attribute_end, 'foo:bar' ]
326
- [ :on_attribute_ns, 'baz:bar', 'baz', 'bar' ]
327
- [ :on_attr_value, 'a' ]
328
- [ :on_attribute_end, 'baz:bar' ]
329
- [ :ns_wellformed_error, "doubled localpart `bar' in the same namespace" ]
330
- [ :on_stag_end_empty_ns, 'fuga', {'xmlns'=>NS_XMLNS, 'foo'=>'moga', 'baz'=>'moga'} ]
331
- [ :on_etag, 'hoge' ]
332
-
333
- '<foo foo:bar:fuga="hoge" xmlns:foo="bar" xmlns:bar="bar"/>'
334
- [ :on_stag_ns, 'foo', '', 'foo' ]
335
- [ :ns_parse_error, "localpart `bar:fuga' includes `:'" ]
336
- [ :on_attribute_ns, 'foo:bar:fuga', 'foo', 'bar:fuga' ]
337
- [ :on_attr_value, 'hoge' ]
338
- [ :on_attribute_end, 'foo:bar:fuga' ]
339
- [ :on_stag_end_empty_ns, 'foo', {'xmlns'=>NS_XMLNS, 'foo'=>'bar', 'bar'=>'bar'} ]
340
-
341
- TESTCASEEND
342
-
343
-
344
-
345
- deftestcase 'reserved', <<-'TESTCASEEND'
346
-
347
- '<hoge xml:lang="ja"/>'
348
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
349
- [ :on_attribute_ns, 'xml:lang', 'xml', 'lang' ]
350
- [ :on_attr_value, 'ja' ]
351
- [ :on_attribute_end, 'xml:lang' ]
352
- [ :on_stag_end_empty_ns, 'hoge', {'xml'=>NS_XML} ]
353
-
354
- '<foo><bar><baz xml:lang="ja"/></bar><hoge/></foo>'
355
- [ :on_stag_ns, 'foo', '', 'foo' ]
356
- [ :on_stag_end_ns, 'foo', {} ]
357
- [ :on_stag_ns, 'bar', '', 'bar' ]
358
- [ :on_stag_end_ns, 'bar', {} ]
359
- [ :on_stag_ns, 'baz', '', 'baz' ]
360
- [ :on_attribute_ns, 'xml:lang', 'xml', 'lang' ]
361
- [ :on_attr_value, 'ja' ]
362
- [ :on_attribute_end, 'xml:lang' ]
363
- [ :on_stag_end_empty_ns, 'baz', {'xml'=>NS_XML} ]
364
- [ :on_etag, 'bar' ]
365
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
366
- [ :on_stag_end_empty_ns, 'hoge', {'xml'=>NS_XML} ]
367
- [ :on_etag, 'foo' ]
368
-
369
- '<xmlns:hoge/>'
370
- [ :ns_wellformed_error, "prefix `xmlns' is not used for namespace prefix declaration" ]
371
- [ :on_stag_ns, 'xmlns:hoge', 'xmlns', 'hoge' ]
372
- [ :on_stag_end_empty_ns, 'xmlns:hoge', {'xmlns'=>NS_XMLNS} ]
373
-
374
- '<hoge xmlns:xml="fuga"/>'
375
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
376
- [ :ns_wellformed_error, "prefix `xml' can't be bound to any namespace except `http://www.w3.org/XML/1998/namespace'" ]
377
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'xml'=>'fuga'} ]
378
-
379
- '<hoge xmlns:xml="http://www.w3.org/XML/1998/namespace"/>'
380
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
381
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'xml'=>NS_XML} ]
382
-
383
- '<hoge xmlns:fuga="http://www.w3.org/XML/1998/namespace"/>'
384
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
385
- [ :ns_wellformed_error, "namespace `http://www.w3.org/XML/1998/namespace' is reserved for prefix `xml'" ]
386
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'fuga'=>NS_XML} ]
387
-
388
- '<hoge xmlns:xmlns="fuga"/>'
389
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
390
- [ :ns_wellformed_error, "prefix `xmlns' can't be bound to any namespace explicitly" ]
391
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>'fuga'} ]
392
-
393
- '<hoge xmlns:xmlns="http://www.w3.org/2000/xmlns/"/>'
394
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
395
- [ :ns_wellformed_error, "prefix `xmlns' can't be bound to any namespace explicitly" ]
396
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS} ]
397
-
398
- '<hoge xmlns:fuga="http://www.w3.org/2000/xmlns/"/>'
399
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
400
- [ :ns_wellformed_error, "namespace `http://www.w3.org/2000/xmlns/' is reserved for prefix `xmlns'" ]
401
- [ :on_stag_end_empty_ns, 'hoge', {'xmlns'=>NS_XMLNS, 'fuga'=>NS_XMLNS} ]
402
-
403
- TESTCASEEND
404
-
405
-
406
-
407
- deftestcase 'wellformedness', <<-'TESTCASEEND'
408
-
409
- '<!DOCTYPE foo:bar><hoge/>'
410
- [ :on_doctype, 'foo:bar', nil, nil ]
411
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
412
- [ :on_stag_end_empty_ns, 'hoge', {} ]
413
-
414
- '<!DOCTYPE foo:bar:baz><hoge/>'
415
- [ :ns_parse_error, "qualified name `foo:bar:baz' includes `:'" ]
416
- [ :on_doctype, 'foo:bar:baz', nil, nil ]
417
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
418
- [ :on_stag_end_empty_ns, 'hoge', {} ]
419
-
420
- '<?foo?><hoge/>'
421
- [ :on_pi, 'foo', '' ]
422
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
423
- [ :on_stag_end_empty_ns, 'hoge', {} ]
424
-
425
- '<?foo:bar?><hoge/>'
426
- [ :ns_parse_error, "PI target `foo:bar' includes `:'" ]
427
- [ :on_pi, 'foo:bar', '' ]
428
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
429
- [ :on_stag_end_empty_ns, 'hoge', {} ]
430
-
431
- '<hoge fuga="&foo:bar;"/>'
432
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
433
- [ :on_attribute_ns, 'fuga', nil, 'fuga' ]
434
- [ :ns_parse_error, "entity reference `foo:bar' includes `:'" ]
435
- [ :on_attr_entityref, 'foo:bar' ]
436
- [ :on_attribute_end, 'fuga' ]
437
- [ :on_stag_end_empty_ns, 'hoge', {} ]
438
-
439
- '<hoge>&foo:bar;</hoge>'
440
- [ :on_stag_ns, 'hoge', '', 'hoge' ]
441
- [ :on_stag_end_ns, 'hoge', {} ]
442
- [ :ns_parse_error, "entity reference `foo:bar' includes `:'" ]
443
- [ :on_entityref, 'foo:bar' ]
444
- [ :on_etag, 'hoge' ]
445
-
446
- TESTCASEEND
447
-
448
-
449
-
450
-
451
-
452
- end
453
-
454
-
455
-
456
-
457
- load "#{File.dirname($0)}/runtest.rb" if __FILE__ == $0