rgen 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/CHANGELOG +20 -1
  2. data/MIT-LICENSE +1 -1
  3. data/README +12 -9
  4. data/lib/instantiators/ea_instantiator.rb +36 -0
  5. data/lib/metamodels/uml13_metamodel.rb +559 -0
  6. data/lib/metamodels/uml13_metamodel_ext.rb +26 -0
  7. data/lib/mmgen/metamodel_generator.rb +5 -5
  8. data/lib/mmgen/mm_ext/ecore_ext.rb +95 -0
  9. data/lib/mmgen/mmgen.rb +6 -4
  10. data/lib/mmgen/templates/annotations.tpl +37 -0
  11. data/lib/mmgen/templates/metamodel_generator.tpl +171 -0
  12. data/lib/rgen/ecore/ecore.rb +190 -0
  13. data/lib/rgen/ecore/ecore_instantiator.rb +25 -0
  14. data/lib/rgen/ecore/ecore_transformer.rb +85 -0
  15. data/lib/rgen/environment.rb +9 -24
  16. data/lib/rgen/find_helper.rb +68 -0
  17. data/lib/rgen/{instantiator.rb → instantiator/abstract_instantiator.rb} +6 -2
  18. data/lib/rgen/instantiator/abstract_xml_instantiator.rb +59 -0
  19. data/lib/rgen/instantiator/default_xml_instantiator.rb +117 -0
  20. data/lib/rgen/instantiator/ecore_xml_instantiator.rb +144 -0
  21. data/lib/rgen/instantiator/nodebased_xml_instantiator.rb +157 -0
  22. data/lib/rgen/instantiator/xmi11_instantiator.rb +164 -0
  23. data/lib/rgen/metamodel_builder.rb +103 -9
  24. data/lib/rgen/metamodel_builder/build_helper.rb +26 -4
  25. data/lib/rgen/metamodel_builder/builder_extensions.rb +285 -88
  26. data/lib/rgen/metamodel_builder/builder_runtime.rb +7 -1
  27. data/lib/rgen/metamodel_builder/data_types.rb +67 -0
  28. data/lib/rgen/metamodel_builder/intermediate/annotation.rb +30 -0
  29. data/lib/rgen/metamodel_builder/metamodel_description.rb +232 -0
  30. data/lib/rgen/metamodel_builder/mm_multiple.rb +23 -0
  31. data/lib/rgen/metamodel_builder/module_extension.rb +33 -0
  32. data/lib/rgen/model_comparator.rb +56 -0
  33. data/lib/rgen/model_dumper.rb +5 -5
  34. data/lib/rgen/name_helper.rb +17 -1
  35. data/lib/rgen/template_language.rb +148 -28
  36. data/lib/rgen/template_language/directory_template_container.rb +56 -38
  37. data/lib/rgen/template_language/output_handler.rb +93 -77
  38. data/lib/rgen/template_language/template_container.rb +186 -143
  39. data/lib/rgen/transformer.rb +19 -14
  40. data/lib/transformers/uml13_to_ecore.rb +75 -0
  41. data/redist/xmlscan/ChangeLog +1301 -0
  42. data/redist/xmlscan/README +34 -0
  43. data/redist/xmlscan/THANKS +11 -0
  44. data/redist/xmlscan/doc/changes.html +74 -0
  45. data/redist/xmlscan/doc/changes.rd +80 -0
  46. data/redist/xmlscan/doc/en/conformance.html +136 -0
  47. data/redist/xmlscan/doc/en/conformance.rd +152 -0
  48. data/redist/xmlscan/doc/en/manual.html +356 -0
  49. data/redist/xmlscan/doc/en/manual.rd +402 -0
  50. data/redist/xmlscan/doc/ja/conformance.ja.html +118 -0
  51. data/redist/xmlscan/doc/ja/conformance.ja.rd +134 -0
  52. data/redist/xmlscan/doc/ja/manual.ja.html +325 -0
  53. data/redist/xmlscan/doc/ja/manual.ja.rd +370 -0
  54. data/redist/xmlscan/doc/src/Makefile +41 -0
  55. data/redist/xmlscan/doc/src/conformance.rd.src +256 -0
  56. data/redist/xmlscan/doc/src/langsplit.rb +110 -0
  57. data/redist/xmlscan/doc/src/manual.rd.src +614 -0
  58. data/redist/xmlscan/install.rb +41 -0
  59. data/redist/xmlscan/lib/xmlscan/encoding.rb +311 -0
  60. data/redist/xmlscan/lib/xmlscan/htmlscan.rb +289 -0
  61. data/redist/xmlscan/lib/xmlscan/namespace.rb +352 -0
  62. data/redist/xmlscan/lib/xmlscan/parser.rb +299 -0
  63. data/redist/xmlscan/lib/xmlscan/scanner.rb +1109 -0
  64. data/redist/xmlscan/lib/xmlscan/version.rb +22 -0
  65. data/redist/xmlscan/lib/xmlscan/visitor.rb +158 -0
  66. data/redist/xmlscan/lib/xmlscan/xmlchar.rb +441 -0
  67. data/redist/xmlscan/memo/CONFORMANCE +1249 -0
  68. data/redist/xmlscan/memo/PRODUCTIONS +195 -0
  69. data/redist/xmlscan/memo/contentspec.ry +335 -0
  70. data/redist/xmlscan/samples/chibixml.rb +105 -0
  71. data/redist/xmlscan/samples/getxmlchar.rb +122 -0
  72. data/redist/xmlscan/samples/rexml.rb +159 -0
  73. data/redist/xmlscan/samples/xmlbench.rb +88 -0
  74. data/redist/xmlscan/samples/xmlbench/parser/chibixml.rb +22 -0
  75. data/redist/xmlscan/samples/xmlbench/parser/nqxml.rb +29 -0
  76. data/redist/xmlscan/samples/xmlbench/parser/rexml.rb +62 -0
  77. data/redist/xmlscan/samples/xmlbench/parser/xmlparser.rb +22 -0
  78. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-0.0.10.rb +62 -0
  79. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb +22 -0
  80. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb +22 -0
  81. data/redist/xmlscan/samples/xmlbench/parser/xmlscan.rb +99 -0
  82. data/redist/xmlscan/samples/xmlbench/xmlbench-lib.rb +116 -0
  83. data/redist/xmlscan/samples/xmlconftest.rb +200 -0
  84. data/redist/xmlscan/test.rb +7 -0
  85. data/redist/xmlscan/tests/deftestcase.rb +73 -0
  86. data/redist/xmlscan/tests/runtest.rb +47 -0
  87. data/redist/xmlscan/tests/testall.rb +14 -0
  88. data/redist/xmlscan/tests/testencoding.rb +438 -0
  89. data/redist/xmlscan/tests/testhtmlscan.rb +752 -0
  90. data/redist/xmlscan/tests/testnamespace.rb +457 -0
  91. data/redist/xmlscan/tests/testparser.rb +591 -0
  92. data/redist/xmlscan/tests/testscanner.rb +1749 -0
  93. data/redist/xmlscan/tests/testxmlchar.rb +143 -0
  94. data/redist/xmlscan/tests/visitor.rb +34 -0
  95. data/test/array_extensions_test.rb +2 -2
  96. data/test/ea_instantiator_test.rb +41 -0
  97. data/test/ecore_self_test.rb +53 -0
  98. data/test/environment_test.rb +11 -6
  99. data/test/metamodel_builder_test.rb +404 -245
  100. data/test/metamodel_roundtrip_test.rb +52 -0
  101. data/test/metamodel_roundtrip_test/TestModel.rb +65 -0
  102. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +64 -0
  103. data/test/metamodel_roundtrip_test/houseMetamodel.ecore +32 -0
  104. data/test/metamodel_roundtrip_test/houseMetamodel_from_ecore.rb +39 -0
  105. data/test/rgen_test.rb +3 -3
  106. data/test/template_language_test.rb +65 -39
  107. data/test/template_language_test/expected_result.txt +24 -3
  108. data/test/template_language_test/templates/code/array.tpl +11 -0
  109. data/test/template_language_test/templates/content/author.tpl +7 -0
  110. data/test/template_language_test/templates/content/chapter.tpl +1 -1
  111. data/test/template_language_test/templates/root.tpl +17 -8
  112. data/test/template_language_test/testout.txt +24 -3
  113. data/test/testmodel/class_model_checker.rb +119 -0
  114. data/test/{xmi_instantiator_test/testmodel.eap → testmodel/ea_testmodel.eap} +0 -0
  115. data/test/{xmi_instantiator_test/testmodel.xml → testmodel/ea_testmodel.xml} +81 -14
  116. data/test/testmodel/ea_testmodel_partial.xml +317 -0
  117. data/test/testmodel/ecore_model_checker.rb +101 -0
  118. data/test/testmodel/manual_testmodel.xml +22 -0
  119. data/test/testmodel/object_model_checker.rb +67 -0
  120. data/test/transformer_test.rb +18 -10
  121. data/test/xml_instantiator_test.rb +81 -8
  122. data/test/xml_instantiator_test/simple_ecore_model_checker.rb +94 -0
  123. data/test/xml_instantiator_test/simple_xmi_ecore_instantiator.rb +53 -0
  124. data/test/xml_instantiator_test/simple_xmi_metamodel.rb +49 -0
  125. data/test/xml_instantiator_test/simple_xmi_to_ecore.rb +75 -0
  126. metadata +126 -28
  127. data/lib/ea/xmi_class_instantiator.rb +0 -46
  128. data/lib/ea/xmi_helper.rb +0 -26
  129. data/lib/ea/xmi_metamodel.rb +0 -34
  130. data/lib/ea/xmi_object_instantiator.rb +0 -46
  131. data/lib/ea/xmi_to_classmodel.rb +0 -78
  132. data/lib/ea/xmi_to_objectmodel.rb +0 -92
  133. data/lib/mmgen/mm_ext/uml_classmodel_ext.rb +0 -71
  134. data/lib/mmgen/templates/uml_classmodel.tpl +0 -63
  135. data/lib/rgen/xml_instantiator.rb +0 -132
  136. data/lib/uml/objectmodel_instantiator.rb +0 -53
  137. data/lib/uml/uml_classmodel.rb +0 -92
  138. data/lib/uml/uml_objectmodel.rb +0 -65
  139. data/test/metamodel_generator_test.rb +0 -44
  140. data/test/metamodel_generator_test/TestModel.rb +0 -40
  141. data/test/metamodel_generator_test/expected_result.txt +0 -40
  142. data/test/xmi_class_instantiator_test.rb +0 -24
  143. data/test/xmi_instantiator_test/class_model_checker.rb +0 -97
  144. data/test/xmi_object_instantiator_test.rb +0 -65
  145. data/test/xml_instantiator_test/testmodel.xml +0 -7
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # langsplit.rb
4
+ #
5
+ # $Id: langsplit.rb,v 1.1 2003/01/22 16:41:45 katsu Exp $
6
+ #
7
+
8
+
9
+ class TextBlockReader
10
+
11
+ def initialize(file)
12
+ @file = file
13
+ @last = nil
14
+ end
15
+
16
+ public
17
+
18
+ def gets
19
+ lang = nil
20
+ @last = @last || @file.gets
21
+ lang = $1 if /\A\s+([a-z][a-z])\| / =~ @last
22
+ dst = []
23
+ while @last
24
+ if /\A\s*\z/ =~ @last then
25
+ dst.push @last
26
+ dst.push @last while /\A\s*\z/ =~ (@last = @file.gets)
27
+ break
28
+ elsif /\A\s+([a-z][a-z])\|(?: | *$)/ =~ @last then
29
+ break unless $1 == lang
30
+ dst.push $'
31
+ else
32
+ break if lang
33
+ dst.push @last
34
+ end
35
+ @last = @file.gets
36
+ end
37
+ (@last or not dst.empty?) and [ lang, dst ]
38
+ end
39
+
40
+ end
41
+
42
+
43
+ class LangSplit
44
+
45
+ DefaultLanguage = 'ja'
46
+
47
+ def initialize(filename, lang)
48
+ lang = nil if lang == DefaultLanguage
49
+ @lang = lang
50
+ @file = File.open(filename)
51
+ @reader = TextBlockReader.new(@file)
52
+ @last = nil
53
+ end
54
+
55
+ def close
56
+ @file.close
57
+ end
58
+
59
+ def self.open(*args)
60
+ f = new(*args)
61
+ begin
62
+ yield f
63
+ ensure
64
+ f.close
65
+ end
66
+ end
67
+
68
+ def gets
69
+ lang, text = @last = @last || @reader.gets
70
+ return nil unless @last
71
+ raise "syntax error" if lang
72
+ indent = text.reject { |i| i.strip.empty? }.
73
+ collect { |i| /\A\s*/.match(i)[0] }.
74
+ min { |a,b| a.size <=> b.size }
75
+ lastspace = []
76
+ texts = {}
77
+ while true
78
+ lastspace.clear
79
+ lastspace.push text.pop while /\A\s*\z/ =~ text.last
80
+ (texts[lang] || texts[lang] = []).concat(text)
81
+ @last = @reader.gets
82
+ lang, text = @last
83
+ break unless @last and lang
84
+ text.each { |i| i[0,0] = indent unless i.strip.empty? }
85
+ end
86
+ (texts[@lang] || texts[nil]).concat(lastspace).join
87
+ end
88
+
89
+ def each
90
+ while s = gets
91
+ yield s
92
+ end
93
+ end
94
+
95
+ end
96
+
97
+
98
+
99
+
100
+ lang = nil
101
+
102
+ ARGV.each { |arg|
103
+ if /\A-([a-z][a-z])\z/ =~ arg then
104
+ lang = $1
105
+ else
106
+ LangSplit.open(arg, lang) { |f|
107
+ f.each { |i| print i }
108
+ }
109
+ end
110
+ }
@@ -0,0 +1,614 @@
1
+ =begin
2
+ # $Id: manual.rd.src,v 1.1 2003/01/22 16:41:45 katsu Exp $
3
+
4
+ = xmlscan version 0.2 ��ե���󥹥ޥ˥奢��
5
+
6
+ en| = xmlscan version 0.2 Reference Manual
7
+ en|
8
+ en| This is a broken English version. If you find lexical or
9
+ en| grammatical mistakes, or strange expressions (including kidding,
10
+ en| unnatural or unclear ones) in this document, please
11
+ en| ((<let me know|URL:mailto:katsu@blue.sky.or.jp>)).
12
+
13
+ == ����
14
+
15
+ en| == Abstract
16
+
17
+ xmlscan �� Ruby �����ǽ񤫤줿 non-validating XML parser �Ǥ���
18
+
19
+ en| XMLscan is one of non-validating XML parser written in 100%
20
+ en| pure Ruby.
21
+
22
+ ���Τ褦����Ĺ������ޤ���
23
+
24
+ en| XMLscan's features are as follows:
25
+
26
+ : 100% pure Ruby
27
+ ��ĥ�饤�֥������ɬ�פȤ��ʤ��Τǡ�1.6 �ʾ�� Ruby ���󥿥ץ꥿����
28
+ ����д�����ư��ޤ���(ɸ��ź�դγ�ĥ�饤�֥���ɬ�פȤ��ޤ���)
29
+
30
+ en| : 100% pure Ruby
31
+ en| XMLscan doesn't require any extension libraries, so
32
+ en| it completely works only with a Ruby interpreter version
33
+ en| 1.6 or above.
34
+ en| (It also needs no standard-bundled extension library.)
35
+
36
+ : ���ʤؤ�Ŭ����
37
+ xmlscan �ϡ�XML 1.0 Specification �ǽҤ٤��Ƥ��롢�������򸡾ڤ��ʤ�
38
+ �ץ������˵��������Ƥξ������������Ȥ���ɸ�˳�ȯ���ʤ����
39
+ ���ޤ���
40
+
41
+ en| : Compliant to the specification
42
+ en| XMLscan has been developed to satisfy all conditions,
43
+ en| described in XML 1.0 Specification and required to a
44
+ en| non-validating XML processor
45
+
46
+ : ��®
47
+ xmlscan �β��Ϥ�®���ϡ������餯����¸���� Ruby �ǽ񤫤줿
48
+ XML/HTML parser ����Ǻ�®�Ǥ���
49
+
50
+ en| : High-speed
51
+ en| XMLscan is, probably, the fastest parser among all
52
+ en| existing XML/HTML parsers written in pure Ruby.
53
+
54
+ : �͡���CES���б�
55
+ xmlscan �Ͼ��ʤ��Ȥ� iso-8859-*, EUC-*, Shift_JIS, UTF-8 �ǽ񤫤줿
56
+ XMLʸ��򤽤Τޤ޲��ϤǤ��ޤ��������� UTF-16 �ϰ����ޤ���
57
+
58
+ en| : Support for various CES.
59
+ en| XMLscan can parse an XML document encoded in at least
60
+ en| iso-8859-*, EUC-*, Shift_JIS, and UTF-8 as it is.
61
+ en| UTF-16 is not supported directly, though.
62
+
63
+ : ���Ϥ������
64
+ xmlscan �����ϡ�����XMLʸ�����Ϥ��뤳�Ȥ����Ǥ���XMLʸ���
65
+ ���ؤ˼�갷������ι��٥�ʵ�ǽ���󶡤��ޤ���xmlscan ��
66
+ ���Τ褦�ʵ�ǽ���󶡤���饤�֥��Υ�����ʬ�Ȥ��ƻȤ��뤳�Ȥ�
67
+ ���ꤷ�Ƥ��ޤ���
68
+
69
+ en| : Just parsing
70
+ en| The role of xmlscan is just to parse an XML document.
71
+ en| XMLscan doesn't provide high-level features to easily
72
+ en| handle an XML document. XMLscan is assumed to be used as
73
+ en| a core part of a library providing such features.
74
+
75
+ : HTML
76
+ ���ޥ��� HTML ��ʸ���Ϥ��� htmlscan ���դ��Ƥ��ޤ���
77
+
78
+ en| : HTML
79
+ en| XMLscan contains htmlscan, an HTML parser.
80
+
81
+
82
+ == ʸ�����󥳡��ǥ��󥰤ˤĤ���
83
+
84
+ en| == Character encodings
85
+
86
+ �ǥե���ȤǤϡ�xmlscan ���ɤ� CES (Character Encoding Scheme) ��
87
+ XMLʸ�����Ϥ��뤫�ϥ������Х��ѿ� $KCODE ���ͤˤ�äƷ�ޤ�ޤ���
88
+ EUC-*, Shift_JIS, UTF-8 �ǽ񤫤줿XMLʸ�����Ϥ���ˤ� $KCODE ��
89
+ ((<XMLScan::XMLScanner#kcode=>)) ��Ŭ�ڤ��ͤ����ꤹ��ɬ�פ�����ޤ���
90
+
91
+ en| By default, the value of global variable $KCODE decides
92
+ en| which CES (character encoding scheme) is assumed for xmlscan
93
+ en| to parse an XML document.
94
+ en| You need to set $KCODE or ((<XMLScan::XMLScanner#kcode=>))
95
+ en| an appropriate value to parse an XML document encoded in EUC-*,
96
+ en| Shift_JIS, or UTF-8.
97
+
98
+ UTF-16 ��ľ�ܥ��ݡ��Ȥ��Ƥ��ޤ��󡣲������˰�ö UTF-8 ���Ѵ�����
99
+ ɬ�פ�����ޤ���
100
+
101
+ en| UTF-16 is not supported directly. You should convert it into
102
+ en| UTF-8 before parsing.
103
+
104
+
105
+ == XML̾�����֤ˤĤ���
106
+
107
+ en| == XML Namespaces
108
+
109
+ XML̾�����֤� xmlscan/namespace.rb �Ǽ�������Ƥ��ޤ��������󥿡��ե�������
110
+ �礭���ѹ�����ͽ�꤬���뤿�� undocumented �Ȥ��ޤ���
111
+
112
+ en| XML Namespaces have been already implemented in
113
+ en| xmlscan/namespace.rb. However, since its interface is going
114
+ en| to be modified, this feature is undocumented now.
115
+
116
+
117
+
118
+ == ���饹��ե����
119
+ en| == Class Reference
120
+
121
+
122
+ === XMLScan::Error
123
+
124
+ xmlscan �˴ؤ������Ƥ��㳰�Υ����ѡ����饹��
125
+
126
+ en| The superclass for all exceptions related to xmlscan.
127
+
128
+ �������㳰�ϡ�XMLScan::Visitor �Υ��󥹥��󥹤���XMLScan::XMLScanner ��
129
+ XMLScan::XMLParser ���饨�顼���������ä��Ȥ��ˡ��ǥե���Ȥ�ȯ��������
130
+ ��ΤǤ����ƥѡ�����ľ�ܤ������㳰���ꤲ�뤳�ȤϤ���ޤ���
131
+
132
+ en| These exceptions are raised by XMLScan::Visitor
133
+ en| by default when it receives an error report from a parser,
134
+ en| such as XMLScan::XMLScanner or XMLScan::XMLParser.
135
+ en| Each parser never raises these exceptions by itself.
136
+
137
+ #�����㳰�� xmlscan/scanner.rb ���������Ƥ��ޤ���
138
+ en| #The following exceptions are defined in xmlscan/scanner.rb:
139
+
140
+ : XMLScan::ParseError
141
+
142
+ ������§�˥ޥå����ʤ����������ȿ�ʳ��Υ��顼��
143
+
144
+ en| An error except a constraint violation, for example,
145
+ en| an XML document is unmatched with a production.
146
+
147
+ : XMLScan::NotWellFormedError
148
+
149
+ ����������˰�ȿ���Ƥ��롣
150
+
151
+ en| Raised when an XML document violates an well-formedness
152
+ en| constraint.
153
+
154
+ : XMLScan::NotValidError
155
+
156
+ ����������˰�ȿ���Ƥ��롣
157
+
158
+ en| Raised when an XML document violates an validity constraint.
159
+
160
+
161
+ === XMLScan::Visitor
162
+
163
+ XMLʸ��β��Ϸ�̤������뤿��� Mix-in �Ǥ���
164
+
165
+ en| Mix-in for receiving the result of parsing an XML document.
166
+
167
+ xmlscan �˴ޤޤ��� parser �ϡ�ʸ�����Ƭ���鹽ʸ���Ϥ�Ԥ�����������
168
+ ��ʸ���Ǥ򸫤Ĥ��뤿�Ӥˡ��ѡ�����Ϳ����줿 XMLScan::Visitor ��
169
+ ���󥹥��󥹤�����Υ᥽�åɤ�ƤӽФ��ޤ������θƤӽФ��ϡ�ɬ��ʸ���
170
+ ��Ƭ������֤˹Ԥ��ޤ���
171
+
172
+ en| Each parser included in xmlscan parses an XML document from
173
+ en| the beginning, and calls each specific method of given instance of
174
+ en| XMLScan::Visitor for each syntactic element, such as a tag.
175
+ en| It is ensured that these calls is in order of the appearance
176
+ en| in the document from the beginning.
177
+
178
+ ==== �᥽�å�:
179
+ en| ==== Methods:
180
+
181
+ �ä˵��Ҥ�̵���¤ꡢ�ƥ᥽�åɤϥǥե���ȤǤϲ��⤷�ޤ���
182
+
183
+ en| Without special notice, the following methods do nothing by
184
+ en| default.
185
+
186
+ --- XMLScan::Visitor#parse_error(msg)
187
+
188
+ ������§�˥ޥå����ʤ����������ȿ�ʳ��Υ��顼��ȯ����������
189
+ �ƤӽФ���ޤ����ǥե���ȤǤ� ((<XMLScan::ParseError>))�㳰��
190
+ ȯ�������ޤ����㳰�����������æ�Ф�Ԥ鷺�����̤������
191
+ �ѡ������֤��ȡ��ѡ����ϥ��顼��������Ʋ��Ϥ�³���ޤ���
192
+
193
+ en| Called when the parser meets an error except a constraint
194
+ en| violation, for example, an XML document is unmatched with
195
+ en| a production. By default, this method raises
196
+ en| ((<XMLScan::ParseError>)) exception. If no exception is
197
+ en| raised and this method returns normally, the parser recovers
198
+ en| the error and continues to parse.
199
+
200
+ --- XMLScan::Visitor#wellformed_error(msg)
201
+
202
+ �����������ȿ��ȯ���������˸ƤӽФ���ޤ����ǥե���ȤǤ�
203
+ ((<XMLScan::NotWellFormedError>))�㳰��ȯ�������ޤ����㳰��������
204
+ ���æ�Ф�Ԥ鷺�����̤������ѡ������֤��ȡ��ѡ����ϥ��顼��
205
+ �������Ʋ��Ϥ�³���ޤ���
206
+
207
+ en| Called when the parser meets an well-formedness constraint
208
+ en| violation. By default, this method raises
209
+ en| ((<XMLScan::NotWellFormedError>)) exception. If no exception
210
+ en| is raised and this method returns normally, the parser recovers
211
+ en| the error and continues to parse.
212
+
213
+ --- XMLScan::Visitor#valid_error(msg)
214
+
215
+ �����������ȿ��ȯ���������˸ƤӽФ���ޤ����ǥե���ȤǤ�
216
+ ((<XMLScan::NotValidError>))�㳰��ȯ�������ޤ����㳰��������
217
+ ���æ�Ф�Ԥ鷺�����̤������ѡ������֤��ȡ��ѡ����ϥ��顼��
218
+ �������Ʋ��Ϥ�³���ޤ���
219
+
220
+ en| Called when the parser meets validity constraint
221
+ en| violation. By default, this method raises
222
+ en| ((<XMLScan::NotValidError>)) exception. If no exception
223
+ en| is raised and this method returns normally, the parser recovers
224
+ en| the error and continues to parse.
225
+
226
+ �ʤ������ߤ� xmlscan �ˤ��������򸡾ڤ���XML�ץ�������
227
+ �ޤޤ�Ƥ��ޤ��󡣤��Υ᥽�åɤϾ�����ǤΤ����ͽ�󤵤�Ƥ��ޤ���
228
+
229
+ en| FYI, current version of xmlscan includes no validating XML
230
+ en| processor. This method is reserved for future versions.
231
+
232
+ --- XMLScan::Visitor#warning(msg)
233
+
234
+ ���顼�ǤϤʤ����侩����ʤ������䡢xmlscan �ǤϽ�ʬ�˲��ϤǤ��ʤ�
235
+ ��ʸ��ȯ���������˸ƤӽФ���ޤ���
236
+
237
+ en| Called when the parser meets a non-error but unrecommended
238
+ en| thing or a syntax which xmlscan is not able to parse.
239
+
240
+ --- XMLScan::Visitor#on_start_document
241
+
242
+ XMLʸ��β��Ϥ�Ϥ��ľ���˸ƤӽФ���ޤ������Υ᥽�åɤ��ƤӽФ��줿
243
+ ��ˤ�ɬ�����б����� ((<XMLScan::Visitor#on_end_document>)) �᥽�åɤ�
244
+ �ƤӽФ���ޤ���
245
+
246
+ en| Called just before the parser starts parsing an XML document.
247
+ en| After this method is called, corresponding
248
+ en| ((<XMLScan::Visitor#on_end_document>)) method is always called.
249
+
250
+ --- XMLScan::Visitor#on_end_document
251
+
252
+ XMLʸ��ν�ü�ޤDz��Ϥ����ä���˸ƤӽФ���ޤ���
253
+
254
+ en| Called after the parser reaches the end of an XML document.
255
+
256
+ --- XMLScan::Visitor#on_xmldecl
257
+ --- XMLScan::Visitor#on_xmldecl_version(str)
258
+ --- XMLScan::Visitor#on_xmldecl_encoding(str)
259
+ --- XMLScan::Visitor#on_xmldecl_standalone(str)
260
+ --- XMLScan::Visitor#on_xmldecl_other(name, value)
261
+ --- XMLScan::Visitor#on_xmldecl_end
262
+
263
+ XML�����ȯ���������˸ƤӽФ���ޤ���
264
+
265
+ en| Called when the parser meets an XML declaration.
266
+
267
+ <?xml version="1.0" encoding="euc-jp" standalone="yes" ?>
268
+ ^ ^ ^ ^ ^
269
+ 1 2 3 4 5
270
+
271
+ method argument
272
+ --------------------------------------
273
+ 1: on_xmldecl
274
+ 2: on_xmldecl_version ("1.0")
275
+ 3: on_xmldecl_encoding ("euc-jp")
276
+ 4: on_xmldecl_standalone ("yes")
277
+ 5: on_xmldecl_end
278
+
279
+ XML�����ȯ��������硢on_xmldecl �� on_xmldecl_end ��ɬ��
280
+ �ƤӽФ���ޤ���¾�Υ᥽�åɤ��б����빽ʸ��XML������
281
+ ����ʤ��ä����ϸƤӽФ���ޤ���
282
+
283
+ en| When an XML declaration is found, both on_xmldecl and
284
+ en| on_xmldecl_end method are always called. Any other methods
285
+ en| are called only when the corresponding syntaxes are found.
286
+
287
+ on_xmldecl_other �� version, encoding, standalone �ʳ��������
288
+ XML�������ˤ��ä����˸ƤӽФ���ޤ������Τ褦������Ϲ�ʸ��
289
+ ������Ƥ��ʤ����ᡢon_xmldecl_other ���ƤӽФ�������ˤ�ɬ��
290
+ ((<XMLScan::Visitor#parse_error>)) �᥽�åɤ��ƤӽФ���뤳�Ȥ�
291
+ ���դ��Ʋ�������
292
+
293
+ en| When a declaration except version, encoding, and standalone
294
+ en| is found in an XML declaration, on_xmldecl_other method is
295
+ en| called. Since such a declaration is not permitted, note that
296
+ en| the parser always calls ((<XMLScan::Visitor#parse_error>)) method
297
+ en| before calling on_xmldecl_other method.
298
+
299
+ --- XMLScan::Visitor#on_doctype(root, pubid, sysid)
300
+
301
+ ʸ�������ȯ���������˸ƤӽФ���ޤ���
302
+
303
+ en| Called when the parser meets a document type declaration.
304
+
305
+ document argument
306
+ --------------------------------------------------------------
307
+ 1: <!DOCTYPE foo> ('foo', nil, nil)
308
+ 2: <!DOCTYPE foo SYSTEM "bar"> ('foo', nil, 'bar')
309
+ 3: <!DOCTYPE foo PUBLIC "bar"> ('foo', 'bar', nil )
310
+ 4: <!DOCTYPE foo PUBLIC "bar" "baz"> ('foo', 'bar', 'baz')
311
+
312
+ --- XMLScan::Visitor#on_prolog_space(str)
313
+
314
+ ���񤭤���˶����ȯ���������˸ƤӽФ���ޤ���
315
+
316
+ en| Called when the parser meets whitespaces in prolog.
317
+
318
+ --- XMLScan::Visitor#on_comment(str)
319
+
320
+ �����Ȥ�ȯ���������˸ƤӽФ���ޤ���
321
+
322
+ en| Called when the parser meets a comment.
323
+
324
+ --- XMLScan::Visitor#on_pi(target, pi)
325
+
326
+ ����̿���ȯ���������˸ƤӽФ���ޤ���
327
+
328
+ en| Called when the parser meets a processing instruction.
329
+
330
+ --- XMLScan::Visitor#on_chardata(str)
331
+
332
+ ʸ���ǡ�����ȯ���������˸ƤӽФ���ޤ���
333
+
334
+ en| Called when the parser meets character data.
335
+
336
+ --- XMLScan::Visitor#on_cdata(str)
337
+
338
+ CDATA����������ȯ���������˸ƤӽФ���ޤ���
339
+
340
+ en| Called when the parser meets a CDATA section.
341
+
342
+ --- XMLScan::Visitor#on_entityref(ref)
343
+
344
+ °���ͤ���ʳ��ξ��ǰ��̼��λ��Ȥ�ȯ���������˸ƤӽФ���ޤ���
345
+
346
+ en| Called when the parser meets a general entity reference
347
+ en| in a place except an attribute value.
348
+
349
+ --- XMLScan::Visitor#on_charref(code)
350
+ --- XMLScan::Visitor#on_charref_hex(code)
351
+
352
+ °���ͤ���ʳ��ξ���ʸ�����Ȥ�ȯ���������˸ƤӽФ���ޤ���
353
+ ʸ�������ɤ�10�ʿ��ǻ��ꤵ��Ƥ������� on_charref��16�ʿ���
354
+ ���ꤵ��Ƥ������� on_charref_hex ���ƤӽФ���ޤ���
355
+ ((|code|))�������Ǥ���
356
+
357
+ en| Called when the parser meets a character reference
358
+ en| in a place except an attribute value.
359
+ en| When the character code is represented by decimals,
360
+ en| on_charref is called. When by hexadecimals, on_charref_hex
361
+ en| is called. ((|code|)) is an integer.
362
+
363
+ --- XMLScan::Visitor#on_stag(name)
364
+ --- XMLScan::Visitor#on_attribute(name)
365
+ --- XMLScan::Visitor#on_attr_value(str)
366
+ --- XMLScan::Visitor#on_attr_entityref(ref)
367
+ --- XMLScan::Visitor#on_attr_charref(code)
368
+ --- XMLScan::Visitor#on_attr_charref_hex(code)
369
+ --- XMLScan::Visitor#on_attribute_end(name)
370
+ --- XMLScan::Visitor#on_stag_end_empty(name)
371
+ --- XMLScan::Visitor#on_stag_end(name)
372
+
373
+ ���ϥ�����ȯ���������˸ƤӽФ���ޤ���
374
+
375
+ en| Called when the parser meets an XML declaration.
376
+
377
+ <hoge fuga="foo&bar;&#38;&#x26;baz" >
378
+ ^ ^ ^ ^ ^ ^ ^ ^ ^
379
+ 1 2 3 4 5 6 7 8 9
380
+
381
+ method argument
382
+ ------------------------------------
383
+ 1: on_stag ('hoge')
384
+ 2: on_attribute ('fuga')
385
+ 3: on_attr_value ('foo')
386
+ 4: on_attr_entityref ('bar')
387
+ 5: on_attr_charref (38)
388
+ 6: on_attr_charref_hex (38)
389
+ 7: on_attr_value ('baz')
390
+ 8: on_attribute_end ('fuga')
391
+ 9: on_stag_end ('hoge')
392
+ or
393
+ on_stag_end_empty ('hoge')
394
+
395
+ ���ϥ�����ȯ��������硢on_stag �ȡ��б����� on_stag_end ����
396
+ on_stag_end_empty ��ɬ���ƤӽФ���ޤ���¾�Υ᥽�åɤϡ����ϥ�����
397
+ ���°��������ʤ��ä����ϸƤӽФ���ޤ���
398
+
399
+ en| When a start tag is found, both on_stag and corresponding
400
+ en| either on_stag_end or on_stag_end_empty method are always
401
+ en| called. Any other methods are called only when at least one
402
+ en| attribute is found in the start tag.
403
+
404
+ °����ȯ��������硢on_attribute �� on_attribute_end ��ɬ��
405
+ �ƤӽФ���ޤ���°���ͤ��� (fuga="") �λ��ϡ�����2�ĤΥ᥽�åɤΤߤ�
406
+ �ƤӽФ���ޤ���
407
+
408
+ en| When an attribute is found, both on_attribute and
409
+ en| on_attribute_end method are always called. If the attribute
410
+ en| value is empty, only these two methods are called.
411
+
412
+ on_attr_entityref ��°���ͤ���ǰ��̼��λ��Ȥ�ȯ����������
413
+ �ƤӽФ���ޤ���on_charref �ڤ� on_charref_hex ��°���ͤ����
414
+ ʸ�����Ȥ�ȯ���������˸ƤӽФ���ޤ���
415
+
416
+ en| When the parser meets a general entity reference in an
417
+ en| attribute value, it calls on_attr_entityref method.
418
+ en| When the parser meets a character reference in an attribute
419
+ en| value, it calls either on_charref or on_charref_hex method.
420
+
421
+ �����������ǥ������ä����ϡ�on_stag_end �᥽�åɤ������
422
+ on_stag_end_empty �᥽�åɤ��ƤӽФ���ޤ���
423
+
424
+ en| If the tag is an empty element tag, on_stag_end_empty method
425
+ en| is called instead of on_stag_end method.
426
+
427
+ --- XMLScan::Visitor#on_etag(name)
428
+
429
+ ��λ������ȯ���������˸ƤӽФ���ޤ���
430
+
431
+ en| Called when the parser meets an end tag.
432
+
433
+
434
+
435
+ === XMLScan::XMLScanner
436
+
437
+ XMLʸ��������Ϥ�����������ǧ�����륹����ʤǤ���
438
+
439
+ en| The scanner which tokenizes an XML document and recognize tags,
440
+ en| and so on.
441
+
442
+ XMLScan::XMLScanner �ε���Ŭ�����ˤĤ��Ƥϡ�¾��ʸ��ǽҤ٤Ƥ��ޤ���
443
+
444
+ en| The conformance of XMLScan::XMLScanner to the specification
445
+ en| is described in another document.
446
+
447
+ ==== �����ѡ����饹:
448
+ en| ==== SuperClass:
449
+
450
+ * Object
451
+
452
+ ==== ���饹�᥽�å�:
453
+ en| ==== Class Methods:
454
+
455
+ --- XMLScan::XMLScanner.new(visitor[, option ...])
456
+
457
+ XMLScan::XMLScanner ���֥������Ȥ��������ޤ���((|visitor|))��
458
+ XMLScan::Visitor �Υ��󥹥��󥹤ǡ�XMLScan::XMLScanner ���֥������Ȥ���
459
+ ���Ϸ�̤�������ޤ���
460
+
461
+ en| Creates an instance. ((|visitor|)) is a instance of
462
+ en| ((<XMLScan::Visitor>)) and receives the result of parsing
463
+ en| from the XMLScan::Scanner object.
464
+
465
+ ((|option|))��ʸ�������ϥ���ܥ�ǻ��ꤷ�ޤ���option�ˤ�
466
+ ���Τ�Τ�����ޤ���
467
+
468
+ en| You can specify one of more ((|option|)) as a string or symbol.
469
+ en| XMLScan::Scanner's options are as follows:
470
+
471
+ : 'strict_char'
472
+
473
+ (({require 'xmlscan/xmlchar'})) ����Ȼ���Ǥ���褦�ˤʤ�ޤ���
474
+ ������ʸ�����Ȥ��Ƥ��ʤ����ɤ����Υ����å���Ԥ��ޤ���
475
+ �ѥե����ޥ󥹤��������㲼���ޤ���
476
+
477
+ en| This option is enabled after
478
+ en| (({require 'xmlscan/xmlchar'})).
479
+ en| XMLScan::Scanner checks whether an XML document includes
480
+ en| an illegal character. The performance decreases sharply.
481
+
482
+ ==== �᥽�å�:
483
+ en| ==== Methods:
484
+
485
+ --- XMLScan::XMLScanner#kcode= arg
486
+
487
+ CES����ꤷ�ޤ���((|arg|))�β��ϡ�nil ������� $KCODE ��Ʊ���Ǥ���
488
+ ((|arg|))�� nil �ΤȤ��ϡ��ɤ� CES �Dz��Ϥ�Ԥ����� $KCODE ���ͤˤ�ä�
489
+ ��ޤ�ޤ���
490
+
491
+ en| Sets CES. Available values for ((|code|)) are same as $KCODE
492
+ en| except nil. If ((|code|)) is nil, $KCODE decides the CES.
493
+
494
+ --- XMLScan::XMLScanner#kcode
495
+
496
+ �ɤ� CES �Dz��Ϥ�Ԥ����� Regexp#kcode ��Ʊ���������֤��ޤ���
497
+ nil�ΤȤ���$KCODE�˰�¸���뤳�Ȥ�ɽ���ޤ���
498
+
499
+ en| Returns CES. The format of the return value is same as
500
+ en| Regexp#kcode. If this method returns nil, it represents that
501
+ en| $KCODE decides the CES.
502
+
503
+ --- XMLScan::XMLScanner#parse(source)
504
+
505
+ ((|source|)) ��XMLʸ��Ȥ��Ʋ��Ϥ��ޤ���((|source|)) ��ʸ����
506
+ ʸ������������� IO#gets ��Ʊ�������񤤤򤹤� gets �᥽�åɤ����
507
+ ���֥������ȤǤʤ���Фʤ�ޤ���
508
+
509
+ en| Parses ((|source|)) as an XML document. ((|source|)) must be
510
+ en| a string, an array of strings, or an object which responds to
511
+ en| gets method which behaves same as IO#gets does.
512
+
513
+
514
+ === XMLScan::XMLParser
515
+
516
+ �������򸡾ڤ��ʤ� XML parser �Ǥ���
517
+
518
+ en| The non-validating XML parser.
519
+
520
+ XMLScan::XMLParser �ε���Ŭ�����ˤĤ��Ƥϡ�¾��ʸ��ǽҤ٤Ƥ��ޤ���
521
+
522
+ en| The conformance of XMLScan::XMLParser to the specification
523
+ en| is described in another document.
524
+
525
+
526
+ ==== �����ѡ����饹:
527
+ en| ==== SuperClass:
528
+
529
+ * ((<XMLScan::XMLScanner>))
530
+
531
+ ==== ���饹�᥽�å�:
532
+ en| ==== Class Methods:
533
+
534
+ --- XMLScan::XMLParser.new(visitor[, option ...])
535
+
536
+ XMLScan::XMLParser ���֥������Ȥ�((|visitor|))�γƥ᥽�åɤˤĤ��ơ�
537
+ ���Τ��Ȥ��ݾڤ��ޤ���
538
+
539
+ en| XMLScan::XMLParser makes sure the following for each
540
+ en| method of ((|visitor|)):
541
+
542
+ : ((<XMLScan::Visitor#on_stag>))
543
+
544
+ ���Υ᥽�åɤ�ƤӽФ�����ˡ��б����� ((<XMLScan::Visitor#on_etag>))
545
+ �᥽�åɤ�ɬ���ƤӽФ��ޤ���
546
+
547
+ en| After calling this method, XMLScan::Parser always call
548
+ en| corresponding ((<XMLScan::Visitor#on_etag>)) method.
549
+
550
+ �ä��ơ����顼������Ԥ�ʤ���С���������XMLʸ��Ǥϵ��������ʤ�
551
+ �᥽�åɸƤӽФ���������������ޤ���
552
+
553
+ en| In addition, if you never intend error recovery, method calls
554
+ en| which must not be occurred in a well-formed XML document are
555
+ en| all suppressed.
556
+
557
+
558
+ === XMLScan::HTMLScanner
559
+
560
+ ((<XMLScan::XMLScanner>)) �򸵤ˤ��� HTML �ѡ����Ǥ���
561
+
562
+ en| An HTML parser based on ((<XMLScan::XMLScanner>)).
563
+
564
+ XMLScan::HTMLScanner �ε���Ŭ�����ˤĤ��Ƥϡ�¾��ʸ��ǽҤ٤Ƥ��ޤ���
565
+
566
+ en| The conformance of XMLScan::HTMLScanner to the specification
567
+ en| is described in another document.
568
+
569
+ ==== �����ѡ����饹:
570
+ en| ==== SuperClass:
571
+
572
+ * ((<XMLScan::XMLScanner>))
573
+
574
+ ==== ���饹�᥽�å�:
575
+ en| ==== Class Methods:
576
+
577
+ --- XMLScan::HTMLScanner.new(visitor[, option ...])
578
+
579
+ XMLScan::HTMLScanner ���֥������Ȥ�((|visitor|))�γƥ᥽�åɤˤĤ��ơ�
580
+ ���Τ��Ȥ��ݾڤ��ޤ���
581
+
582
+ en| XMLScan::HTMLScanner makes sure the following for each
583
+ en| method of ((|visitor|)):
584
+
585
+ : ((<XMLScan::Visitor#on_xmldecl>))
586
+ : ((<XMLScan::Visitor#on_xmldecl_version>))
587
+ : ((<XMLScan::Visitor#on_xmldecl_encoding>))
588
+ : ((<XMLScan::Visitor#on_xmldecl_standalone>))
589
+ : ((<XMLScan::Visitor#on_xmldecl_end>))
590
+
591
+ HTML �ˤ� XML�����¸�ߤ��ʤ��Τǡ������Υ᥽�åɤ�ƤӽФ����Ȥ�
592
+ ����ޤ���
593
+
594
+ en| An XML declaration never appears in an HTML document,
595
+ en| so XMLScan::HTMLScanner never calls these methods.
596
+
597
+ : ((<XMLScan::Visitor#on_stag_end_empty>))
598
+
599
+ HTML �ˤ϶����ǥ�����¸�ߤ��ʤ��Τǡ����Υ᥽�åɤ�ƤӽФ����Ȥ�
600
+ ����ޤ��󡣶����ǥ����ϲ��ϥ��顼�ˤʤ�ޤ���
601
+
602
+ en| An empty element tag never appears in an HTML document,
603
+ en| so XMLScan::HTMLScanner never calls this method.
604
+ en| An empty element tag causes a parse error.
605
+
606
+ : ((<XMLScan::Visitor#wellformed_error>))
607
+
608
+ HTML �ˤ�����������¸�ߤ��ʤ��Τǡ����Υ᥽�åɤ�ƤӽФ����Ȥ�
609
+ ����ޤ���
610
+
611
+ en| There is no well-formedness constraint for HTML,
612
+ en| so XMLScan::HTMLScanner never calls this method.
613
+
614
+ =end