libxml-ruby 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/{CHANGES → HISTORY} +35 -0
  2. data/LICENSE +1 -0
  3. data/MANIFEST +165 -0
  4. data/{README → README.rdoc} +2 -2
  5. data/Rakefile +47 -147
  6. data/ext/libxml/libxml.c +17 -1
  7. data/ext/libxml/ruby_libxml.h +9 -1
  8. data/ext/libxml/ruby_xml_attr.c +3 -3
  9. data/ext/libxml/ruby_xml_attr_decl.c +32 -32
  10. data/ext/libxml/ruby_xml_attributes.c +1 -1
  11. data/ext/libxml/ruby_xml_cbg.c +1 -2
  12. data/ext/libxml/ruby_xml_document.c +26 -4
  13. data/ext/libxml/ruby_xml_dtd.c +3 -3
  14. data/ext/libxml/ruby_xml_encoding.c +92 -5
  15. data/ext/libxml/ruby_xml_encoding.h +4 -0
  16. data/ext/libxml/ruby_xml_namespace.c +2 -2
  17. data/ext/libxml/ruby_xml_node.c +14 -14
  18. data/ext/libxml/ruby_xml_parser_context.c +8 -8
  19. data/ext/libxml/ruby_xml_reader.c +98 -43
  20. data/ext/libxml/ruby_xml_sax2_handler.c +13 -1
  21. data/ext/libxml/ruby_xml_sax_parser.c +4 -5
  22. data/ext/libxml/ruby_xml_version.h +5 -5
  23. data/ext/libxml/ruby_xml_xpath_context.c +9 -6
  24. data/ext/libxml/ruby_xml_xpath_object.c +1 -1
  25. data/ext/vc/libxml_ruby.sln +4 -4
  26. data/lib/libxml.rb +29 -29
  27. data/lib/libxml/attr.rb +112 -110
  28. data/lib/libxml/attr_decl.rb +2 -0
  29. data/lib/libxml/attributes.rb +13 -11
  30. data/lib/libxml/document.rb +192 -190
  31. data/lib/libxml/error.rb +89 -87
  32. data/lib/libxml/hpricot.rb +77 -75
  33. data/lib/libxml/html_parser.rb +96 -94
  34. data/lib/libxml/namespace.rb +61 -59
  35. data/lib/libxml/namespaces.rb +37 -35
  36. data/lib/libxml/node.rb +398 -384
  37. data/lib/libxml/ns.rb +21 -19
  38. data/lib/libxml/parser.rb +366 -364
  39. data/lib/libxml/properties.rb +22 -20
  40. data/lib/libxml/reader.rb +2 -0
  41. data/lib/libxml/sax_callbacks.rb +179 -177
  42. data/lib/libxml/sax_parser.rb +57 -55
  43. data/lib/libxml/tree.rb +28 -26
  44. data/lib/libxml/xpath_object.rb +15 -13
  45. data/lib/xml.rb +16 -14
  46. data/lib/xml/libxml.rb +10 -8
  47. data/libxml-ruby.gemspec +50 -0
  48. data/script/benchmark/depixelate +634 -0
  49. data/script/benchmark/hamlet.xml +9055 -0
  50. data/script/benchmark/parsecount +170 -0
  51. data/script/benchmark/sock_entries.xml +507 -0
  52. data/script/benchmark/throughput +41 -0
  53. data/script/test +6 -0
  54. data/test/etc_doc_to_s.rb +21 -19
  55. data/test/ets_doc_file.rb +17 -15
  56. data/test/ets_doc_to_s.rb +23 -21
  57. data/test/ets_gpx.rb +28 -26
  58. data/test/ets_node_gc.rb +23 -21
  59. data/test/ets_tsr.rb +11 -9
  60. data/test/model/bands.iso-8859-1.xml +5 -0
  61. data/test/model/bands.utf-8.xml +5 -0
  62. data/test/rb-magic-comment.rb +33 -0
  63. data/test/tc_attr.rb +181 -170
  64. data/test/tc_attr_decl.rb +3 -1
  65. data/test/tc_attributes.rb +134 -132
  66. data/test/tc_deprecated_require.rb +13 -11
  67. data/test/tc_document.rb +119 -113
  68. data/test/tc_document_write.rb +186 -117
  69. data/test/tc_dtd.rb +125 -123
  70. data/test/tc_error.rb +3 -1
  71. data/test/tc_html_parser.rb +139 -137
  72. data/test/tc_namespace.rb +61 -58
  73. data/test/tc_namespaces.rb +176 -173
  74. data/test/tc_node.rb +257 -180
  75. data/test/tc_node_cdata.rb +51 -49
  76. data/test/tc_node_comment.rb +33 -30
  77. data/test/tc_node_copy.rb +42 -40
  78. data/test/tc_node_edit.rb +159 -157
  79. data/test/tc_node_text.rb +71 -69
  80. data/test/tc_node_write.rb +41 -16
  81. data/test/tc_node_xlink.rb +29 -26
  82. data/test/tc_parser.rb +335 -329
  83. data/test/tc_parser_context.rb +188 -185
  84. data/test/tc_properties.rb +39 -36
  85. data/test/tc_reader.rb +297 -283
  86. data/test/tc_relaxng.rb +54 -51
  87. data/test/tc_sax_parser.rb +275 -273
  88. data/test/tc_schema.rb +53 -51
  89. data/test/tc_traversal.rb +222 -220
  90. data/test/tc_xinclude.rb +21 -19
  91. data/test/tc_xml.rb +3 -1
  92. data/test/tc_xpath.rb +195 -193
  93. data/test/tc_xpath_context.rb +80 -78
  94. data/test/tc_xpath_expression.rb +38 -35
  95. data/test/tc_xpointer.rb +74 -72
  96. data/test/test_helper.rb +14 -0
  97. data/test/test_suite.rb +39 -33
  98. metadata +65 -105
  99. data/doc/css/normal.css +0 -182
  100. data/doc/img/raze-tiny.png +0 -0
  101. data/doc/img/red-cube.jpg +0 -0
  102. data/doc/img/xml-ruby.png +0 -0
  103. data/doc/index.xml +0 -43
  104. data/doc/install.xml +0 -77
  105. data/doc/layout.rhtml +0 -38
  106. data/doc/layout.xsl +0 -67
  107. data/doc/license.xml +0 -32
  108. data/doc/log/changelog.xml +0 -1324
  109. data/doc/log/changelog.xsl +0 -42
  110. data/ext/libxml/Makefile +0 -156
  111. data/ext/libxml/extconf.h +0 -5
  112. data/ext/libxml/libxml-ruby.so.a +0 -0
  113. data/ext/libxml/libxml.o +0 -0
  114. data/ext/libxml/libxml_ruby.so +0 -0
  115. data/ext/libxml/mkmf.log +0 -129
  116. data/ext/libxml/ruby_xml.o +0 -0
  117. data/ext/libxml/ruby_xml_attr.o +0 -0
  118. data/ext/libxml/ruby_xml_attr_decl.o +0 -0
  119. data/ext/libxml/ruby_xml_attributes.o +0 -0
  120. data/ext/libxml/ruby_xml_cbg.o +0 -0
  121. data/ext/libxml/ruby_xml_document.o +0 -0
  122. data/ext/libxml/ruby_xml_dtd.o +0 -0
  123. data/ext/libxml/ruby_xml_encoding.o +0 -0
  124. data/ext/libxml/ruby_xml_error.o +0 -0
  125. data/ext/libxml/ruby_xml_html_parser.o +0 -0
  126. data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
  127. data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
  128. data/ext/libxml/ruby_xml_input_cbg.o +0 -0
  129. data/ext/libxml/ruby_xml_io.o +0 -0
  130. data/ext/libxml/ruby_xml_namespace.o +0 -0
  131. data/ext/libxml/ruby_xml_namespaces.o +0 -0
  132. data/ext/libxml/ruby_xml_node.o +0 -0
  133. data/ext/libxml/ruby_xml_parser.o +0 -0
  134. data/ext/libxml/ruby_xml_parser_context.o +0 -0
  135. data/ext/libxml/ruby_xml_parser_options.o +0 -0
  136. data/ext/libxml/ruby_xml_reader.o +0 -0
  137. data/ext/libxml/ruby_xml_relaxng.o +0 -0
  138. data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
  139. data/ext/libxml/ruby_xml_sax_parser.o +0 -0
  140. data/ext/libxml/ruby_xml_schema.o +0 -0
  141. data/ext/libxml/ruby_xml_xinclude.o +0 -0
  142. data/ext/libxml/ruby_xml_xpath.o +0 -0
  143. data/ext/libxml/ruby_xml_xpath_context.o +0 -0
  144. data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
  145. data/ext/libxml/ruby_xml_xpath_object.o +0 -0
  146. data/ext/libxml/ruby_xml_xpointer.o +0 -0
data/lib/libxml/ns.rb CHANGED
@@ -1,20 +1,22 @@
1
- module LibXML
2
- module XML
3
- class NS < Namespace # :nodoc:
4
- def initialize(node, prefix, href)
5
- warn('The XML::NS class is deprecated. Use XML::Namespace instead.')
6
- super(node, href, prefix)
7
- end
8
-
9
- def href?
10
- warn('XML::NS#href? is deprecated. Use !XML::NS#href.nil? instead.')
11
- not self.href.nil?
12
- end
13
-
14
- def prefix?
15
- warn('XML::NS#prefix? is deprecated. Use !XML::NS#prefix?.nil? instead.')
16
- not self.previx.nil?
17
- end
18
- end
19
- end
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class NS < Namespace # :nodoc:
6
+ def initialize(node, prefix, href)
7
+ warn('The XML::NS class is deprecated. Use XML::Namespace instead.')
8
+ super(node, href, prefix)
9
+ end
10
+
11
+ def href?
12
+ warn('XML::NS#href? is deprecated. Use !XML::NS#href.nil? instead.')
13
+ not self.href.nil?
14
+ end
15
+
16
+ def prefix?
17
+ warn('XML::NS#prefix? is deprecated. Use !XML::NS#prefix?.nil? instead.')
18
+ not self.previx.nil?
19
+ end
20
+ end
21
+ end
20
22
  end
data/lib/libxml/parser.rb CHANGED
@@ -1,365 +1,367 @@
1
- module LibXML
2
- module XML
3
- class Parser
4
- # call-seq:
5
- # XML::Parser.document(document) -> XML::Parser
6
- #
7
- # Creates a new parser for the specified document.
8
- #
9
- # Parameters:
10
- #
11
- # document - A preparsed document.
12
- def self.document(doc)
13
- context = XML::Parser::Context.document(doc)
14
- self.new(context)
15
- end
16
-
17
- # call-seq:
18
- # XML::Parser.file(path) -> XML::Parser
19
- # XML::Parser.file(path, :encoding => XML::Encoding::UTF_8,
20
- # :options => XML::Parser::Options::NOENT) -> XML::Parser
21
- #
22
- # Creates a new parser for the specified file or uri.
23
- #
24
- # You may provide an optional hash table to control how the
25
- # parsing is performed. Valid options are:
26
- #
27
- # encoding - The document encoding, defaults to nil. Valid values
28
- # are the encoding constants defined on XML::Encoding.
29
- # options - Parser options. Valid values are the constants defined on
30
- # XML::Parser::Options. Mutliple options can be combined
31
- # by using Bitwise OR (|).
32
- def self.file(path, options = {})
33
- context = XML::Parser::Context.file(path)
34
- context.encoding = options[:encoding] if options[:encoding]
35
- context.options = options[:options] if options[:options]
36
- self.new(context)
37
- end
38
-
39
- # call-seq:
40
- # XML::Parser.io(io) -> XML::Parser
41
- # XML::Parser.io(io, :encoding => XML::Encoding::UTF_8,
42
- # :options => XML::Parser::Options::NOENT
43
- # :base_uri="http://libxml.org") -> XML::Parser
44
- #
45
- # Creates a new parser for the specified io object.
46
- #
47
- # Parameters:
48
- #
49
- # io - io object that contains the xml to parser
50
- # base_uri - The base url for the parsed document.
51
- # encoding - The document encoding, defaults to nil. Valid values
52
- # are the encoding constants defined on XML::Encoding.
53
- # options - Parser options. Valid values are the constants defined on
54
- # XML::Parser::Options. Mutliple options can be combined
55
- # by using Bitwise OR (|).
56
- def self.io(io, options = {})
57
- context = XML::Parser::Context.io(io)
58
- context.base_uri = options[:base_uri] if options[:base_uri]
59
- context.encoding = options[:encoding] if options[:encoding]
60
- context.options = options[:options] if options[:options]
61
- self.new(context)
62
- end
63
-
64
- # call-seq:
65
- # XML::Parser.string(string)
66
- # XML::Parser.string(string, :encoding => XML::Encoding::UTF_8,
67
- # :options => XML::Parser::Options::NOENT
68
- # :base_uri="http://libxml.org") -> XML::Parser
69
- #
70
- # Creates a new parser by parsing the specified string.
71
- #
72
- # You may provide an optional hash table to control how the
73
- # parsing is performed. Valid options are:
74
- #
75
- # base_uri - The base url for the parsed document.
76
- # encoding - The document encoding, defaults to nil. Valid values
77
- # are the encoding constants defined on XML::Encoding.
78
- # options - Parser options. Valid values are the constants defined on
79
- # XML::Parser::Options. Mutliple options can be combined
80
- # by using Bitwise OR (|).
81
- def self.string(string, options = {})
82
- context = XML::Parser::Context.string(string)
83
- context.base_uri = options[:base_uri] if options[:base_uri]
84
- context.encoding = options[:encoding] if options[:encoding]
85
- context.options = options[:options] if options[:options]
86
- self.new(context)
87
- end
88
-
89
- def self.register_error_handler(proc)
90
- warn('Parser.register_error_handler is deprecated. Use Error.set_handler instead')
91
- if proc.nil?
92
- Error.reset_handler
93
- else
94
- Error.set_handler(&proc)
95
- end
96
- end
97
-
98
- # :enddoc:
99
-
100
- # Bunch of deprecated methods that have moved to the XML module
101
- VERSION = XML::VERSION
102
- VERNUM = XML::VERNUM
103
-
104
- def document=(value)
105
- warn("XML::Parser#document= is deprecated. Use XML::Parser.document= instead")
106
- @context = XML::Parser::Context.document(value)
107
- end
108
-
109
- def file=(value)
110
- warn("XML::Parser#file is deprecated. Use XML::Parser.file instead")
111
- @context = XML::Parser::Context.file(value)
112
- end
113
-
114
- def filename=(value)
115
- warn("XML::Parser#filename is deprecated. Use XML::Parser.file instead")
116
- self.file = value
117
- end
118
-
119
- def io=(value)
120
- warn("XML::Parser#io is deprecated. Use XML::Parser.io instead")
121
- @context = XML::Parser::Context.io(value)
122
- end
123
-
124
- def string=(value)
125
- warn("XML::Parser#string is deprecated. Use XML::Parser.string instead")
126
- @context = XML::Parser::Context.string(value)
127
- end
128
-
129
- def self.enabled_automata?
130
- warn("XML::Parser.enabled_automata? has been deprecated. Use XML.enabled_automata? instead")
131
- XML.enabled_automata?
132
- end
133
-
134
- def self.enabled_c14n?
135
- warn("XML::Parser.enabled_c14n? has been deprecated. Use XML.enabled_c14n? instead")
136
- XML.enabled_c14n?
137
- end
138
-
139
- def self.enabled_catalog?
140
- warn("XML::Parser.enabled_catalog? has been deprecated. Use XML.enabled_catalog? instead")
141
- XML.enabled_catalog?
142
- end
143
-
144
- def self.enabled_debug?
145
- warn("XML::Parser.enabled_debug? has been deprecated. Use XML.enabled_debug? instead")
146
- XML.enabled_debug?
147
- end
148
-
149
- def self.enabled_docbook?
150
- warn("XML::Parser.enabled_docbook? has been deprecated. Use XML.enabled_docbook? instead")
151
- XML.enabled_docbook?
152
- end
153
-
154
- def self.enabled_ftp?
155
- warn("XML::Parser.enabled_ftp? has been deprecated. Use XML.enabled_ftp? instead")
156
- XML.enabled_ftp?
157
- end
158
-
159
- def self.enabled_http?
160
- warn("XML::Parser.enabled_http? has been deprecated. Use XML.enabled_http? instead")
161
- XML.enabled_http?
162
- end
163
-
164
- def self.enabled_html?
165
- warn("XML::Parser.enabled_html? has been deprecated. Use XML.enabled_html? instead")
166
- XML.enabled_html?
167
- end
168
-
169
- def self.enabled_iconv?
170
- warn("XML::Parser.enabled_iconv? has been deprecated. Use XML.enabled_iconv? instead")
171
- XML.enabled_iconv?
172
- end
173
-
174
- def self.enabled_memory_debug?
175
- warn("XML::Parser.enabled_memory_debug_location? has been deprecated. Use XML.enabled_memory_debug_location? instead")
176
- XML.enabled_memory_debug_location?
177
- end
178
-
179
- def self.enabled_regexp?
180
- warn("XML::Parser.enabled_regexp? has been deprecated. Use XML.enabled_regexp? instead")
181
- XML.enabled_regexp?
182
- end
183
-
184
- def self.enabled_schemas?
185
- warn("XML::Parser.enabled_schemas? has been deprecated. Use XML.enabled_schemas? instead")
186
- XML.enabled_schemas?
187
- end
188
-
189
- def self.enabled_thread?
190
- warn("XML::Parser.enabled_thread? has been deprecated. Use XML.enabled_thread? instead")
191
- XML.enabled_thread?
192
- end
193
-
194
- def self.enabled_unicode?
195
- warn("XML::Parser.enabled_unicode? has been deprecated. Use XML.enabled_unicode? instead")
196
- XML.enabled_unicode?
197
- end
198
-
199
- def self.enabled_xinclude?
200
- warn("XML::Parser.enabled_xinclude? has been deprecated. Use XML.enabled_xinclude? instead")
201
- XML.enabled_xinclude?
202
- end
203
-
204
- def self.enabled_xpath?
205
- warn("XML::Parser.enabled_xpath? has been deprecated. Use XML.enabled_xpath? instead")
206
- XML.enabled_xpath?
207
- end
208
-
209
- def self.enabled_xpointer?
210
- warn("XML::Parser.enabled_xpointer? has been deprecated. Use XML.enabled_xpointer? instead")
211
- XML.enabled_xpointer?
212
- end
213
-
214
- def self.enabled_zlib?
215
- warn("XML::Parser.enabled_zlib? has been deprecated. Use XML.enabled_zlib? instead")
216
- XML.enabled_zlib?
217
- end
218
-
219
- def self.catalog_dump
220
- warn("XML::Parser.catalog_dump has been deprecated. Use XML.catalog_dump instead")
221
- XML.catalog_dump
222
- end
223
-
224
- def self.catalog_remove
225
- warn("XML::Parser.catalog_remove has been deprecated. Use XML.catalog_remove instead")
226
- XML.catalog_remove
227
- end
228
-
229
- def self.check_lib_versions
230
- warn("XML::Parser.check_lib_versions has been deprecated. Use XML.check_lib_versions instead")
231
- XML.check_lib_versions
232
- end
233
-
234
- def self.debug_entities
235
- warn("XML::Parser.debug_entities has been deprecated. Use XML.debug_entities instead")
236
- XML.debug_entities
237
- end
238
-
239
- def self.debug_entities=(value)
240
- warn("XML::Parser.debug_entities_set has been deprecated. Use XML.debug_entities= value instead")
241
- XML.debug_entities= value
242
- end
243
-
244
- def self.default_compression
245
- warn("XML::Parser.default_compression has been deprecated. Use XML.default_compression instead")
246
- XML.default_compression
247
- end
248
-
249
- def self.default_compression=(value)
250
- warn("XML::Parser.default_compression= value has been deprecated. Use XML.default_compression= value instead")
251
- XML.default_compression= value
252
- end
253
-
254
- def self.default_keep_blanks
255
- warn("XML::Parser.default_keep_blanks has been deprecated. Use XML.default_keep_blanks instead")
256
- XML.default_keep_blanks
257
- end
258
-
259
- def self.default_keep_blanks=(value)
260
- warn("XML::Parser.default_keep_blanks= value has been deprecated. Use XML.default_keep_blanks= value instead")
261
- XML.default_keep_blanks= value
262
- end
263
-
264
- def self.default_load_external_dtd
265
- warn("XML::Parser.default_load_external_dtd has been deprecated. Use XML.default_load_external_dtd instead")
266
- XML.default_load_external_dtd
267
- end
268
-
269
- def self.default_load_external_dtd=(value)
270
- warn("XML::Parser.default_load_external_dtd= value has been deprecated. Use XML.default_load_external_dtd= value instead")
271
- XML.default_load_external_dtd= value
272
- end
273
-
274
- def self.default_line_numbers
275
- warn("XML::Parser.default_line_numbers has been deprecated. Use XML.default_line_numbers instead")
276
- XML.default_line_numbers
277
- end
278
-
279
- def self.default_line_numbers=(value)
280
- warn("XML::Parser.default_line_numbers= value has been deprecated. Use XML.default_line_numbers= value instead")
281
- XML.default_line_numbers= value
282
- end
283
-
284
- def self.default_pedantic_parser
285
- warn("XML::Parser.default_pedantic_parser has been deprecated. Use XML.default_pedantic_parser instead")
286
- XML.default_pedantic_parser
287
- end
288
-
289
- def self.default_pedantic_parser=(value)
290
- warn("XML::Parser.default_pedantic_parser= value has been deprecated. Use XML.default_pedantic_parser= value instead")
291
- XML.default_pedantic_parser= value
292
- end
293
-
294
- def self.default_substitute_entities
295
- warn("XML::Parser.default_substitute_entities has been deprecated. Use XML.default_substitute_entities instead")
296
- XML.default_substitute_entities
297
- end
298
-
299
- def self.default_substitute_entities=(value)
300
- warn("XML::Parser.default_substitute_entities= value has been deprecated. Use XML.default_substitute_entities= value instead")
301
- XML.default_substitute_entities= value
302
- end
303
-
304
- def self.default_tree_indent_string
305
- warn("XML::Parser.default_tree_indent_string has been deprecated. Use XML.default_tree_indent_string instead")
306
- XML.default_tree_indent_string
307
- end
308
-
309
- def self.default_tree_indent_string=(value)
310
- warn("XML::Parser.default_tree_indent_string= value has been deprecated. Use XML.default_tree_indent_string= value instead")
311
- XML.default_tree_indent_string= value
312
- end
313
-
314
- def self.default_validity_checking
315
- warn("XML::Parser.default_validity_checking has been deprecated. Use XML.default_validity_checking instead")
316
- XML.default_validity_checking
317
- end
318
-
319
- def self.default_validity_checking=(value)
320
- warn("XML::Parser.default_validity_checking= value has been deprecated. Use XML.default_validity_checking= value instead")
321
- XML.default_validity_checking= value
322
- end
323
-
324
- def self.default_warnings
325
- warn("XML::Parser.default_warnings has been deprecated. Use XML.default_warnings instead")
326
- XML.default_warnings
327
- end
328
-
329
- def self.default_warnings=(value)
330
- warn("XML::Parser.default_warnings= value has been deprecated. Use XML.default_warnings= value instead")
331
- XML.default_warnings= value
332
- end
333
-
334
- def self.features
335
- warn("XML::Parser.features has been deprecated. Use XML.features instead")
336
- XML.features
337
- end
338
-
339
- def self.indent_tree_output
340
- warn("XML::Parser.indent_tree_output has been deprecated. Use XML.indent_tree_output instead")
341
- XML.indent_tree_output
342
- end
343
-
344
- def self.indent_tree_output=(value)
345
- warn("XML::Parser.indent_tree_output= value has been deprecated. Use XML.indent_tree_output= value instead")
346
- XML.indent_tree_output= value
347
- end
348
-
349
- def self.filename(value)
350
- warn("Parser.filename is deprecated. Use Parser.file instead")
351
- self.file(value)
352
- end
353
-
354
- def self.memory_dump
355
- warn("XML::Parser.memory_dump has been deprecated. Use XML.memory_dump instead")
356
- XML.memory_dump
357
- end
358
-
359
- def self.memory_used
360
- warn("XML::Parser.memory_used has been deprecated. Use XML.memory_used instead")
361
- XML.memory_used
362
- end
363
- end
364
- end
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class Parser
6
+ # call-seq:
7
+ # XML::Parser.document(document) -> XML::Parser
8
+ #
9
+ # Creates a new parser for the specified document.
10
+ #
11
+ # Parameters:
12
+ #
13
+ # document - A preparsed document.
14
+ def self.document(doc)
15
+ context = XML::Parser::Context.document(doc)
16
+ self.new(context)
17
+ end
18
+
19
+ # call-seq:
20
+ # XML::Parser.file(path) -> XML::Parser
21
+ # XML::Parser.file(path, :encoding => XML::Encoding::UTF_8,
22
+ # :options => XML::Parser::Options::NOENT) -> XML::Parser
23
+ #
24
+ # Creates a new parser for the specified file or uri.
25
+ #
26
+ # You may provide an optional hash table to control how the
27
+ # parsing is performed. Valid options are:
28
+ #
29
+ # encoding - The document encoding, defaults to nil. Valid values
30
+ # are the encoding constants defined on XML::Encoding.
31
+ # options - Parser options. Valid values are the constants defined on
32
+ # XML::Parser::Options. Mutliple options can be combined
33
+ # by using Bitwise OR (|).
34
+ def self.file(path, options = {})
35
+ context = XML::Parser::Context.file(path)
36
+ context.encoding = options[:encoding] if options[:encoding]
37
+ context.options = options[:options] if options[:options]
38
+ self.new(context)
39
+ end
40
+
41
+ # call-seq:
42
+ # XML::Parser.io(io) -> XML::Parser
43
+ # XML::Parser.io(io, :encoding => XML::Encoding::UTF_8,
44
+ # :options => XML::Parser::Options::NOENT
45
+ # :base_uri="http://libxml.org") -> XML::Parser
46
+ #
47
+ # Creates a new parser for the specified io object.
48
+ #
49
+ # Parameters:
50
+ #
51
+ # io - io object that contains the xml to parser
52
+ # base_uri - The base url for the parsed document.
53
+ # encoding - The document encoding, defaults to nil. Valid values
54
+ # are the encoding constants defined on XML::Encoding.
55
+ # options - Parser options. Valid values are the constants defined on
56
+ # XML::Parser::Options. Mutliple options can be combined
57
+ # by using Bitwise OR (|).
58
+ def self.io(io, options = {})
59
+ context = XML::Parser::Context.io(io)
60
+ context.base_uri = options[:base_uri] if options[:base_uri]
61
+ context.encoding = options[:encoding] if options[:encoding]
62
+ context.options = options[:options] if options[:options]
63
+ self.new(context)
64
+ end
65
+
66
+ # call-seq:
67
+ # XML::Parser.string(string)
68
+ # XML::Parser.string(string, :encoding => XML::Encoding::UTF_8,
69
+ # :options => XML::Parser::Options::NOENT
70
+ # :base_uri="http://libxml.org") -> XML::Parser
71
+ #
72
+ # Creates a new parser by parsing the specified string.
73
+ #
74
+ # You may provide an optional hash table to control how the
75
+ # parsing is performed. Valid options are:
76
+ #
77
+ # base_uri - The base url for the parsed document.
78
+ # encoding - The document encoding, defaults to nil. Valid values
79
+ # are the encoding constants defined on XML::Encoding.
80
+ # options - Parser options. Valid values are the constants defined on
81
+ # XML::Parser::Options. Mutliple options can be combined
82
+ # by using Bitwise OR (|).
83
+ def self.string(string, options = {})
84
+ context = XML::Parser::Context.string(string)
85
+ context.base_uri = options[:base_uri] if options[:base_uri]
86
+ context.encoding = options[:encoding] if options[:encoding]
87
+ context.options = options[:options] if options[:options]
88
+ self.new(context)
89
+ end
90
+
91
+ def self.register_error_handler(proc)
92
+ warn('Parser.register_error_handler is deprecated. Use Error.set_handler instead')
93
+ if proc.nil?
94
+ Error.reset_handler
95
+ else
96
+ Error.set_handler(&proc)
97
+ end
98
+ end
99
+
100
+ # :enddoc:
101
+
102
+ # Bunch of deprecated methods that have moved to the XML module
103
+ VERSION = XML::VERSION
104
+ VERNUM = XML::VERNUM
105
+
106
+ def document=(value)
107
+ warn("XML::Parser#document= is deprecated. Use XML::Parser.document= instead")
108
+ @context = XML::Parser::Context.document(value)
109
+ end
110
+
111
+ def file=(value)
112
+ warn("XML::Parser#file is deprecated. Use XML::Parser.file instead")
113
+ @context = XML::Parser::Context.file(value)
114
+ end
115
+
116
+ def filename=(value)
117
+ warn("XML::Parser#filename is deprecated. Use XML::Parser.file instead")
118
+ self.file = value
119
+ end
120
+
121
+ def io=(value)
122
+ warn("XML::Parser#io is deprecated. Use XML::Parser.io instead")
123
+ @context = XML::Parser::Context.io(value)
124
+ end
125
+
126
+ def string=(value)
127
+ warn("XML::Parser#string is deprecated. Use XML::Parser.string instead")
128
+ @context = XML::Parser::Context.string(value)
129
+ end
130
+
131
+ def self.enabled_automata?
132
+ warn("XML::Parser.enabled_automata? has been deprecated. Use XML.enabled_automata? instead")
133
+ XML.enabled_automata?
134
+ end
135
+
136
+ def self.enabled_c14n?
137
+ warn("XML::Parser.enabled_c14n? has been deprecated. Use XML.enabled_c14n? instead")
138
+ XML.enabled_c14n?
139
+ end
140
+
141
+ def self.enabled_catalog?
142
+ warn("XML::Parser.enabled_catalog? has been deprecated. Use XML.enabled_catalog? instead")
143
+ XML.enabled_catalog?
144
+ end
145
+
146
+ def self.enabled_debug?
147
+ warn("XML::Parser.enabled_debug? has been deprecated. Use XML.enabled_debug? instead")
148
+ XML.enabled_debug?
149
+ end
150
+
151
+ def self.enabled_docbook?
152
+ warn("XML::Parser.enabled_docbook? has been deprecated. Use XML.enabled_docbook? instead")
153
+ XML.enabled_docbook?
154
+ end
155
+
156
+ def self.enabled_ftp?
157
+ warn("XML::Parser.enabled_ftp? has been deprecated. Use XML.enabled_ftp? instead")
158
+ XML.enabled_ftp?
159
+ end
160
+
161
+ def self.enabled_http?
162
+ warn("XML::Parser.enabled_http? has been deprecated. Use XML.enabled_http? instead")
163
+ XML.enabled_http?
164
+ end
165
+
166
+ def self.enabled_html?
167
+ warn("XML::Parser.enabled_html? has been deprecated. Use XML.enabled_html? instead")
168
+ XML.enabled_html?
169
+ end
170
+
171
+ def self.enabled_iconv?
172
+ warn("XML::Parser.enabled_iconv? has been deprecated. Use XML.enabled_iconv? instead")
173
+ XML.enabled_iconv?
174
+ end
175
+
176
+ def self.enabled_memory_debug?
177
+ warn("XML::Parser.enabled_memory_debug_location? has been deprecated. Use XML.enabled_memory_debug_location? instead")
178
+ XML.enabled_memory_debug_location?
179
+ end
180
+
181
+ def self.enabled_regexp?
182
+ warn("XML::Parser.enabled_regexp? has been deprecated. Use XML.enabled_regexp? instead")
183
+ XML.enabled_regexp?
184
+ end
185
+
186
+ def self.enabled_schemas?
187
+ warn("XML::Parser.enabled_schemas? has been deprecated. Use XML.enabled_schemas? instead")
188
+ XML.enabled_schemas?
189
+ end
190
+
191
+ def self.enabled_thread?
192
+ warn("XML::Parser.enabled_thread? has been deprecated. Use XML.enabled_thread? instead")
193
+ XML.enabled_thread?
194
+ end
195
+
196
+ def self.enabled_unicode?
197
+ warn("XML::Parser.enabled_unicode? has been deprecated. Use XML.enabled_unicode? instead")
198
+ XML.enabled_unicode?
199
+ end
200
+
201
+ def self.enabled_xinclude?
202
+ warn("XML::Parser.enabled_xinclude? has been deprecated. Use XML.enabled_xinclude? instead")
203
+ XML.enabled_xinclude?
204
+ end
205
+
206
+ def self.enabled_xpath?
207
+ warn("XML::Parser.enabled_xpath? has been deprecated. Use XML.enabled_xpath? instead")
208
+ XML.enabled_xpath?
209
+ end
210
+
211
+ def self.enabled_xpointer?
212
+ warn("XML::Parser.enabled_xpointer? has been deprecated. Use XML.enabled_xpointer? instead")
213
+ XML.enabled_xpointer?
214
+ end
215
+
216
+ def self.enabled_zlib?
217
+ warn("XML::Parser.enabled_zlib? has been deprecated. Use XML.enabled_zlib? instead")
218
+ XML.enabled_zlib?
219
+ end
220
+
221
+ def self.catalog_dump
222
+ warn("XML::Parser.catalog_dump has been deprecated. Use XML.catalog_dump instead")
223
+ XML.catalog_dump
224
+ end
225
+
226
+ def self.catalog_remove
227
+ warn("XML::Parser.catalog_remove has been deprecated. Use XML.catalog_remove instead")
228
+ XML.catalog_remove
229
+ end
230
+
231
+ def self.check_lib_versions
232
+ warn("XML::Parser.check_lib_versions has been deprecated. Use XML.check_lib_versions instead")
233
+ XML.check_lib_versions
234
+ end
235
+
236
+ def self.debug_entities
237
+ warn("XML::Parser.debug_entities has been deprecated. Use XML.debug_entities instead")
238
+ XML.debug_entities
239
+ end
240
+
241
+ def self.debug_entities=(value)
242
+ warn("XML::Parser.debug_entities_set has been deprecated. Use XML.debug_entities= value instead")
243
+ XML.debug_entities= value
244
+ end
245
+
246
+ def self.default_compression
247
+ warn("XML::Parser.default_compression has been deprecated. Use XML.default_compression instead")
248
+ XML.default_compression
249
+ end
250
+
251
+ def self.default_compression=(value)
252
+ warn("XML::Parser.default_compression= value has been deprecated. Use XML.default_compression= value instead")
253
+ XML.default_compression= value
254
+ end
255
+
256
+ def self.default_keep_blanks
257
+ warn("XML::Parser.default_keep_blanks has been deprecated. Use XML.default_keep_blanks instead")
258
+ XML.default_keep_blanks
259
+ end
260
+
261
+ def self.default_keep_blanks=(value)
262
+ warn("XML::Parser.default_keep_blanks= value has been deprecated. Use XML.default_keep_blanks= value instead")
263
+ XML.default_keep_blanks= value
264
+ end
265
+
266
+ def self.default_load_external_dtd
267
+ warn("XML::Parser.default_load_external_dtd has been deprecated. Use XML.default_load_external_dtd instead")
268
+ XML.default_load_external_dtd
269
+ end
270
+
271
+ def self.default_load_external_dtd=(value)
272
+ warn("XML::Parser.default_load_external_dtd= value has been deprecated. Use XML.default_load_external_dtd= value instead")
273
+ XML.default_load_external_dtd= value
274
+ end
275
+
276
+ def self.default_line_numbers
277
+ warn("XML::Parser.default_line_numbers has been deprecated. Use XML.default_line_numbers instead")
278
+ XML.default_line_numbers
279
+ end
280
+
281
+ def self.default_line_numbers=(value)
282
+ warn("XML::Parser.default_line_numbers= value has been deprecated. Use XML.default_line_numbers= value instead")
283
+ XML.default_line_numbers= value
284
+ end
285
+
286
+ def self.default_pedantic_parser
287
+ warn("XML::Parser.default_pedantic_parser has been deprecated. Use XML.default_pedantic_parser instead")
288
+ XML.default_pedantic_parser
289
+ end
290
+
291
+ def self.default_pedantic_parser=(value)
292
+ warn("XML::Parser.default_pedantic_parser= value has been deprecated. Use XML.default_pedantic_parser= value instead")
293
+ XML.default_pedantic_parser= value
294
+ end
295
+
296
+ def self.default_substitute_entities
297
+ warn("XML::Parser.default_substitute_entities has been deprecated. Use XML.default_substitute_entities instead")
298
+ XML.default_substitute_entities
299
+ end
300
+
301
+ def self.default_substitute_entities=(value)
302
+ warn("XML::Parser.default_substitute_entities= value has been deprecated. Use XML.default_substitute_entities= value instead")
303
+ XML.default_substitute_entities= value
304
+ end
305
+
306
+ def self.default_tree_indent_string
307
+ warn("XML::Parser.default_tree_indent_string has been deprecated. Use XML.default_tree_indent_string instead")
308
+ XML.default_tree_indent_string
309
+ end
310
+
311
+ def self.default_tree_indent_string=(value)
312
+ warn("XML::Parser.default_tree_indent_string= value has been deprecated. Use XML.default_tree_indent_string= value instead")
313
+ XML.default_tree_indent_string= value
314
+ end
315
+
316
+ def self.default_validity_checking
317
+ warn("XML::Parser.default_validity_checking has been deprecated. Use XML.default_validity_checking instead")
318
+ XML.default_validity_checking
319
+ end
320
+
321
+ def self.default_validity_checking=(value)
322
+ warn("XML::Parser.default_validity_checking= value has been deprecated. Use XML.default_validity_checking= value instead")
323
+ XML.default_validity_checking= value
324
+ end
325
+
326
+ def self.default_warnings
327
+ warn("XML::Parser.default_warnings has been deprecated. Use XML.default_warnings instead")
328
+ XML.default_warnings
329
+ end
330
+
331
+ def self.default_warnings=(value)
332
+ warn("XML::Parser.default_warnings= value has been deprecated. Use XML.default_warnings= value instead")
333
+ XML.default_warnings= value
334
+ end
335
+
336
+ def self.features
337
+ warn("XML::Parser.features has been deprecated. Use XML.features instead")
338
+ XML.features
339
+ end
340
+
341
+ def self.indent_tree_output
342
+ warn("XML::Parser.indent_tree_output has been deprecated. Use XML.indent_tree_output instead")
343
+ XML.indent_tree_output
344
+ end
345
+
346
+ def self.indent_tree_output=(value)
347
+ warn("XML::Parser.indent_tree_output= value has been deprecated. Use XML.indent_tree_output= value instead")
348
+ XML.indent_tree_output= value
349
+ end
350
+
351
+ def self.filename(value)
352
+ warn("Parser.filename is deprecated. Use Parser.file instead")
353
+ self.file(value)
354
+ end
355
+
356
+ def self.memory_dump
357
+ warn("XML::Parser.memory_dump has been deprecated. Use XML.memory_dump instead")
358
+ XML.memory_dump
359
+ end
360
+
361
+ def self.memory_used
362
+ warn("XML::Parser.memory_used has been deprecated. Use XML.memory_used instead")
363
+ XML.memory_used
364
+ end
365
+ end
366
+ end
365
367
  end