libxml-ruby 1.1.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/error.rb CHANGED
@@ -1,88 +1,90 @@
1
- module LibXML
2
- module XML
3
- class Error
4
- # Verbose error handler
5
- VERBOSE_HANDLER = lambda do |error|
6
- STDERR << error.to_s << "\n"
7
- STDERR.flush
8
- end
9
-
10
- # Quiet error handler
11
- QUIET_HANDLER = lambda do |error|
12
- end
13
-
14
- def ==(other)
15
- eql?(other)
16
- end
17
-
18
- def eql?(other)
19
- self.code == other.code and
20
- self.domain == other.domain and
21
- self.message == other.message and
22
- self.level == other.level and
23
- self.file == other.file and
24
- self.line == other.line and
25
- self.str1 == other.str1 and
26
- self.str2 == other.str2 and
27
- self.str3 == other.str3 and
28
- self.int1 == other.int1 and
29
- self.int2 == other.int2 and
30
- self.ctxt == other.ctxt and
31
- self.node == other.node
32
- end
33
-
34
- def level_to_s
35
- case self.level
36
- when NONE
37
- ''
38
- when WARNING
39
- 'Warning:'
40
- when ERROR
41
- 'Error:'
42
- when FATAL
43
- 'Fatal error:'
44
- end
45
- end
46
-
47
- def domain_to_s
48
- const_map = Hash.new
49
- domains = self.class.constants.grep(/XML_FROM/)
50
- domains.each do |domain|
51
- human_name = domain.gsub(/XML_FROM_/, '')
52
- const_map[self.class.const_get(domain)] = human_name
53
- end
54
-
55
- const_map[self.domain]
56
- end
57
-
58
- def code_to_s
59
- const_map = Hash.new
60
- codes = self.class.constants -
61
- self.class.constants.grep(/XML_FROM/) -
62
- ["XML_ERR_NONE", "XML_ERR_WARNING", "XML_ERR_ERROR", "XML_ERR_FATAL"]
63
-
64
-
65
- codes.each do |code|
66
- human_name = code.gsub(/XML_ERR_/, '')
67
- const_map[self.class.const_get(code)] = human_name
68
- end
69
-
70
- const_map[self.code]
71
- end
72
-
73
- def to_s
74
- msg = super
75
- msg = msg ? msg.strip: ''
76
-
77
- if self.line
78
- sprintf("%s %s at %s:%d.", self.level_to_s, msg,
79
- self.file, self.line)
80
- else
81
- sprintf("%s %s.", self.level_to_s, msg)
82
- end
83
- end
84
- end
85
- end
86
- end
87
-
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class Error
6
+ # Verbose error handler
7
+ VERBOSE_HANDLER = lambda do |error|
8
+ STDERR << error.to_s << "\n"
9
+ STDERR.flush
10
+ end
11
+
12
+ # Quiet error handler
13
+ QUIET_HANDLER = lambda do |error|
14
+ end
15
+
16
+ def ==(other)
17
+ eql?(other)
18
+ end
19
+
20
+ def eql?(other)
21
+ self.code == other.code and
22
+ self.domain == other.domain and
23
+ self.message == other.message and
24
+ self.level == other.level and
25
+ self.file == other.file and
26
+ self.line == other.line and
27
+ self.str1 == other.str1 and
28
+ self.str2 == other.str2 and
29
+ self.str3 == other.str3 and
30
+ self.int1 == other.int1 and
31
+ self.int2 == other.int2 and
32
+ self.ctxt == other.ctxt and
33
+ self.node == other.node
34
+ end
35
+
36
+ def level_to_s
37
+ case self.level
38
+ when NONE
39
+ ''
40
+ when WARNING
41
+ 'Warning:'
42
+ when ERROR
43
+ 'Error:'
44
+ when FATAL
45
+ 'Fatal error:'
46
+ end
47
+ end
48
+
49
+ def domain_to_s
50
+ const_map = Hash.new
51
+ domains = self.class.constants.grep(/XML_FROM/)
52
+ domains.each do |domain|
53
+ human_name = domain.gsub(/XML_FROM_/, '')
54
+ const_map[self.class.const_get(domain)] = human_name
55
+ end
56
+
57
+ const_map[self.domain]
58
+ end
59
+
60
+ def code_to_s
61
+ const_map = Hash.new
62
+ codes = self.class.constants -
63
+ self.class.constants.grep(/XML_FROM/) -
64
+ ["XML_ERR_NONE", "XML_ERR_WARNING", "XML_ERR_ERROR", "XML_ERR_FATAL"]
65
+
66
+
67
+ codes.each do |code|
68
+ human_name = code.gsub(/XML_ERR_/, '')
69
+ const_map[self.class.const_get(code)] = human_name
70
+ end
71
+
72
+ const_map[self.code]
73
+ end
74
+
75
+ def to_s
76
+ msg = super
77
+ msg = msg ? msg.strip: ''
78
+
79
+ if self.line
80
+ sprintf("%s %s at %s:%d.", self.level_to_s, msg,
81
+ self.file, self.line)
82
+ else
83
+ sprintf("%s %s.", self.level_to_s, msg)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+
88
90
  LibXML::XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
@@ -1,76 +1,78 @@
1
- ## Provide hpricot API for libxml. Provided by Michael Guterl,
2
- ## inspired by http://thebogles.com/blog/an-hpricot-style-interface-to-libxml
3
- #
4
- #class String
5
- # def to_libxml_doc
6
- # xp = XML::Parser.new
7
- # xp.string = self
8
- # xp.parse
9
- # end
10
- #end
11
- #
12
- #module LibXML
13
- # module XML
14
- # class Document
15
- # alias :search :find
16
- # end
17
- #
18
- # class Node
19
- # # find the child node with the given xpath
20
- # def at(xpath)
21
- # self.find_first(xpath)
22
- # end
23
- #
24
- # # find the array of child nodes matching the given xpath
25
- # def search(xpath)
26
- # results = self.find(xpath).to_a
27
- # if block_given?
28
- # results.each do |result|
29
- # yield result
30
- # end
31
- # end
32
- # return results
33
- # end
34
- #
35
- # def /(xpath)
36
- # search(xpath)
37
- # end
38
- #
39
- # # return the inner contents of this node as a string
40
- # def inner_xml
41
- # child.to_s
42
- # end
43
- #
44
- # # alias for inner_xml
45
- # def inner_html
46
- # inner_xml
47
- # end
48
- #
49
- # # return this node and its contents as an xml string
50
- # def to_xml
51
- # self.to_s
52
- # end
53
- #
54
- # # alias for path
55
- # def xpath
56
- # self.path
57
- # end
58
- #
59
- # def find_with_default_ns(xpath_expr, namespace=nil)
60
- # find_base(xpath_expr, namespace || default_namespaces)
61
- # end
62
- #
63
- # def find_first_with_default_ns(xpath_expr, namespace=nil)
64
- # find_first_base(xpath_expr, namespace || default_namespaces)
65
- # end
66
- #
67
- ## alias_method :find_base, :find unless method_defined?(:find_base)
68
- ## alias_method :find, :find_with_default_ns
69
- ## alias_method :find_first_base, :find_first unless method_defined?(:find_first_base)
70
- ## alias_method :find_first, :find_first_with_default_ns
71
- ## alias :child? :first?
72
- ## alias :children? :first?
73
- ## alias :child :first
74
- # end
75
- # end
1
+ # encoding: UTF-8
2
+
3
+ ## Provide hpricot API for libxml. Provided by Michael Guterl,
4
+ ## inspired by http://thebogles.com/blog/an-hpricot-style-interface-to-libxml
5
+ #
6
+ #class String
7
+ # def to_libxml_doc
8
+ # xp = XML::Parser.new
9
+ # xp.string = self
10
+ # xp.parse
11
+ # end
12
+ #end
13
+ #
14
+ #module LibXML
15
+ # module XML
16
+ # class Document
17
+ # alias :search :find
18
+ # end
19
+ #
20
+ # class Node
21
+ # # find the child node with the given xpath
22
+ # def at(xpath)
23
+ # self.find_first(xpath)
24
+ # end
25
+ #
26
+ # # find the array of child nodes matching the given xpath
27
+ # def search(xpath)
28
+ # results = self.find(xpath).to_a
29
+ # if block_given?
30
+ # results.each do |result|
31
+ # yield result
32
+ # end
33
+ # end
34
+ # return results
35
+ # end
36
+ #
37
+ # def /(xpath)
38
+ # search(xpath)
39
+ # end
40
+ #
41
+ # # return the inner contents of this node as a string
42
+ # def inner_xml
43
+ # child.to_s
44
+ # end
45
+ #
46
+ # # alias for inner_xml
47
+ # def inner_html
48
+ # inner_xml
49
+ # end
50
+ #
51
+ # # return this node and its contents as an xml string
52
+ # def to_xml
53
+ # self.to_s
54
+ # end
55
+ #
56
+ # # alias for path
57
+ # def xpath
58
+ # self.path
59
+ # end
60
+ #
61
+ # def find_with_default_ns(xpath_expr, namespace=nil)
62
+ # find_base(xpath_expr, namespace || default_namespaces)
63
+ # end
64
+ #
65
+ # def find_first_with_default_ns(xpath_expr, namespace=nil)
66
+ # find_first_base(xpath_expr, namespace || default_namespaces)
67
+ # end
68
+ #
69
+ ## alias_method :find_base, :find unless method_defined?(:find_base)
70
+ ## alias_method :find, :find_with_default_ns
71
+ ## alias_method :find_first_base, :find_first unless method_defined?(:find_first_base)
72
+ ## alias_method :find_first, :find_first_with_default_ns
73
+ ## alias :child? :first?
74
+ ## alias :children? :first?
75
+ ## alias :child :first
76
+ # end
77
+ # end
76
78
  #end
@@ -1,94 +1,96 @@
1
- module LibXML
2
- module XML
3
- class HTMLParser
4
- # call-seq:
5
- # XML::HTMLParser.file(path) -> XML::HTMLParser
6
- # XML::HTMLParser.file(path, :encoding => XML::Encoding::UTF_8,
7
- # :options => XML::HTMLParser::Options::NOENT) -> XML::HTMLParser
8
- #
9
- # Creates a new parser by parsing the specified file or uri.
10
- #
11
- # You may provide an optional hash table to control how the
12
- # parsing is performed. Valid options are:
13
- #
14
- # encoding - The document encoding, defaults to nil. Valid values
15
- # are the encoding constants defined on XML::Encoding.
16
- # options - Parser options. Valid values are the constants defined on
17
- # XML::HTMLParser::Options. Mutliple options can be combined
18
- # by using Bitwise OR (|).
19
- def self.file(path, options = {})
20
- context = XML::HTMLParser::Context.file(path)
21
- context.encoding = options[:encoding] if options[:encoding]
22
- context.options = options[:options] if options[:options]
23
- self.new(context)
24
- end
25
-
26
- # call-seq:
27
- # XML::HTMLParser.io(io) -> XML::HTMLParser
28
- # XML::HTMLParser.io(io, :encoding => XML::Encoding::UTF_8,
29
- # :options => XML::HTMLParser::Options::NOENT
30
- # :base_uri="http://libxml.org") -> XML::HTMLParser
31
- #
32
- # Creates a new reader by parsing the specified io object.
33
- #
34
- # Parameters:
35
- #
36
- # io - io object that contains the xml to parser
37
- # base_uri - The base url for the parsed document.
38
- # encoding - The document encoding, defaults to nil. Valid values
39
- # are the encoding constants defined on XML::Encoding.
40
- # options - Parser options. Valid values are the constants defined on
41
- # XML::HTMLParser::Options. Mutliple options can be combined
42
- # by using Bitwise OR (|).
43
- def self.io(io, options = {})
44
- context = XML::HTMLParser::Context.io(io)
45
- context.base_uri = options[:base_uri] if options[:base_uri]
46
- context.encoding = options[:encoding] if options[:encoding]
47
- context.options = options[:options] if options[:options]
48
- self.new(context)
49
- end
50
-
51
- # call-seq:
52
- # XML::HTMLParser.string(string)
53
- # XML::HTMLParser.string(string, :encoding => XML::Encoding::UTF_8,
54
- # :options => XML::HTMLParser::Options::NOENT
55
- # :base_uri="http://libxml.org") -> XML::HTMLParser
56
- #
57
- # Creates a new parser by parsing the specified string.
58
- #
59
- # You may provide an optional hash table to control how the
60
- # parsing is performed. Valid options are:
61
- #
62
- # base_uri - The base url for the parsed document.
63
- # encoding - The document encoding, defaults to nil. Valid values
64
- # are the encoding constants defined on XML::Encoding.
65
- # options - Parser options. Valid values are the constants defined on
66
- # XML::HTMLParser::Options. Mutliple options can be combined
67
- # by using Bitwise OR (|).
68
- def self.string(string, options = {})
69
- context = XML::HTMLParser::Context.string(string)
70
- context.base_uri = options[:base_uri] if options[:base_uri]
71
- context.encoding = options[:encoding] if options[:encoding]
72
- context.options = options[:options] if options[:options]
73
- self.new(context)
74
- end
75
-
76
- # :enddoc:
77
-
78
- def file=(value)
79
- warn("XML::HTMLParser#file is deprecated. Use XML::HTMLParser.file instead")
80
- @context = XML::HTMLParser::Context.file(value)
81
- end
82
-
83
- def io=(value)
84
- warn("XML::HTMLParser#io is deprecated. Use XML::HTMLParser.io instead")
85
- @context = XML::HTMLParser::Context.io(value)
86
- end
87
-
88
- def string=(value)
89
- warn("XML::HTMLParser#string is deprecated. Use XML::HTMLParser.string instead")
90
- @context = XML::HTMLParser::Context.string(value)
91
- end
92
- end
93
- end
94
- end
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class HTMLParser
6
+ # call-seq:
7
+ # XML::HTMLParser.file(path) -> XML::HTMLParser
8
+ # XML::HTMLParser.file(path, :encoding => XML::Encoding::UTF_8,
9
+ # :options => XML::HTMLParser::Options::NOENT) -> XML::HTMLParser
10
+ #
11
+ # Creates a new parser by parsing the specified file or uri.
12
+ #
13
+ # You may provide an optional hash table to control how the
14
+ # parsing is performed. Valid options are:
15
+ #
16
+ # encoding - The document encoding, defaults to nil. Valid values
17
+ # are the encoding constants defined on XML::Encoding.
18
+ # options - Parser options. Valid values are the constants defined on
19
+ # XML::HTMLParser::Options. Mutliple options can be combined
20
+ # by using Bitwise OR (|).
21
+ def self.file(path, options = {})
22
+ context = XML::HTMLParser::Context.file(path)
23
+ context.encoding = options[:encoding] if options[:encoding]
24
+ context.options = options[:options] if options[:options]
25
+ self.new(context)
26
+ end
27
+
28
+ # call-seq:
29
+ # XML::HTMLParser.io(io) -> XML::HTMLParser
30
+ # XML::HTMLParser.io(io, :encoding => XML::Encoding::UTF_8,
31
+ # :options => XML::HTMLParser::Options::NOENT
32
+ # :base_uri="http://libxml.org") -> XML::HTMLParser
33
+ #
34
+ # Creates a new reader by parsing the specified io object.
35
+ #
36
+ # Parameters:
37
+ #
38
+ # io - io object that contains the xml to parser
39
+ # base_uri - The base url for the parsed document.
40
+ # encoding - The document encoding, defaults to nil. Valid values
41
+ # are the encoding constants defined on XML::Encoding.
42
+ # options - Parser options. Valid values are the constants defined on
43
+ # XML::HTMLParser::Options. Mutliple options can be combined
44
+ # by using Bitwise OR (|).
45
+ def self.io(io, options = {})
46
+ context = XML::HTMLParser::Context.io(io)
47
+ context.base_uri = options[:base_uri] if options[:base_uri]
48
+ context.encoding = options[:encoding] if options[:encoding]
49
+ context.options = options[:options] if options[:options]
50
+ self.new(context)
51
+ end
52
+
53
+ # call-seq:
54
+ # XML::HTMLParser.string(string)
55
+ # XML::HTMLParser.string(string, :encoding => XML::Encoding::UTF_8,
56
+ # :options => XML::HTMLParser::Options::NOENT
57
+ # :base_uri="http://libxml.org") -> XML::HTMLParser
58
+ #
59
+ # Creates a new parser by parsing the specified string.
60
+ #
61
+ # You may provide an optional hash table to control how the
62
+ # parsing is performed. Valid options are:
63
+ #
64
+ # base_uri - The base url for the parsed document.
65
+ # encoding - The document encoding, defaults to nil. Valid values
66
+ # are the encoding constants defined on XML::Encoding.
67
+ # options - Parser options. Valid values are the constants defined on
68
+ # XML::HTMLParser::Options. Mutliple options can be combined
69
+ # by using Bitwise OR (|).
70
+ def self.string(string, options = {})
71
+ context = XML::HTMLParser::Context.string(string)
72
+ context.base_uri = options[:base_uri] if options[:base_uri]
73
+ context.encoding = options[:encoding] if options[:encoding]
74
+ context.options = options[:options] if options[:options]
75
+ self.new(context)
76
+ end
77
+
78
+ # :enddoc:
79
+
80
+ def file=(value)
81
+ warn("XML::HTMLParser#file is deprecated. Use XML::HTMLParser.file instead")
82
+ @context = XML::HTMLParser::Context.file(value)
83
+ end
84
+
85
+ def io=(value)
86
+ warn("XML::HTMLParser#io is deprecated. Use XML::HTMLParser.io instead")
87
+ @context = XML::HTMLParser::Context.io(value)
88
+ end
89
+
90
+ def string=(value)
91
+ warn("XML::HTMLParser#string is deprecated. Use XML::HTMLParser.string instead")
92
+ @context = XML::HTMLParser::Context.string(value)
93
+ end
94
+ end
95
+ end
96
+ end