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.
- data/CHANGES +22 -0
- data/README +3 -1
- data/ext/libxml/cbg.c +86 -76
- data/ext/libxml/extconf.rb +2 -1
- data/ext/libxml/libxml.c +899 -885
- data/ext/libxml/ruby_libxml.h +65 -70
- data/ext/libxml/ruby_xml_attr.c +485 -500
- data/ext/libxml/ruby_xml_attributes.c +107 -106
- data/ext/libxml/ruby_xml_document.c +355 -356
- data/ext/libxml/ruby_xml_dtd.c +119 -117
- data/ext/libxml/ruby_xml_error.c +1112 -581
- data/ext/libxml/ruby_xml_html_parser.c +35 -34
- data/ext/libxml/ruby_xml_input.c +182 -187
- data/ext/libxml/ruby_xml_input_cbg.c +197 -179
- data/ext/libxml/ruby_xml_node.c +1529 -1566
- data/ext/libxml/ruby_xml_node.h +2 -2
- data/ext/libxml/ruby_xml_ns.c +150 -156
- data/ext/libxml/ruby_xml_parser.c +37 -36
- data/ext/libxml/ruby_xml_parser_context.c +657 -659
- data/ext/libxml/ruby_xml_reader.c +203 -209
- data/ext/libxml/ruby_xml_relaxng.c +29 -25
- data/ext/libxml/ruby_xml_sax_parser.c +33 -32
- data/ext/libxml/ruby_xml_schema.c +165 -161
- data/ext/libxml/ruby_xml_state.c +19 -21
- data/ext/libxml/ruby_xml_xinclude.c +24 -25
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath_context.c +305 -293
- data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
- data/ext/libxml/ruby_xml_xpath_object.c +89 -96
- data/ext/libxml/ruby_xml_xpointer.c +107 -109
- data/ext/libxml/ruby_xml_xpointer.h +13 -13
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/Rakefile +1 -1
- data/ext/vc/libxml_ruby.vcproj +1 -1
- data/lib/libxml/error.rb +4 -4
- data/test/tc_node_edit.rb +14 -2
- data/test/tc_node_text.rb +9 -9
- metadata +2 -2
@@ -1,109 +1,107 @@
|
|
1
|
-
/* $Id: ruby_xml_xpointer.c
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
VALUE
|
27
|
-
VALUE
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
context
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
result
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
*
|
62
|
-
*
|
63
|
-
*
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if (rb_obj_is_kind_of(
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
+
#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
|
8
|
+
#define RUBY_LIBXML_VER_MIC 5
|
9
9
|
#define RUBY_LIBXML_VER_PATCH 0
|
data/ext/mingw/Rakefile
CHANGED
data/ext/vc/libxml_ruby.vcproj
CHANGED
@@ -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.
|
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
data/test/tc_node_edit.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
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
|
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
|
-
|
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
|
15
|
-
|
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
|
+
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-
|
12
|
+
date: 2008-11-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|