libxml-ruby 4.1.0 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +13 -0
- data/ext/libxml/extconf.rb +67 -61
- data/ext/libxml/ruby_xml_attr_decl.c +154 -153
- data/ext/libxml/ruby_xml_attributes.c +276 -275
- data/ext/libxml/ruby_xml_error.c +2 -2
- data/ext/libxml/ruby_xml_html_parser_context.c +0 -1
- data/ext/libxml/ruby_xml_input_cbg.c +4 -7
- data/ext/libxml/ruby_xml_reader.c +1245 -1242
- data/ext/libxml/ruby_xml_relaxng.c +113 -112
- 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 +2 -2
- data/ext/libxml/ruby_xml_writer.c +1138 -1137
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
- data/ext/libxml/ruby_xml_xpath_object.c +340 -339
- data/lib/libxml/error.rb +7 -7
- data/lib/libxml/schema/element.rb +27 -19
- data/test/test_error.rb +173 -157
- data/test/test_schema.rb +237 -231
- metadata +3 -3
@@ -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
|
-
xmlErrorPtr 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
|
-
}
|
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
|
+
xmlErrorPtr 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
|
+
}
|