libxml-ruby 4.1.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +22 -0
- data/ext/libxml/extconf.rb +67 -61
- data/ext/libxml/ruby_libxml.h +43 -44
- data/ext/libxml/ruby_xml.c +0 -343
- data/ext/libxml/ruby_xml.h +9 -10
- data/ext/libxml/ruby_xml_attr_decl.c +154 -153
- data/ext/libxml/ruby_xml_attributes.c +276 -275
- data/ext/libxml/ruby_xml_attributes.h +2 -0
- data/ext/libxml/ruby_xml_document.c +6 -6
- data/ext/libxml/ruby_xml_document.h +11 -11
- data/ext/libxml/ruby_xml_dtd.c +3 -3
- data/ext/libxml/ruby_xml_encoding.h +20 -18
- data/ext/libxml/ruby_xml_error.c +9 -6
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
- data/ext/libxml/ruby_xml_namespace.c +0 -3
- data/ext/libxml/ruby_xml_node.c +1394 -1398
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +47 -39
- data/ext/libxml/ruby_xml_parser_options.c +9 -1
- data/ext/libxml/ruby_xml_parser_options.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +1244 -1242
- data/ext/libxml/ruby_xml_relaxng.c +113 -112
- data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
- data/ext/libxml/ruby_xml_sax_parser.c +1 -9
- data/ext/libxml/ruby_xml_schema.c +422 -420
- data/ext/libxml/ruby_xml_schema_attribute.c +108 -107
- data/ext/libxml/ruby_xml_schema_element.c +70 -69
- data/ext/libxml/ruby_xml_schema_type.c +252 -251
- data/ext/libxml/ruby_xml_version.h +5 -5
- data/ext/libxml/ruby_xml_writer.c +1138 -1137
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +2 -2
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
- data/ext/libxml/ruby_xml_xpath_object.c +340 -339
- data/lib/libxml/document.rb +13 -13
- data/lib/libxml/html_parser.rb +23 -23
- data/lib/libxml/parser.rb +26 -24
- data/lib/libxml/schema/element.rb +27 -19
- data/test/test.rb +5 -0
- data/test/test_document_write.rb +1 -4
- data/test/test_dtd.rb +1 -4
- data/test/test_encoding.rb +1 -4
- data/test/test_helper.rb +9 -2
- data/test/test_html_parser.rb +162 -162
- data/test/test_namespace.rb +1 -3
- data/test/test_node.rb +1 -3
- data/test/test_node_write.rb +1 -4
- data/test/test_parser.rb +26 -17
- data/test/test_reader.rb +4 -4
- data/test/test_sax_parser.rb +1 -1
- data/test/test_schema.rb +237 -231
- data/test/test_xml.rb +0 -99
- metadata +4 -3
data/ext/libxml/ruby_xml_xpath.c
CHANGED
@@ -89,7 +89,7 @@ VALUE rxml_xpath_to_value(xmlXPathContextPtr xctxt, xmlXPathObjectPtr xobject)
|
|
89
89
|
/* xmlLastError is different than xctxt->lastError. Use
|
90
90
|
xmlLastError since it has the message set while xctxt->lastError
|
91
91
|
does not. */
|
92
|
-
|
92
|
+
const xmlError *xerror = xmlGetLastError();
|
93
93
|
rxml_raise(xerror);
|
94
94
|
}
|
95
95
|
|
@@ -320,7 +320,7 @@ rxml_xpath_context_enable_cache(int argc, VALUE *argv, VALUE self)
|
|
320
320
|
}
|
321
321
|
|
322
322
|
if (xmlXPathContextSetCache(xctxt, 1, value, 0) == -1)
|
323
|
-
rxml_raise(
|
323
|
+
rxml_raise(xmlGetLastError());
|
324
324
|
|
325
325
|
return self;
|
326
326
|
}
|
@@ -338,7 +338,7 @@ rxml_xpath_context_disable_cache(VALUE self)
|
|
338
338
|
Data_Get_Struct(self, xmlXPathContext, xctxt);
|
339
339
|
|
340
340
|
if (xmlXPathContextSetCache(xctxt, 0, 0, 0) == -1)
|
341
|
-
rxml_raise(
|
341
|
+
rxml_raise(xmlGetLastError());
|
342
342
|
|
343
343
|
return self;
|
344
344
|
}
|
@@ -1,81 +1,81 @@
|
|
1
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
2
|
-
|
3
|
-
#include "ruby_libxml.h"
|
4
|
-
#include "ruby_xml_xpath.h"
|
5
|
-
#include "ruby_xml_xpath_expression.h"
|
6
|
-
|
7
|
-
/*
|
8
|
-
* Document-class: LibXML::XML::XPath::Expression
|
9
|
-
*
|
10
|
-
* The XML::XPath::Expression class is used to compile
|
11
|
-
* XPath expressions so they can be parsed only once
|
12
|
-
* but reused multiple times.
|
13
|
-
*
|
14
|
-
* doc = XML::Document.string(IO.read('some xml file'))
|
15
|
-
* expr = XPath::Expression.new('//first')
|
16
|
-
* doc.root.each do |node|
|
17
|
-
* result = node.find(expr) # many, many, many times
|
18
|
-
* # ...
|
19
|
-
* end
|
20
|
-
*/
|
21
|
-
|
22
|
-
VALUE cXMLXPathExpression;
|
23
|
-
|
24
|
-
static void rxml_xpath_expression_free(xmlXPathCompExprPtr expr)
|
25
|
-
{
|
26
|
-
xmlXPathFreeCompExpr(expr);
|
27
|
-
}
|
28
|
-
|
29
|
-
static VALUE rxml_xpath_expression_alloc(VALUE klass)
|
30
|
-
{
|
31
|
-
return Data_Wrap_Struct(cXMLXPathExpression, NULL,
|
32
|
-
rxml_xpath_expression_free, NULL);
|
33
|
-
}
|
34
|
-
|
35
|
-
/* call-seq:
|
36
|
-
* XPath::Expression.compile(expression) -> XPath::Expression
|
37
|
-
*
|
38
|
-
* Compiles an
|
39
|
-
* when an XPath expression is called multiple times.
|
40
|
-
*
|
41
|
-
* doc = XML::Document.string('<header><first>hi</first></header>')
|
42
|
-
* expr = XPath::Expression.new('//first')
|
43
|
-
* nodes = doc.find(expr)
|
44
|
-
*/
|
45
|
-
static VALUE rxml_xpath_expression_compile(VALUE klass, VALUE expression)
|
46
|
-
{
|
47
|
-
VALUE args[] = {expression};
|
48
|
-
return rb_class_new_instance(1, args, cXMLXPathExpression);
|
49
|
-
}
|
50
|
-
|
51
|
-
/* call-seq:
|
52
|
-
* XPath::Expression.new(expression) -> XPath::Expression
|
53
|
-
*
|
54
|
-
* Compiles an
|
55
|
-
* when an XPath expression is called multiple times.
|
56
|
-
*
|
57
|
-
* doc = XML::Document.string('<header><first>hi</first></header>')
|
58
|
-
* expr = XPath::Expression.new('//first')
|
59
|
-
* nodes = doc.find(expr)
|
60
|
-
*/
|
61
|
-
static VALUE rxml_xpath_expression_initialize(VALUE self, VALUE expression)
|
62
|
-
{
|
63
|
-
xmlXPathCompExprPtr compexpr = xmlXPathCompile((const xmlChar*)StringValueCStr(expression));
|
64
|
-
|
65
|
-
if (compexpr == NULL)
|
66
|
-
{
|
67
|
-
|
68
|
-
rxml_raise(xerror);
|
69
|
-
}
|
70
|
-
|
71
|
-
DATA_PTR( self) = compexpr;
|
72
|
-
return self;
|
73
|
-
}
|
74
|
-
|
75
|
-
void rxml_init_xpath_expression(void)
|
76
|
-
{
|
77
|
-
cXMLXPathExpression = rb_define_class_under(mXPath, "Expression", rb_cObject);
|
78
|
-
rb_define_alloc_func(cXMLXPathExpression, rxml_xpath_expression_alloc);
|
79
|
-
rb_define_singleton_method(cXMLXPathExpression, "compile", rxml_xpath_expression_compile, 1);
|
80
|
-
rb_define_method(cXMLXPathExpression, "initialize", rxml_xpath_expression_initialize, 1);
|
81
|
-
}
|
1
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
2
|
+
|
3
|
+
#include "ruby_libxml.h"
|
4
|
+
#include "ruby_xml_xpath.h"
|
5
|
+
#include "ruby_xml_xpath_expression.h"
|
6
|
+
|
7
|
+
/*
|
8
|
+
* Document-class: LibXML::XML::XPath::Expression
|
9
|
+
*
|
10
|
+
* The XML::XPath::Expression class is used to compile
|
11
|
+
* XPath expressions so they can be parsed only once
|
12
|
+
* but reused multiple times.
|
13
|
+
*
|
14
|
+
* doc = XML::Document.string(IO.read('some xml file'))
|
15
|
+
* expr = XPath::Expression.new('//first')
|
16
|
+
* doc.root.each do |node|
|
17
|
+
* result = node.find(expr) # many, many, many times
|
18
|
+
* # ...
|
19
|
+
* end
|
20
|
+
*/
|
21
|
+
|
22
|
+
VALUE cXMLXPathExpression;
|
23
|
+
|
24
|
+
static void rxml_xpath_expression_free(xmlXPathCompExprPtr expr)
|
25
|
+
{
|
26
|
+
xmlXPathFreeCompExpr(expr);
|
27
|
+
}
|
28
|
+
|
29
|
+
static VALUE rxml_xpath_expression_alloc(VALUE klass)
|
30
|
+
{
|
31
|
+
return Data_Wrap_Struct(cXMLXPathExpression, NULL,
|
32
|
+
rxml_xpath_expression_free, NULL);
|
33
|
+
}
|
34
|
+
|
35
|
+
/* call-seq:
|
36
|
+
* XPath::Expression.compile(expression) -> XPath::Expression
|
37
|
+
*
|
38
|
+
* Compiles an XPath expression. This improves performance
|
39
|
+
* when an XPath expression is called multiple times.
|
40
|
+
*
|
41
|
+
* doc = XML::Document.string('<header><first>hi</first></header>')
|
42
|
+
* expr = XPath::Expression.new('//first')
|
43
|
+
* nodes = doc.find(expr)
|
44
|
+
*/
|
45
|
+
static VALUE rxml_xpath_expression_compile(VALUE klass, VALUE expression)
|
46
|
+
{
|
47
|
+
VALUE args[] = {expression};
|
48
|
+
return rb_class_new_instance(1, args, cXMLXPathExpression);
|
49
|
+
}
|
50
|
+
|
51
|
+
/* call-seq:
|
52
|
+
* XPath::Expression.new(expression) -> XPath::Expression
|
53
|
+
*
|
54
|
+
* Compiles an XPath expression. This improves performance
|
55
|
+
* when an XPath expression is called multiple times.
|
56
|
+
*
|
57
|
+
* doc = XML::Document.string('<header><first>hi</first></header>')
|
58
|
+
* expr = XPath::Expression.new('//first')
|
59
|
+
* nodes = doc.find(expr)
|
60
|
+
*/
|
61
|
+
static VALUE rxml_xpath_expression_initialize(VALUE self, VALUE expression)
|
62
|
+
{
|
63
|
+
xmlXPathCompExprPtr compexpr = xmlXPathCompile((const xmlChar*)StringValueCStr(expression));
|
64
|
+
|
65
|
+
if (compexpr == NULL)
|
66
|
+
{
|
67
|
+
const xmlError *xerror = xmlGetLastError();
|
68
|
+
rxml_raise(xerror);
|
69
|
+
}
|
70
|
+
|
71
|
+
DATA_PTR( self) = compexpr;
|
72
|
+
return self;
|
73
|
+
}
|
74
|
+
|
75
|
+
void rxml_init_xpath_expression(void)
|
76
|
+
{
|
77
|
+
cXMLXPathExpression = rb_define_class_under(mXPath, "Expression", rb_cObject);
|
78
|
+
rb_define_alloc_func(cXMLXPathExpression, rxml_xpath_expression_alloc);
|
79
|
+
rb_define_singleton_method(cXMLXPathExpression, "compile", rxml_xpath_expression_compile, 1);
|
80
|
+
rb_define_method(cXMLXPathExpression, "initialize", rxml_xpath_expression_initialize, 1);
|
81
|
+
}
|