libxml-ruby 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/CHANGES +53 -0
  2. data/Rakefile +1 -0
  3. data/ext/libxml/build.log +4 -0
  4. data/ext/libxml/cbg.c +86 -86
  5. data/ext/libxml/libxml.c +878 -876
  6. data/ext/libxml/ruby_libxml.h +8 -4
  7. data/ext/libxml/ruby_xml_attr.c +36 -168
  8. data/ext/libxml/ruby_xml_attr.h +2 -4
  9. data/ext/libxml/ruby_xml_attr_decl.c +177 -0
  10. data/ext/libxml/ruby_xml_attr_decl.h +13 -0
  11. data/ext/libxml/ruby_xml_attributes.c +29 -20
  12. data/ext/libxml/ruby_xml_document.c +895 -898
  13. data/ext/libxml/ruby_xml_dtd.c +18 -1
  14. data/ext/libxml/ruby_xml_dtd.h +1 -0
  15. data/ext/libxml/ruby_xml_encoding.c +116 -0
  16. data/ext/libxml/ruby_xml_encoding.h +12 -0
  17. data/ext/libxml/ruby_xml_error.c +8 -2
  18. data/ext/libxml/ruby_xml_html_parser.c +53 -74
  19. data/ext/libxml/ruby_xml_html_parser.h +2 -3
  20. data/ext/libxml/ruby_xml_html_parser_context.c +145 -0
  21. data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
  22. data/ext/libxml/ruby_xml_html_parser_options.c +48 -0
  23. data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
  24. data/ext/libxml/ruby_xml_input_cbg.c +1 -1
  25. data/ext/libxml/ruby_xml_io.c +30 -0
  26. data/ext/libxml/ruby_xml_io.h +9 -0
  27. data/ext/libxml/ruby_xml_namespace.c +34 -16
  28. data/ext/libxml/ruby_xml_namespace.h +2 -2
  29. data/ext/libxml/ruby_xml_namespaces.c +6 -6
  30. data/ext/libxml/ruby_xml_node.c +1367 -1324
  31. data/ext/libxml/ruby_xml_node.h +2 -2
  32. data/ext/libxml/ruby_xml_parser.c +26 -78
  33. data/ext/libxml/ruby_xml_parser.h +1 -1
  34. data/ext/libxml/ruby_xml_parser_context.c +284 -13
  35. data/ext/libxml/ruby_xml_parser_context.h +1 -2
  36. data/ext/libxml/ruby_xml_parser_options.c +75 -0
  37. data/ext/libxml/ruby_xml_parser_options.h +14 -0
  38. data/ext/libxml/ruby_xml_reader.c +277 -183
  39. data/ext/libxml/ruby_xml_sax_parser.c +60 -57
  40. data/ext/libxml/ruby_xml_xpath_context.c +43 -8
  41. data/ext/libxml/ruby_xml_xpath_expression.c +6 -0
  42. data/ext/libxml/ruby_xml_xpath_object.c +107 -95
  43. data/ext/libxml/ruby_xml_xpath_object.h +9 -1
  44. data/ext/libxml/ruby_xml_xpointer.c +107 -107
  45. data/ext/libxml/version.h +2 -2
  46. data/ext/vc/libxml_ruby.vcproj +43 -3
  47. data/lib/libxml.rb +2 -3
  48. data/lib/libxml/attr.rb +71 -2
  49. data/lib/libxml/attr_decl.rb +81 -0
  50. data/lib/libxml/document.rb +78 -14
  51. data/lib/libxml/html_parser.rb +75 -42
  52. data/lib/libxml/node.rb +11 -0
  53. data/lib/libxml/parser.rb +106 -62
  54. data/lib/libxml/reader.rb +12 -0
  55. data/lib/libxml/sax_parser.rb +42 -52
  56. data/lib/libxml/xpath_object.rb +15 -0
  57. data/test/model/atom.xml +12 -12
  58. data/test/model/bands.xml +4 -4
  59. data/test/model/books.xml +146 -147
  60. data/test/model/merge_bug_data.xml +1 -1
  61. data/test/model/rubynet.xml +1 -0
  62. data/test/model/shiporder.rng +1 -1
  63. data/test/model/shiporder.xml +22 -22
  64. data/test/model/shiporder.xsd +30 -30
  65. data/test/model/xinclude.xml +1 -1
  66. data/test/{tc_node_attr.rb → tc_attr.rb} +1 -1
  67. data/test/tc_attr_decl.rb +131 -0
  68. data/test/tc_deprecated_require.rb +1 -3
  69. data/test/tc_document.rb +13 -3
  70. data/test/tc_document_write.rb +5 -5
  71. data/test/tc_dtd.rb +13 -5
  72. data/test/tc_html_parser.rb +14 -26
  73. data/test/tc_node_cdata.rb +1 -3
  74. data/test/tc_node_comment.rb +2 -4
  75. data/test/tc_node_edit.rb +2 -3
  76. data/test/tc_node_text.rb +35 -1
  77. data/test/tc_node_write.rb +3 -3
  78. data/test/tc_node_xlink.rb +2 -4
  79. data/test/tc_parser.rb +163 -70
  80. data/test/tc_parser_context.rb +103 -42
  81. data/test/tc_reader.rb +173 -45
  82. data/test/tc_relaxng.rb +2 -2
  83. data/test/tc_sax_parser.rb +48 -52
  84. data/test/tc_schema.rb +2 -2
  85. data/test/tc_xpath.rb +37 -6
  86. data/test/tc_xpath_context.rb +7 -1
  87. data/test/tc_xpath_expression.rb +1 -3
  88. data/test/tc_xpointer.rb +1 -3
  89. data/test/test_suite.rb +2 -3
  90. metadata +20 -13
  91. data/ext/libxml/ruby_xml_input.c +0 -329
  92. data/ext/libxml/ruby_xml_input.h +0 -20
  93. data/lib/libxml/parser_context.rb +0 -17
  94. data/lib/libxml/parser_options.rb +0 -25
  95. data/test/model/simple.xml +0 -7
  96. data/test/tc_input.rb +0 -13
  97. data/test/tc_well_formed.rb +0 -11
@@ -1,4 +1,4 @@
1
- <?xml version="1.0"?>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
2
  <template>
3
3
  <body>
4
4
  <section>
@@ -1,3 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
1
2
  <rubynet xmlns:xlink="http://www.w3.org/1999/xlink">
2
3
  <pkg version="1.0">
3
4
  <meta>
@@ -1,4 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
2
  <!--
3
3
 
4
4
  relax ng schema in compact syntax; this cannot be used within libxml but
@@ -1,23 +1,23 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <shiporder orderid="889923"
3
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
- xsi:noNamespaceSchemaLocation="shiporder.xsd">
5
- <orderperson>John Smith</orderperson>
6
- <shipto>
7
- <name>Ola Nordmann</name>
8
- <address>Langgt 23</address>
9
- <city>4000 Stavanger</city>
10
- <country>Norway</country>
11
- </shipto>
12
- <item>
13
- <title>Empire Burlesque</title>
14
- <note>Special Edition</note>
15
- <quantity>1</quantity>
16
- <price>10.90</price>
17
- </item>
18
- <item>
19
- <title>Hide your heart</title>
20
- <quantity>1</quantity>
21
- <price>9.90</price>
22
- </item>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <shiporder orderid="889923"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:noNamespaceSchemaLocation="shiporder.xsd">
5
+ <orderperson>John Smith</orderperson>
6
+ <shipto>
7
+ <name>Ola Nordmann</name>
8
+ <address>Langgt 23</address>
9
+ <city>4000 Stavanger</city>
10
+ <country>Norway</country>
11
+ </shipto>
12
+ <item>
13
+ <title>Empire Burlesque</title>
14
+ <note>Special Edition</note>
15
+ <quantity>1</quantity>
16
+ <price>10.90</price>
17
+ </item>
18
+ <item>
19
+ <title>Hide your heart</title>
20
+ <quantity>1</quantity>
21
+ <price>9.90</price>
22
+ </item>
23
23
  </shiporder>
@@ -1,31 +1,31 @@
1
- <?xml version="1.0" encoding="iso-8859-1" ?>
2
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
- <xs:element name="shiporder">
4
- <xs:complexType>
5
- <xs:sequence>
6
- <xs:element name="orderperson" type="xs:string"/>
7
- <xs:element name="shipto">
8
- <xs:complexType>
9
- <xs:sequence>
10
- <xs:element name="name" type="xs:string"/>
11
- <xs:element name="address" type="xs:string"/>
12
- <xs:element name="city" type="xs:string"/>
13
- <xs:element name="country" type="xs:string"/>
14
- </xs:sequence>
15
- </xs:complexType>
16
- </xs:element>
17
- <xs:element name="item" maxOccurs="unbounded">
18
- <xs:complexType>
19
- <xs:sequence>
20
- <xs:element name="title" type="xs:string"/>
21
- <xs:element name="note" type="xs:string" minOccurs="0"/>
22
- <xs:element name="quantity" type="xs:positiveInteger"/>
23
- <xs:element name="price" type="xs:decimal"/>
24
- </xs:sequence>
25
- </xs:complexType>
26
- </xs:element>
27
- </xs:sequence>
28
- <xs:attribute name="orderid" type="xs:string" use="required"/>
29
- </xs:complexType>
30
- </xs:element>
1
+ <?xml version="1.0" encoding="iso-8859-1" ?>
2
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
+ <xs:element name="shiporder">
4
+ <xs:complexType>
5
+ <xs:sequence>
6
+ <xs:element name="orderperson" type="xs:string"/>
7
+ <xs:element name="shipto">
8
+ <xs:complexType>
9
+ <xs:sequence>
10
+ <xs:element name="name" type="xs:string"/>
11
+ <xs:element name="address" type="xs:string"/>
12
+ <xs:element name="city" type="xs:string"/>
13
+ <xs:element name="country" type="xs:string"/>
14
+ </xs:sequence>
15
+ </xs:complexType>
16
+ </xs:element>
17
+ <xs:element name="item" maxOccurs="unbounded">
18
+ <xs:complexType>
19
+ <xs:sequence>
20
+ <xs:element name="title" type="xs:string"/>
21
+ <xs:element name="note" type="xs:string" minOccurs="0"/>
22
+ <xs:element name="quantity" type="xs:positiveInteger"/>
23
+ <xs:element name="price" type="xs:decimal"/>
24
+ </xs:sequence>
25
+ </xs:complexType>
26
+ </xs:element>
27
+ </xs:sequence>
28
+ <xs:attribute name="orderid" type="xs:string" use="required"/>
29
+ </xs:complexType>
30
+ </xs:element>
31
31
  </xs:schema>
@@ -2,4 +2,4 @@
2
2
  <document xmlns:xi="http://www.w3.org/2001/XInclude">
3
3
  <p>This libxml2 binding has the following project information:
4
4
  <code><xi:include href="rubynet_project" parse="text"/></code></p>
5
- </document>
5
+ </document>
@@ -1,4 +1,4 @@
1
- require "xml"
1
+ require 'xml'
2
2
  require 'test/unit'
3
3
 
4
4
  class AttrNodeTest < Test::Unit::TestCase
@@ -0,0 +1,131 @@
1
+ require 'xml'
2
+ require 'test/unit'
3
+
4
+ class AttrDeclTest < Test::Unit::TestCase
5
+ def setup
6
+ xp = XML::Parser.string(<<-EOS)
7
+ <!DOCTYPE test [
8
+ <!ELEMENT root (property*)>
9
+ <!ELEMENT property EMPTY>
10
+ <!ATTLIST property name NMTOKEN #REQUIRED>
11
+ <!ATTLIST property access (r | w | rw) "rw">
12
+ ]>
13
+ <root>
14
+ <property name="readonly" access="r" />
15
+ <property name="readwrite" />
16
+ </root>
17
+ EOS
18
+ @doc = xp.parse
19
+ end
20
+
21
+ def teardown
22
+ @doc = nil
23
+ end
24
+
25
+ def test_attributes
26
+ # Get a element with an access attribute
27
+ elem = @doc.find_first('/root/property[@name="readonly"]')
28
+ assert_equal(2, elem.attributes.length)
29
+ assert_not_nil(elem['access'])
30
+
31
+ # Get a element node without a access attribute
32
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
33
+ assert_equal(1, elem.attributes.length)
34
+ assert_nil(elem['access'])
35
+ end
36
+
37
+ def test_attr
38
+ # Get a property node without a access attribute
39
+ elem = @doc.find_first('/root/property[@name="readonly"]')
40
+
41
+ # Get the attr_decl
42
+ attr = elem.attributes.get_attribute('access')
43
+ assert_not_nil(attr)
44
+ assert_equal(XML::Node::ATTRIBUTE_NODE, attr.node_type)
45
+ assert_equal('attribute', attr.node_type_name)
46
+
47
+ # Get its value
48
+ assert_equal('r', attr.value)
49
+ end
50
+
51
+ def test_attr_decl
52
+ # Get a property node without a access attribute
53
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
54
+
55
+ # Get the attr_decl
56
+ attr_decl = elem.attributes.get_attribute('access')
57
+ assert_not_nil(attr_decl)
58
+ assert_equal(XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
59
+ assert_equal('attribute declaration', attr_decl.node_type_name)
60
+
61
+ # Get its value
62
+ assert_equal('rw', attr_decl.value)
63
+ end
64
+
65
+ def test_type
66
+ # Get a property node without a access attribute
67
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
68
+ attr_decl = elem.attributes.get_attribute('access')
69
+
70
+ assert_not_nil(attr_decl)
71
+ assert_equal(XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
72
+ assert_equal('attribute declaration', attr_decl.node_type_name)
73
+ end
74
+
75
+ def test_name
76
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
77
+ attr_decl = elem.attributes.get_attribute('access')
78
+
79
+ assert_equal('access', attr_decl.name)
80
+ end
81
+
82
+ def test_value
83
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
84
+ attr_decl = elem.attributes.get_attribute('access')
85
+
86
+ assert_equal('rw', attr_decl.value)
87
+ end
88
+
89
+ def test_to_s
90
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
91
+ attr_decl = elem.attributes.get_attribute('access')
92
+
93
+ assert_equal('access = rw', attr_decl.to_s)
94
+ end
95
+
96
+ def test_prev
97
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
98
+ attr_decl = elem.attributes.get_attribute('access')
99
+
100
+ first_decl = attr_decl.prev
101
+ assert_equal(XML::Node::ATTRIBUTE_DECL, first_decl.node_type)
102
+ assert_equal('name', first_decl.name)
103
+ assert_nil(first_decl.value)
104
+
105
+ elem_decl = first_decl.prev
106
+ assert_equal(XML::Node::ELEMENT_DECL, elem_decl.node_type)
107
+ end
108
+
109
+ def test_next
110
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
111
+ attr_decl = elem.attributes.get_attribute('access')
112
+
113
+ next_decl = attr_decl.next
114
+ assert_nil(next_decl)
115
+ end
116
+
117
+ def test_doc
118
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
119
+ attr_decl = elem.attributes.get_attribute('access')
120
+
121
+ assert_same(@doc, attr_decl.doc)
122
+ end
123
+
124
+ def test_parent
125
+ elem = @doc.find_first('/root/property[@name="readwrite"]')
126
+ attr_decl = elem.attributes.get_attribute('access')
127
+
128
+ parent = attr_decl.parent
129
+ assert_instance_of(XML::Dtd, parent)
130
+ end
131
+ end
@@ -3,10 +3,8 @@ require 'test/unit'
3
3
 
4
4
  class TestDeprecatedRequire < Test::Unit::TestCase
5
5
  def test_basic
6
- xp = XML::Parser.new
6
+ xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
7
7
  assert_instance_of(XML::Parser, xp)
8
- str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
9
- assert_equal(str, xp.string = str)
10
8
  @doc = xp.parse
11
9
  assert_instance_of(XML::Document, @doc)
12
10
  end
@@ -4,10 +4,8 @@ require 'test/unit'
4
4
 
5
5
  class TestDocument < Test::Unit::TestCase
6
6
  def setup
7
- xp = XML::Parser.new
7
+ xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
8
8
  assert_instance_of(XML::Parser, xp)
9
- str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
10
- assert_equal(str, xp.string = str)
11
9
  @doc = xp.parse
12
10
  assert_instance_of(XML::Document, @doc)
13
11
  end
@@ -73,4 +71,16 @@ class TestDocument < Test::Unit::TestCase
73
71
  assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rubynet/>\n",
74
72
  @doc.to_s(:indent => false))
75
73
  end
74
+
75
+ def test_encoding
76
+ doc = XML::Document.new
77
+ assert_equal(XML::Encoding::NONE, doc.encoding)
78
+
79
+ file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.xml'))
80
+ doc = XML::Document.file(file)
81
+ assert_equal(XML::Encoding::UTF_8, doc.encoding)
82
+
83
+ doc.encoding = XML::Encoding::ISO_8859_1
84
+ assert_equal(XML::Encoding::ISO_8859_1, doc.encoding)
85
+ end
76
86
  end
@@ -44,20 +44,20 @@ class TestDocumentWrite < Test::Unit::TestCase
44
44
  # ö - c3 b6 in hex, \303\266 in octal
45
45
  # ü - c3 bc in hex, \303\274 in octal
46
46
  assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
47
- @doc.to_s(:encoding => XML::Input::UTF_8))
47
+ @doc.to_s(:encoding => XML::Encoding::UTF_8))
48
48
 
49
49
  # ISO_8859_1:
50
50
  # ö - f6 in hex, \366 in octal
51
51
  # ü - fc in hex, \374 in octal
52
52
  assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\">\n <m\366tley_cr\374e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\366tley_cr\374e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
53
- @doc.to_s(:encoding => XML::Input::ISO_8859_1))
53
+ @doc.to_s(:encoding => XML::Encoding::ISO_8859_1))
54
54
 
55
55
 
56
56
  # Invalid encoding
57
57
  error = assert_raise(ArgumentError) do
58
58
  @doc.to_s(:encoding => -9999)
59
59
  end
60
- assert_equal('Unknown encoding.', error.to_s)
60
+ assert_equal('Unknown encoding value: -9999', error.to_s)
61
61
  end
62
62
 
63
63
  # --- save tests -----
@@ -89,7 +89,7 @@ class TestDocumentWrite < Test::Unit::TestCase
89
89
 
90
90
  def test_save_iso_8859_1
91
91
  temp_filename = File.join(Dir.tmpdir, "tc_document_write_test_save_iso_8859_1.xml")
92
- bytes = @doc.save(temp_filename, :encoding => XML::Input::ISO_8859_1)
92
+ bytes = @doc.save(temp_filename, :encoding => XML::Encoding::ISO_8859_1)
93
93
  assert_equal(272, bytes)
94
94
 
95
95
  contents = File.read(temp_filename)
@@ -101,7 +101,7 @@ class TestDocumentWrite < Test::Unit::TestCase
101
101
 
102
102
  def test_save_iso_8859_1_no_indent
103
103
  temp_filename = File.join(Dir.tmpdir, "tc_document_write_test_save_iso_8859_1_no_indent.xml")
104
- bytes = @doc.save(temp_filename, :indent => false, :encoding => XML::Input::ISO_8859_1)
104
+ bytes = @doc.save(temp_filename, :indent => false, :encoding => XML::Encoding::ISO_8859_1)
105
105
  assert_equal(265, bytes)
106
106
 
107
107
  contents = File.read(temp_filename)
@@ -58,7 +58,7 @@ class TestDtd < Test::Unit::TestCase
58
58
  assert_not_nil(error.node)
59
59
  assert_equal('invalid', error.node.name)
60
60
  end
61
-
61
+
62
62
  def test_external_dtd
63
63
  xml = <<-EOS
64
64
  <!DOCTYPE test PUBLIC "-//TEST" "test.dtd" []>
@@ -74,13 +74,21 @@ class TestDtd < Test::Unit::TestCase
74
74
 
75
75
  XML.default_load_external_dtd = false
76
76
  doc = XML::Parser.string(xml).parse
77
- assert_equal(Array.new, errors)
77
+ assert_equal(0, errors.length)
78
78
 
79
+ errors = Array.new
79
80
  XML.default_load_external_dtd = true
80
81
  doc = XML::Parser.string(xml).parse
82
+ assert_equal(1, errors.length)
83
+ assert_equal("Warning: failed to load external entity \"test.dtd\" at :1.",
84
+ errors[0].to_s)
85
+
86
+ errors = Array.new
87
+ doc = XML::Parser.string(xml, :options => XML::Parser::Options::DTDLOAD).parse
88
+ assert_equal(1, errors.length)
81
89
  assert_equal("Warning: failed to load external entity \"test.dtd\" at :1.",
82
- errors.map do |error|
83
- error.to_s
84
- end.join(' '))
90
+ errors[0].to_s)
91
+ ensure
92
+ XML::Error.reset_handler
85
93
  end
86
94
  end
@@ -1,19 +1,7 @@
1
1
  require "xml"
2
2
  require 'test/unit'
3
3
 
4
- class HtmlParserTest < Test::Unit::TestCase
5
- def setup
6
- @xp = XML::HTMLParser.new()
7
- assert_not_nil(@xp)
8
- str = '<html><head><meta name=keywords content=nasty></head><body>Hello<br>World</html>'
9
- @xp.string = str
10
- assert_equal(str, @xp.string)
11
- end
12
-
13
- def teardown()
14
- @xp = nil
15
- end
16
-
4
+ class HTMLParserTest < Test::Unit::TestCase
17
5
  def html_file
18
6
  File.expand_path(File.join(File.dirname(__FILE__), 'model/ruby-lang.html'))
19
7
  end
@@ -22,8 +10,6 @@ class HtmlParserTest < Test::Unit::TestCase
22
10
  def test_file
23
11
  xp = XML::HTMLParser.file(html_file)
24
12
  assert_instance_of(XML::HTMLParser, xp)
25
- assert_equal(html_file, xp.file)
26
- assert_equal(html_file, xp.input.file)
27
13
  end
28
14
 
29
15
  def test_string
@@ -32,8 +18,6 @@ class HtmlParserTest < Test::Unit::TestCase
32
18
 
33
19
  assert_instance_of(XML::HTMLParser, xp)
34
20
  assert_instance_of(XML::HTMLParser, xp)
35
- assert_equal(str, xp.string)
36
- assert_equal(str, xp.input.string)
37
21
 
38
22
  doc = xp.parse
39
23
  assert_instance_of(XML::Document, doc)
@@ -43,9 +27,7 @@ class HtmlParserTest < Test::Unit::TestCase
43
27
  File.open(html_file) do |io|
44
28
  xp = XML::HTMLParser.io(io)
45
29
  assert_instance_of(XML::HTMLParser, xp)
46
- assert_equal(io, xp.io)
47
- assert_equal(io, xp.input.io)
48
-
30
+
49
31
  doc = xp.parse
50
32
  assert_instance_of(XML::Document, doc)
51
33
  end
@@ -56,16 +38,22 @@ class HtmlParserTest < Test::Unit::TestCase
56
38
  io = StringIO.new(data)
57
39
  xp = XML::HTMLParser.io(io)
58
40
  assert_instance_of(XML::HTMLParser, xp)
59
- assert_equal(io, xp.io)
60
- assert_equal(io, xp.input.io)
61
41
 
62
42
  doc = xp.parse
63
43
  assert_instance_of(XML::Document, doc)
64
44
  end
65
45
 
66
- def test_libxml_html_parser_parse
67
- doc = @xp.parse
68
-
46
+ def test_parse
47
+ html = <<-EOS
48
+ <html>
49
+ <head>
50
+ <meta name=keywords content=nasty>
51
+ </head>
52
+ <body>Hello<br>World</html>
53
+ EOS
54
+
55
+ parser = XML::HTMLParser.string(html)
56
+ doc = parser.parse
69
57
  assert_instance_of XML::Document, doc
70
58
 
71
59
  root = doc.root
@@ -102,4 +90,4 @@ class HtmlParserTest < Test::Unit::TestCase
102
90
  assert_instance_of XML::Node, world
103
91
  assert_equal 'World', world.content
104
92
  end
105
- end
93
+ end