libxml-ruby 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGES +22 -0
  2. data/README +3 -1
  3. data/ext/libxml/cbg.c +86 -76
  4. data/ext/libxml/extconf.rb +2 -1
  5. data/ext/libxml/libxml.c +899 -885
  6. data/ext/libxml/ruby_libxml.h +65 -70
  7. data/ext/libxml/ruby_xml_attr.c +485 -500
  8. data/ext/libxml/ruby_xml_attributes.c +107 -106
  9. data/ext/libxml/ruby_xml_document.c +355 -356
  10. data/ext/libxml/ruby_xml_dtd.c +119 -117
  11. data/ext/libxml/ruby_xml_error.c +1112 -581
  12. data/ext/libxml/ruby_xml_html_parser.c +35 -34
  13. data/ext/libxml/ruby_xml_input.c +182 -187
  14. data/ext/libxml/ruby_xml_input_cbg.c +197 -179
  15. data/ext/libxml/ruby_xml_node.c +1529 -1566
  16. data/ext/libxml/ruby_xml_node.h +2 -2
  17. data/ext/libxml/ruby_xml_ns.c +150 -156
  18. data/ext/libxml/ruby_xml_parser.c +37 -36
  19. data/ext/libxml/ruby_xml_parser_context.c +657 -659
  20. data/ext/libxml/ruby_xml_reader.c +203 -209
  21. data/ext/libxml/ruby_xml_relaxng.c +29 -25
  22. data/ext/libxml/ruby_xml_sax_parser.c +33 -32
  23. data/ext/libxml/ruby_xml_schema.c +165 -161
  24. data/ext/libxml/ruby_xml_state.c +19 -21
  25. data/ext/libxml/ruby_xml_xinclude.c +24 -25
  26. data/ext/libxml/ruby_xml_xpath.c +108 -108
  27. data/ext/libxml/ruby_xml_xpath_context.c +305 -293
  28. data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
  29. data/ext/libxml/ruby_xml_xpath_object.c +89 -96
  30. data/ext/libxml/ruby_xml_xpointer.c +107 -109
  31. data/ext/libxml/ruby_xml_xpointer.h +13 -13
  32. data/ext/libxml/version.h +2 -2
  33. data/ext/mingw/Rakefile +1 -1
  34. data/ext/vc/libxml_ruby.vcproj +1 -1
  35. data/lib/libxml/error.rb +4 -4
  36. data/test/tc_node_edit.rb +14 -2
  37. data/test/tc_node_text.rb +9 -9
  38. metadata +2 -2
@@ -1,109 +1,107 @@
1
- /* $Id: ruby_xml_xpointer.c 612 2008-11-21 08:01:29Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #include "ruby_libxml.h"
6
- #include "ruby_xml_xpointer.h"
7
-
8
- VALUE cXMLXPointer;
9
-
10
- /*
11
- * Document-class: LibXML::XML::XPointer
12
- *
13
- * The XML::Pointer class provides a standards based API for searching an xml document.
14
- * XPointer is based on the XML Path Language (XML::XPath) and is documented
15
- * at http://www.w3.org/TR/WD-xptr.
16
- */
17
-
18
-
19
- static VALUE
20
- rxml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
21
- #ifdef LIBXML_XPTR_ENABLED
22
- xmlNodePtr xnode;
23
- xmlXPathContextPtr xctxt;
24
- xmlXPathObjectPtr xpop;
25
-
26
- VALUE context;
27
- VALUE result;
28
- VALUE argv[1];
29
-
30
- Check_Type(xptr_str, T_STRING);
31
- if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
32
- rb_raise(rb_eTypeError, "require an XML::Node object");
33
-
34
- Data_Get_Struct(rnode, xmlNode, xnode);
35
-
36
- argv[0] = rb_funcall(rnode, rb_intern("doc"), 0);
37
- context = rb_class_new_instance(1, argv, cXMLXPathContext);
38
- Data_Get_Struct(context, xmlXPathContext, xctxt);
39
-
40
- xpop = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xctxt);
41
- if (!xpop)
42
- rxml_raise(&xmlLastError);
43
-
44
- result = rxml_xpath_object_wrap(xpop);
45
- rb_iv_set(result, "@context", context);
46
-
47
- return(result);
48
- #else
49
- rb_warn("libxml was compiled without XPointer support");
50
- return(Qfalse);
51
- #endif
52
- }
53
-
54
- VALUE
55
- rxml_xpointer_point2(VALUE node, VALUE xptr_str) {
56
- return(rxml_xpointer_point(cXMLXPointer, node, xptr_str));
57
- }
58
-
59
-
60
- /*
61
- * call-seq:
62
- * XML::XPointer.range(start_node, end_node) -> xpath
63
- *
64
- * Create an xpath representing the range between the supplied
65
- * start and end node.
66
- */
67
- static VALUE
68
- rxml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
69
- #ifdef LIBXML_XPTR_ENABLED
70
- xmlNodePtr start, end;
71
- VALUE rxxp;
72
- xmlXPathObjectPtr xpath;
73
-
74
- if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
75
- rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
76
- if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
77
- rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
78
-
79
- Data_Get_Struct(rstart, xmlNode, start);
80
- if (start == NULL)
81
- return(Qnil);
82
-
83
- Data_Get_Struct(rend, xmlNode, end);
84
- if (end == NULL)
85
- return(Qnil);
86
-
87
- xpath = xmlXPtrNewRangeNodes(start, end);
88
- if (xpath == NULL)
89
- rb_fatal("You shouldn't be able to have this happen");
90
-
91
- rxxp = rxml_xpath_object_wrap(xpath);
92
- return(rxxp);
93
- #else
94
- rb_warn("libxml was compiled without XPointer support");
95
- return(Qfalse);
96
- #endif
97
- }
98
-
99
- // Rdoc needs to know
100
- #ifdef RDOC_NEVER_DEFINED
101
- mLibXML = rb_define_module("LibXML");
102
- mXML = rb_define_module_under(mLibXML, "XML");
103
- #endif
104
-
105
- void
106
- ruby_init_xml_xpointer(void) {
107
- cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
108
- rb_define_singleton_method(cXMLXPointer, "range", rxml_xpointer_range, 2);
109
- }
1
+ /* $Id: ruby_xml_xpointer.c 650 2008-11-30 03:40:22Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_xpointer.h"
7
+
8
+ VALUE cXMLXPointer;
9
+
10
+ /*
11
+ * Document-class: LibXML::XML::XPointer
12
+ *
13
+ * The XML::Pointer class provides a standards based API for searching an xml document.
14
+ * XPointer is based on the XML Path Language (XML::XPath) and is documented
15
+ * at http://www.w3.org/TR/WD-xptr.
16
+ */
17
+
18
+ static VALUE rxml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str)
19
+ {
20
+ #ifdef LIBXML_XPTR_ENABLED
21
+ xmlNodePtr xnode;
22
+ xmlXPathContextPtr xctxt;
23
+ xmlXPathObjectPtr xpop;
24
+
25
+ VALUE context;
26
+ VALUE result;
27
+ VALUE argv[1];
28
+
29
+ Check_Type(xptr_str, T_STRING);
30
+ if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
31
+ rb_raise(rb_eTypeError, "require an XML::Node object");
32
+
33
+ Data_Get_Struct(rnode, xmlNode, xnode);
34
+
35
+ argv[0] = rb_funcall(rnode, rb_intern("doc"), 0);
36
+ context = rb_class_new_instance(1, argv, cXMLXPathContext);
37
+ Data_Get_Struct(context, xmlXPathContext, xctxt);
38
+
39
+ xpop = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xctxt);
40
+ if (!xpop)
41
+ rxml_raise(&xmlLastError);
42
+
43
+ result = rxml_xpath_object_wrap(xpop);
44
+ rb_iv_set(result, "@context", context);
45
+
46
+ return(result);
47
+ #else
48
+ rb_warn("libxml was compiled without XPointer support");
49
+ return (Qfalse);
50
+ #endif
51
+ }
52
+
53
+ VALUE rxml_xpointer_point2(VALUE node, VALUE xptr_str)
54
+ {
55
+ return (rxml_xpointer_point(cXMLXPointer, node, xptr_str));
56
+ }
57
+
58
+ /*
59
+ * call-seq:
60
+ * XML::XPointer.range(start_node, end_node) -> xpath
61
+ *
62
+ * Create an xpath representing the range between the supplied
63
+ * start and end node.
64
+ */
65
+ static VALUE rxml_xpointer_range(VALUE class, VALUE rstart, VALUE rend)
66
+ {
67
+ #ifdef LIBXML_XPTR_ENABLED
68
+ xmlNodePtr start, end;
69
+ VALUE rxxp;
70
+ xmlXPathObjectPtr xpath;
71
+
72
+ if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
73
+ rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
74
+ if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
75
+ rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
76
+
77
+ Data_Get_Struct(rstart, xmlNode, start);
78
+ if (start == NULL)
79
+ return(Qnil);
80
+
81
+ Data_Get_Struct(rend, xmlNode, end);
82
+ if (end == NULL)
83
+ return(Qnil);
84
+
85
+ xpath = xmlXPtrNewRangeNodes(start, end);
86
+ if (xpath == NULL)
87
+ rb_fatal("You shouldn't be able to have this happen");
88
+
89
+ rxxp = rxml_xpath_object_wrap(xpath);
90
+ return(rxxp);
91
+ #else
92
+ rb_warn("libxml was compiled without XPointer support");
93
+ return (Qfalse);
94
+ #endif
95
+ }
96
+
97
+ // Rdoc needs to know
98
+ #ifdef RDOC_NEVER_DEFINED
99
+ mLibXML = rb_define_module("LibXML");
100
+ mXML = rb_define_module_under(mLibXML, "XML");
101
+ #endif
102
+
103
+ void ruby_init_xml_xpointer(void)
104
+ {
105
+ cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
106
+ rb_define_singleton_method(cXMLXPointer, "range", rxml_xpointer_range, 2);
107
+ }
@@ -1,13 +1,13 @@
1
- /* $Id: ruby_xml_xpointer.h 630 2008-11-24 06:53:01Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #ifndef __rxml_XPOINTER__
6
- #define __rxml_XPOINTER__
7
-
8
- extern VALUE cXMLXPointer;
9
-
10
- void ruby_init_xml_xpointer(void);
11
- VALUE rxml_xpointer_point2(VALUE node, VALUE xptr_str);
12
-
13
- #endif
1
+ /* $Id: ruby_xml_xpointer.h 630 2008-11-24 06:53:01Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __rxml_XPOINTER__
6
+ #define __rxml_XPOINTER__
7
+
8
+ extern VALUE cXMLXPointer;
9
+
10
+ void ruby_init_xml_xpointer(void);
11
+ VALUE rxml_xpointer_point2(VALUE node, VALUE xptr_str);
12
+
13
+ #endif
data/ext/libxml/version.h CHANGED
@@ -1,9 +1,9 @@
1
1
  /* Don't nuke this block! It is used for automatically updating the
2
2
  * versions below. VERSION = string formatting, VERNUM = numbered
3
3
  * version for inline testing: increment both or none at all.*/
4
- #define RUBY_LIBXML_VERSION "0.9.4"
4
+ #define RUBY_LIBXML_VERSION "0.9.5"
5
5
  #define RUBY_LIBXML_VERNUM 0
6
6
  #define RUBY_LIBXML_VER_MAJ 0
7
7
  #define RUBY_LIBXML_VER_MIN 9
8
- #define RUBY_LIBXML_VER_MIC 4
8
+ #define RUBY_LIBXML_VER_MIC 5
9
9
  #define RUBY_LIBXML_VER_PATCH 0
data/ext/mingw/Rakefile CHANGED
@@ -25,7 +25,7 @@ task :install do
25
25
  # Copy the import library (used by libxslt)
26
26
  cp(EXTENSION_LIB_NAME, dest_path)
27
27
 
28
- # Copy dllss
28
+ # Copy dlls
29
29
  Dir.glob('*.dll').each do |dll|
30
30
  cp(dll, dest_path)
31
31
  end
@@ -63,7 +63,7 @@
63
63
  <Tool
64
64
  Name="VCLinkerTool"
65
65
  AdditionalDependencies="msvcrt-ruby18.lib libxml2.lib"
66
- OutputFile="C:\Development\ruby\lib\ruby\gems\1.8\gems\libxml-ruby-0.9.4-x86-mswin32-60\lib\$(ProjectName).so"
66
+ OutputFile="C:\Development\ruby\lib\ruby\gems\1.8\gems\libxml-ruby-0.9.5-x86-mswin32-60\lib\$(ProjectName).so"
67
67
  LinkIncremental="2"
68
68
  AdditionalLibraryDirectories="C:\Development\ruby\lib;C:\Development\msys\local\lib"
69
69
  GenerateDebugInformation="true"
data/lib/libxml/error.rb CHANGED
@@ -33,13 +33,13 @@ module LibXML
33
33
 
34
34
  def level_to_s
35
35
  case self.level
36
- when NONE:
36
+ when NONE
37
37
  ''
38
- when WARNING:
38
+ when WARNING
39
39
  'Warning:'
40
- when ERROR:
40
+ when ERROR
41
41
  'Error:'
42
- when FATAL:
42
+ when FATAL
43
43
  'Fatal error:'
44
44
  end
45
45
  end
data/test/tc_node_edit.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "xml"
1
+ require 'xml'
2
2
  require 'test/unit'
3
3
 
4
4
  class TestNodeEdit < Test::Unit::TestCase
@@ -60,12 +60,24 @@ class TestNodeEdit < Test::Unit::TestCase
60
60
  @doc.root.to_s.gsub(/\n\s*/,'')
61
61
  end
62
62
 
63
- def test_remove_node()
63
+ def test_remove_node
64
64
  first_node.remove!
65
65
  assert_equal('<test><num>two</num><num>three</num></test>',
66
66
  @doc.root.to_s.gsub(/\n\s*/,''))
67
67
  end
68
68
 
69
+ def test_reuse_removed_node
70
+ # Remove the node
71
+ node = @doc.root.first.remove!
72
+ assert_not_nil(node)
73
+
74
+ # Add it to the end of the documnet
75
+ @doc.root.last.next = node
76
+
77
+ assert_equal('<test><num>two</num><num>three</num><num>one</num></test>',
78
+ @doc.root.to_s.gsub(/\n\s*/,''))
79
+ end
80
+
69
81
  # This test is to verify that an earlier reported bug has been fixed
70
82
  def test_merge
71
83
  documents = []
data/test/tc_node_text.rb CHANGED
@@ -1,17 +1,17 @@
1
1
  require 'xml'
2
2
  require 'test/unit'
3
3
 
4
- class TC_XML_Node_text < Test::Unit::TestCase
5
- def setup
6
- @t=XML::Node.new_text("testdata")
7
- assert_instance_of(XML::Node,@t)
8
- end
9
-
4
+ class TestTextNode < Test::Unit::TestCase
10
5
  def test_content
11
- assert_equal("testdata",@t.content)
6
+ node = XML::Node.new_text('testdata')
7
+ assert_instance_of(XML::Node, node)
8
+ assert_equal('testdata', node.content)
12
9
  end
13
10
 
14
- def test_type
15
- assert_equal(true,@t.text?)
11
+ def test_invalid_content
12
+ error = assert_raise(TypeError) do
13
+ node = XML::Node.new_text(nil)
14
+ end
15
+ assert_equal('wrong argument type nil (expected String)', error.to_s)
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxml-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Savage
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-24 00:00:00 -07:00
12
+ date: 2008-11-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15