libxml-ruby 0.5.1.0 → 0.5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/ext/xml/libxml.c +2 -1
  2. data/ext/xml/libxml.h +5 -3
  3. data/ext/xml/libxml.rb +1 -1
  4. data/ext/xml/ruby_xml_attr.c +13 -33
  5. data/ext/xml/ruby_xml_document.c +11 -22
  6. data/ext/xml/ruby_xml_document.h +2 -1
  7. data/ext/xml/ruby_xml_html_parser.c +3 -6
  8. data/ext/xml/ruby_xml_html_parser.h +1 -1
  9. data/ext/xml/ruby_xml_node.c +87 -70
  10. data/ext/xml/ruby_xml_node.h +2 -1
  11. data/ext/xml/ruby_xml_node_set.c +32 -111
  12. data/ext/xml/ruby_xml_node_set.h +5 -11
  13. data/ext/xml/ruby_xml_ns.c +1 -1
  14. data/ext/xml/ruby_xml_ns.h +1 -1
  15. data/ext/xml/ruby_xml_parser.c +11 -11
  16. data/ext/xml/ruby_xml_parser.h +1 -1
  17. data/ext/xml/ruby_xml_parser_context.c +11 -9
  18. data/ext/xml/ruby_xml_parser_context.h +1 -1
  19. data/ext/xml/ruby_xml_sax_parser.c +1 -1
  20. data/ext/xml/ruby_xml_sax_parser.h +1 -1
  21. data/ext/xml/ruby_xml_state.c +114 -0
  22. data/ext/xml/ruby_xml_state.h +11 -0
  23. data/ext/xml/ruby_xml_tree.c +1 -1
  24. data/ext/xml/ruby_xml_tree.h +1 -1
  25. data/ext/xml/ruby_xml_xinclude.c +1 -1
  26. data/ext/xml/ruby_xml_xinclude.h +1 -1
  27. data/ext/xml/ruby_xml_xpath.c +117 -231
  28. data/ext/xml/ruby_xml_xpath.h +4 -5
  29. data/ext/xml/ruby_xml_xpath_context.c +43 -50
  30. data/ext/xml/ruby_xml_xpath_context.h +3 -7
  31. data/ext/xml/ruby_xml_xpath_object.c +246 -0
  32. data/ext/xml/ruby_xml_xpath_object.h +29 -0
  33. data/ext/xml/ruby_xml_xpointer.c +8 -14
  34. data/ext/xml/ruby_xml_xpointer.h +1 -1
  35. data/ext/xml/ruby_xml_xpointer_context.c +1 -1
  36. data/ext/xml/ruby_xml_xpointer_context.h +1 -1
  37. data/ext/xml/sax_parser_callbacks.inc +1 -1
  38. data/tests/tc_xml_document.rb +5 -4
  39. data/tests/tc_xml_html_parser.rb +7 -4
  40. data/tests/tc_xml_node.rb +6 -5
  41. data/tests/tc_xml_node_set.rb +2 -2
  42. data/tests/tc_xml_node_set2.rb +3 -3
  43. data/tests/tc_xml_xpath.rb +3 -3
  44. data/tests/tc_xml_xpointer.rb +2 -2
  45. metadata +16 -10
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer.c 138 2007-08-29 18:00:35Z danj $ */
1
+ /* $Id: ruby_xml_xpointer.c 188 2007-09-24 01:43:21Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -12,7 +12,7 @@ VALUE
12
12
  ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
13
13
  #ifdef LIBXML_XPTR_ENABLED
14
14
  ruby_xml_node *node;
15
- ruby_xml_xpath_context *xxpc;
15
+ xmlXPathContextPtr ctxt;
16
16
  VALUE rxptr_xpth_ctxt, rxxp;
17
17
  xmlXPathObjectPtr xpath;
18
18
 
@@ -22,21 +22,17 @@ ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
22
22
 
23
23
  Data_Get_Struct(rnode, ruby_xml_node, node);
24
24
 
25
- rxptr_xpth_ctxt = ruby_xml_xpath_context_new(cXMLXPathContext,
26
- ruby_xml_document_wrap(cXMLDocument,node->node->doc),
27
- xmlXPtrNewContext(node->node->doc, node->node, NULL));
25
+ rxptr_xpth_ctxt =
26
+ ruby_xml_xpath_context_wrap(ctxt=xmlXPtrNewContext(node->node->doc, node->node, NULL));
27
+
28
28
  if (NIL_P(rxptr_xpth_ctxt))
29
29
  return(Qnil);
30
- Data_Get_Struct(rxptr_xpth_ctxt, ruby_xml_xpath_context, xxpc);
31
30
 
32
- xpath = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xxpc->ctxt);
31
+ xpath = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), ctxt);
33
32
  if (xpath == NULL)
34
33
  rb_raise(eXMLXPointerInvalidExpression, "invalid xpointer expression");
35
34
 
36
- rxxp = ruby_xml_xpath_new(cXMLXPath,
37
- ruby_xml_document_wrap(cXMLDocument,node->node->doc),
38
- rxptr_xpth_ctxt
39
- , xpath);
35
+ rxxp = ruby_xml_xpath_object_wrap(xpath);
40
36
  return(rxxp);
41
37
  #else
42
38
  rb_warn("libxml was compiled without XPointer support");
@@ -82,9 +78,7 @@ ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
82
78
  if (xpath == NULL)
83
79
  rb_fatal("You shouldn't be able to have this happen");
84
80
 
85
- rxxp = ruby_xml_xpath_new(cXMLXPath,
86
- ruby_xml_document_wrap(cXMLDocument,start->node->doc),
87
- Qnil, xpath);
81
+ rxxp = ruby_xml_xpath_object_wrap(xpath);
88
82
  return(rxxp);
89
83
  #else
90
84
  rb_warn("libxml was compiled without XPointer support");
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer.h 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_xpointer.h 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer_context.c 120 2006-11-26 12:57:56Z roscopeco $ */
1
+ /* $Id: ruby_xml_xpointer_context.c 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
1
+ /* $Id: ruby_xml_xpointer_context.h 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: sax_parser_callbacks.inc 120 2006-11-26 12:57:56Z roscopeco $ */
1
+ /* $Id: sax_parser_callbacks.inc 134 2007-08-29 17:30:19Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_document.rb 67 2006-04-17 13:30:22Z roscopeco $
1
+ # $Id: tc_xml_document.rb 183 2007-09-21 14:09:52Z danj $
2
2
  require 'test/unit'
3
3
  require "libxml_test"
4
4
 
@@ -18,9 +18,10 @@ class TC_XML_Document < Test::Unit::TestCase
18
18
 
19
19
  def test_libxml_document_find()
20
20
  set = @doc.find('/ruby_array/fixnum')
21
- assert_instance_of(XML::Node::Set, set)
22
- xpt = set.xpath
23
- assert_instance_of(XML::XPath, xpt)
21
+ assert_instance_of(XML::XPath::Object, set)
22
+ assert_raise(NoMethodError) {
23
+ xpt = set.xpath
24
+ }
24
25
  end
25
26
 
26
27
  def test_ruby_xml_document_compression()
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_html_parser.rb 168 2007-09-05 12:51:04Z danj $
1
+ # $Id: tc_xml_html_parser.rb 182 2007-09-12 14:47:09Z danj $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -33,13 +33,16 @@ class TC_XML_HTMLParser < Test::Unit::TestCase
33
33
  assert_equal 'meta', meta.name
34
34
  assert_equal 'keywords', meta[:name]
35
35
  assert_equal 'nasty', meta[:content]
36
-
36
+
37
37
  body = head.next
38
38
  assert_instance_of XML::Node, body
39
39
  assert_equal 'body', body.name
40
40
 
41
- hello = body.child.child
42
- puts hello.next.to_s
41
+ hello = body.child
42
+ # It appears that some versions of libxml2 add a layer of <p>
43
+ # cant figure our why or how, so this skips it if there
44
+ hello = hello.child if hello.name == "p"
45
+
43
46
  assert_instance_of XML::Node, hello
44
47
  assert_equal 'Hello', hello.content
45
48
 
data/tests/tc_xml_node.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node.rb 67 2006-04-17 13:30:22Z roscopeco $
1
+ # $Id: tc_xml_node.rb 191 2007-10-05 14:56:49Z danj $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -12,9 +12,10 @@ class TC_XML_Node < Test::Unit::TestCase
12
12
  @root = doc.root
13
13
  assert_instance_of(XML::Node, @root)
14
14
  set = doc.find('/ruby_array/fixnum')
15
- assert_instance_of(XML::Node::Set, set)
16
- xpt = set.xpath
17
- assert_instance_of(XML::XPath, xpt)
15
+ assert_instance_of(XML::XPath::Object, set)
16
+ assert_raise(NoMethodError) {
17
+ xpt = set.xpath
18
+ }
18
19
  @nodes = []
19
20
  set.each do |n|
20
21
  @nodes.push(n)
@@ -50,7 +51,7 @@ class TC_XML_Node < Test::Unit::TestCase
50
51
  end
51
52
 
52
53
  def test_libxml_node_find()
53
- set = @root.find('./fixnum')
54
+ set = @root.find('./fixnum').set
54
55
  assert_instance_of(XML::Node::Set, set)
55
56
  for node in set
56
57
  assert_instance_of(XML::Node, node)
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node_set.rb 67 2006-04-17 13:30:22Z roscopeco $
1
+ # $Id: tc_xml_node_set.rb 183 2007-09-21 14:09:52Z danj $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -9,7 +9,7 @@ class TC_XML_Node_Set < Test::Unit::TestCase
9
9
  assert_equal(str, xp.string = str)
10
10
  doc = xp.parse
11
11
  assert_instance_of(XML::Document, doc)
12
- @set = doc.find('/ruby_array/fixnum')
12
+ @set = doc.find('/ruby_array/fixnum').set
13
13
  assert_instance_of(XML::Node::Set, @set)
14
14
  end
15
15
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node_set2.rb 107 2006-11-20 01:22:08Z roscopeco $
1
+ # $Id: tc_xml_node_set2.rb 183 2007-09-21 14:09:52Z danj $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -11,8 +11,8 @@ class TC_XML_Node_Set2 < Test::Unit::TestCase
11
11
  assert_instance_of(XML::Document, doc)
12
12
  @one = doc.root.child
13
13
  @two = @one.next
14
- @set = doc.find('/ruby_array/fixnum')
15
- @emptyset = doc.find('/fixnum')
14
+ @set = doc.find('/ruby_array/fixnum').set
15
+ @emptyset = doc.find('/fixnum').set
16
16
  assert_instance_of(XML::Node::Set, @set)
17
17
  end
18
18
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_xpath.rb 67 2006-04-17 13:30:22Z roscopeco $
1
+ # $Id: tc_xml_xpath.rb 183 2007-09-21 14:09:52Z danj $
2
2
  require "libxml_test"
3
3
  require "test/unit"
4
4
 
@@ -9,8 +9,8 @@ class TC_XML_XPath < Test::Unit::TestCase
9
9
  assert_equal(str, xp.string = str)
10
10
  doc = xp.parse
11
11
  assert_instance_of(XML::Document, doc)
12
- @xpt = doc.find('/ruby_array/fixnum').xpath
13
- assert_instance_of(XML::XPath, @xpt)
12
+ @xpt = doc.find('/ruby_array/fixnum')
13
+ assert_instance_of(XML::XPath::Object, @xpt)
14
14
  end
15
15
 
16
16
  def teardown()
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_xpointer.rb 67 2006-04-17 13:30:22Z roscopeco $
1
+ # $Id: tc_xml_xpointer.rb 183 2007-09-21 14:09:52Z danj $
2
2
  require "libxml_test"
3
3
  require "test/unit"
4
4
 
@@ -21,7 +21,7 @@ class TC_XML_XPointer < Test::Unit::TestCase
21
21
 
22
22
  def test_libxml_xpointer_id()
23
23
  @xptr = @root.pointer('xpointer(id("two"))')
24
- assert_instance_of(XML::XPath, @xptr)
24
+ assert_instance_of(XML::XPath::Object, @xptr)
25
25
  set = @xptr.set
26
26
  assert_instance_of(XML::Node::Set, set)
27
27
  for n in set
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: libxml-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.1.0
7
- date: 2007-09-05 00:00:00 -04:00
6
+ version: 0.5.2.0
7
+ date: 2007-10-10 00:00:00 -04:00
8
8
  summary: LibXML2 bindings for Ruby
9
9
  require_paths:
10
10
  - lib
@@ -52,10 +52,12 @@ files:
52
52
  - ext/xml/ruby_xml_reader.c
53
53
  - ext/xml/ruby_xml_sax_parser.c
54
54
  - ext/xml/ruby_xml_schema.c
55
+ - ext/xml/ruby_xml_state.c
55
56
  - ext/xml/ruby_xml_tree.c
56
57
  - ext/xml/ruby_xml_xinclude.c
57
58
  - ext/xml/ruby_xml_xpath.c
58
59
  - ext/xml/ruby_xml_xpath_context.c
60
+ - ext/xml/ruby_xml_xpath_object.c
59
61
  - ext/xml/ruby_xml_xpointer.c
60
62
  - ext/xml/ruby_xml_xpointer_context.c
61
63
  - ext/xml/sax_parser_callbacks.inc
@@ -72,10 +74,12 @@ files:
72
74
  - ext/xml/ruby_xml_reader.h
73
75
  - ext/xml/ruby_xml_sax_parser.h
74
76
  - ext/xml/ruby_xml_schema.h
77
+ - ext/xml/ruby_xml_state.h
75
78
  - ext/xml/ruby_xml_tree.h
76
79
  - ext/xml/ruby_xml_xinclude.h
77
80
  - ext/xml/ruby_xml_xpath.h
78
81
  - ext/xml/ruby_xml_xpath_context.h
82
+ - ext/xml/ruby_xml_xpath_object.h
79
83
  - ext/xml/ruby_xml_xpointer.h
80
84
  - ext/xml/ruby_xml_xpointer_context.h
81
85
  - ext/xml/libxml.h
@@ -83,6 +87,13 @@ files:
83
87
  - tests/libxml_test.rb
84
88
  - tests/merge_bug.rb
85
89
  - tests/model
90
+ - tests/model/default_validation_bug.rb
91
+ - tests/model/merge_bug_data.xml
92
+ - tests/model/rubynet.xml
93
+ - tests/model/rubynet_project
94
+ - tests/model/saxtest.xml
95
+ - tests/model/simple.xml
96
+ - tests/model/xinclude.xml
86
97
  - tests/runner.rb
87
98
  - tests/schema-test.rb
88
99
  - tests/tc_xml_document.rb
@@ -116,13 +127,6 @@ files:
116
127
  - tests/tc_xml_xinclude.rb
117
128
  - tests/tc_xml_xpath.rb
118
129
  - tests/tc_xml_xpointer.rb
119
- - tests/model/default_validation_bug.rb
120
- - tests/model/merge_bug_data.xml
121
- - tests/model/rubynet.xml
122
- - tests/model/rubynet_project
123
- - tests/model/saxtest.xml
124
- - tests/model/simple.xml
125
- - tests/model/xinclude.xml
126
130
  test_files:
127
131
  - tests/runner.rb
128
132
  rdoc_options:
@@ -147,10 +151,12 @@ extra_rdoc_files:
147
151
  - ext/xml/ruby_xml_reader.c
148
152
  - ext/xml/ruby_xml_sax_parser.c
149
153
  - ext/xml/ruby_xml_schema.c
154
+ - ext/xml/ruby_xml_state.c
150
155
  - ext/xml/ruby_xml_tree.c
151
156
  - ext/xml/ruby_xml_xinclude.c
152
157
  - ext/xml/ruby_xml_xpath.c
153
158
  - ext/xml/ruby_xml_xpath_context.c
159
+ - ext/xml/ruby_xml_xpath_object.c
154
160
  - ext/xml/ruby_xml_xpointer.c
155
161
  - ext/xml/ruby_xml_xpointer_context.c
156
162
  - ext/xml/libxml.rb