libxml-ruby 0.9.4-x86-mswin32-60 → 0.9.5-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) 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/mingw/libxml_ruby.dll.a +0 -0
  35. data/ext/mingw/libxml_ruby.so +0 -0
  36. data/ext/vc/libxml_ruby.vcproj +1 -1
  37. data/lib/libxml/error.rb +4 -4
  38. data/test/tc_node_edit.rb +14 -2
  39. data/test/tc_node_text.rb +9 -9
  40. metadata +2 -2
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node.h 612 2008-11-21 08:01:29Z cfis $ */
1
+ /* $Id: ruby_xml_node.h 649 2008-11-30 03:15:57Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -9,6 +9,6 @@ extern VALUE cXMLNode;
9
9
 
10
10
  void ruby_init_xml_node(void);
11
11
  void rxml_node_mark_common(xmlNodePtr xnode);
12
- VALUE rxml_node2_wrap(VALUE class, xmlNodePtr xnode);
12
+ VALUE rxml_node_wrap(VALUE class, xmlNodePtr xnode);
13
13
  VALUE check_string_or_symbol(VALUE val);
14
14
  #endif
@@ -1,156 +1,150 @@
1
- /* $Id: ruby_xml_ns.c 614 2008-11-22 08:04:39Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #include "ruby_libxml.h"
6
- #include "ruby_xml_ns.h"
7
-
8
- VALUE cXMLNS;
9
-
10
-
11
- /* Document-class: LibXML::XML::NS
12
- *
13
- * The NS class is used to query information about
14
- * xml namespaces associated with particular nodes.
15
- * It can also be used to associate new namespaces
16
- * with an node. */
17
-
18
-
19
- static VALUE
20
- rxml_ns_alloc(VALUE klass) {
21
- return Data_Wrap_Struct(klass, NULL, NULL, NULL);
22
- }
23
-
24
- /*
25
- * call-seq:
26
- * initialize(node, "href", "prefix")
27
- *
28
- * Create a new namespace attached to the specified node with the
29
- * give prefix and namespace.
30
- *
31
- * XML::NS.new(node, "xlink", "http://www.w3.org/1999/xlink")
32
- */
33
- static VALUE
34
- rxml_ns_initialize(VALUE self, VALUE node, VALUE href, VALUE prefix) {
35
- xmlNodePtr xnode;
36
- xmlChar *xmlPrefix;
37
- xmlNsPtr xns;
38
-
39
- Data_Get_Struct(node, xmlNode, xnode);
40
- /* Prefix can be null - that means its the default namespace */
41
- xmlPrefix = NIL_P(prefix) ? NULL : StringValuePtr(prefix);
42
- xns = xmlNewNs(xnode, (xmlChar*)StringValuePtr(href), xmlPrefix);
43
-
44
- DATA_PTR(self) = xns;
45
- return self;
46
- }
47
-
48
- VALUE
49
- rxml_ns_wrap(xmlNsPtr xns) {
50
- return(Data_Wrap_Struct(cXMLNS, NULL, NULL, xns));
51
- }
52
-
53
-
54
- /*
55
- * call-seq:
56
- * ns.href -> "href"
57
- *
58
- * Obtain the namespace's href.
59
- */
60
- static VALUE
61
- rxml_ns_href_get(VALUE self) {
62
- xmlNsPtr xns;
63
- Data_Get_Struct(self, xmlNs, xns);
64
- if (xns == NULL || xns->href == NULL)
65
- return(Qnil);
66
- else
67
- return(rb_str_new2((const char*)xns->href));
68
- }
69
-
70
-
71
- /*
72
- * call-seq:
73
- * ns.href? -> (true|false)
74
- *
75
- * Determine whether this namespace has an href.
76
- */
77
- static VALUE
78
- rxml_ns_href_q(VALUE self) {
79
- xmlNsPtr xns;
80
- Data_Get_Struct(self, xmlNs, xns);
81
- if (xns == NULL || xns->href == NULL)
82
- return(Qfalse);
83
- else
84
- return(Qtrue);
85
- }
86
-
87
-
88
- /*
89
- * call-seq:
90
- * ns.next -> ns
91
- *
92
- * Obtain the next namespace.
93
- */
94
- static VALUE
95
- rxml_ns_next(VALUE self) {
96
- xmlNsPtr xns;
97
- Data_Get_Struct(self, xmlNs, xns);
98
- if (xns == NULL || xns->next == NULL)
99
- return(Qnil);
100
- else
101
- return(rxml_ns_wrap(xns->next));
102
- }
103
-
104
-
105
- /*
106
- * call-seq:
107
- * ns.prefix -> "prefix"
108
- * ns.to_s -> "prefix"
109
- *
110
- * Obtain the namespace's prefix.
111
- */
112
- static VALUE
113
- rxml_ns_prefix_get(VALUE self) {
114
- xmlNsPtr xns;
115
- Data_Get_Struct(self, xmlNs, xns);
116
- if (xns == NULL || xns->prefix == NULL)
117
- return(Qnil);
118
- else
119
- return(rb_str_new2((const char*)xns->prefix));
120
- }
121
-
122
-
123
- /*
124
- * call-seq:
125
- * ns.prefix? -> (true|false)
126
- *
127
- * Determine whether this namespace has a prefix.
128
- */
129
- static VALUE
130
- rxml_ns_prefix_q(VALUE self) {
131
- xmlNsPtr xns;
132
- Data_Get_Struct(self, xmlNs, xns);
133
- if (xns == NULL || xns->prefix == NULL)
134
- return(Qfalse);
135
- else
136
- return(Qtrue);
137
- }
138
-
139
- // Rdoc needs to know
140
- #ifdef RDOC_NEVER_DEFINED
141
- mLibXML = rb_define_module("LibXML");
142
- mXML = rb_define_module_under(mLibXML, "XML");
143
- #endif
144
-
145
- void
146
- ruby_init_xml_ns(void) {
147
- cXMLNS = rb_define_class_under(mXML, "NS", rb_cObject);
148
- rb_define_alloc_func(cXMLNS, rxml_ns_alloc);
149
- rb_define_method(cXMLNS, "initialize", rxml_ns_initialize, 3);
150
- rb_define_method(cXMLNS, "href", rxml_ns_href_get, 0);
151
- rb_define_method(cXMLNS, "href?", rxml_ns_href_q, 0);
152
- rb_define_method(cXMLNS, "next", rxml_ns_next, 0);
153
- rb_define_method(cXMLNS, "prefix", rxml_ns_prefix_get, 0);
154
- rb_define_method(cXMLNS, "prefix?", rxml_ns_prefix_q, 0);
155
- rb_define_method(cXMLNS, "to_s", rxml_ns_prefix_get, 0);
156
- }
1
+ /* $Id: ruby_xml_ns.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_ns.h"
7
+
8
+ VALUE cXMLNS;
9
+
10
+ /* Document-class: LibXML::XML::NS
11
+ *
12
+ * The NS class is used to query information about
13
+ * xml namespaces associated with particular nodes.
14
+ * It can also be used to associate new namespaces
15
+ * with an node. */
16
+
17
+ static VALUE rxml_ns_alloc(VALUE klass)
18
+ {
19
+ return Data_Wrap_Struct(klass, NULL, NULL, NULL);
20
+ }
21
+
22
+ /*
23
+ * call-seq:
24
+ * initialize(node, "href", "prefix")
25
+ *
26
+ * Create a new namespace attached to the specified node with the
27
+ * give prefix and namespace.
28
+ *
29
+ * XML::NS.new(node, "xlink", "http://www.w3.org/1999/xlink")
30
+ */
31
+ static VALUE rxml_ns_initialize(VALUE self, VALUE node, VALUE href,
32
+ VALUE prefix)
33
+ {
34
+ xmlNodePtr xnode;
35
+ xmlChar *xmlPrefix;
36
+ xmlNsPtr xns;
37
+
38
+ Data_Get_Struct(node, xmlNode, xnode);
39
+ /* Prefix can be null - that means its the default namespace */
40
+ xmlPrefix = NIL_P(prefix) ? NULL : StringValuePtr(prefix);
41
+ xns = xmlNewNs(xnode, (xmlChar*) StringValuePtr(href), xmlPrefix);
42
+
43
+ DATA_PTR( self) = xns;
44
+ return self;
45
+ }
46
+
47
+ VALUE rxml_ns_wrap(xmlNsPtr xns)
48
+ {
49
+ return (Data_Wrap_Struct(cXMLNS, NULL, NULL, xns));
50
+ }
51
+
52
+ /*
53
+ * call-seq:
54
+ * ns.href -> "href"
55
+ *
56
+ * Obtain the namespace's href.
57
+ */
58
+ static VALUE rxml_ns_href_get(VALUE self)
59
+ {
60
+ xmlNsPtr xns;
61
+ Data_Get_Struct(self, xmlNs, xns);
62
+ if (xns == NULL || xns->href == NULL)
63
+ return (Qnil);
64
+ else
65
+ return (rb_str_new2((const char*) xns->href));
66
+ }
67
+
68
+ /*
69
+ * call-seq:
70
+ * ns.href? -> (true|false)
71
+ *
72
+ * Determine whether this namespace has an href.
73
+ */
74
+ static VALUE rxml_ns_href_q(VALUE self)
75
+ {
76
+ xmlNsPtr xns;
77
+ Data_Get_Struct(self, xmlNs, xns);
78
+ if (xns == NULL || xns->href == NULL)
79
+ return (Qfalse);
80
+ else
81
+ return (Qtrue);
82
+ }
83
+
84
+ /*
85
+ * call-seq:
86
+ * ns.next -> ns
87
+ *
88
+ * Obtain the next namespace.
89
+ */
90
+ static VALUE rxml_ns_next(VALUE self)
91
+ {
92
+ xmlNsPtr xns;
93
+ Data_Get_Struct(self, xmlNs, xns);
94
+ if (xns == NULL || xns->next == NULL)
95
+ return (Qnil);
96
+ else
97
+ return (rxml_ns_wrap(xns->next));
98
+ }
99
+
100
+ /*
101
+ * call-seq:
102
+ * ns.prefix -> "prefix"
103
+ * ns.to_s -> "prefix"
104
+ *
105
+ * Obtain the namespace's prefix.
106
+ */
107
+ static VALUE rxml_ns_prefix_get(VALUE self)
108
+ {
109
+ xmlNsPtr xns;
110
+ Data_Get_Struct(self, xmlNs, xns);
111
+ if (xns == NULL || xns->prefix == NULL)
112
+ return (Qnil);
113
+ else
114
+ return (rb_str_new2((const char*) xns->prefix));
115
+ }
116
+
117
+ /*
118
+ * call-seq:
119
+ * ns.prefix? -> (true|false)
120
+ *
121
+ * Determine whether this namespace has a prefix.
122
+ */
123
+ static VALUE rxml_ns_prefix_q(VALUE self)
124
+ {
125
+ xmlNsPtr xns;
126
+ Data_Get_Struct(self, xmlNs, xns);
127
+ if (xns == NULL || xns->prefix == NULL)
128
+ return (Qfalse);
129
+ else
130
+ return (Qtrue);
131
+ }
132
+
133
+ // Rdoc needs to know
134
+ #ifdef RDOC_NEVER_DEFINED
135
+ mLibXML = rb_define_module("LibXML");
136
+ mXML = rb_define_module_under(mLibXML, "XML");
137
+ #endif
138
+
139
+ void ruby_init_xml_ns(void)
140
+ {
141
+ cXMLNS = rb_define_class_under(mXML, "NS", rb_cObject);
142
+ rb_define_alloc_func(cXMLNS, rxml_ns_alloc);
143
+ rb_define_method(cXMLNS, "initialize", rxml_ns_initialize, 3);
144
+ rb_define_method(cXMLNS, "href", rxml_ns_href_get, 0);
145
+ rb_define_method(cXMLNS, "href?", rxml_ns_href_q, 0);
146
+ rb_define_method(cXMLNS, "next", rxml_ns_next, 0);
147
+ rb_define_method(cXMLNS, "prefix", rxml_ns_prefix_get, 0);
148
+ rb_define_method(cXMLNS, "prefix?", rxml_ns_prefix_q, 0);
149
+ rb_define_method(cXMLNS, "to_s", rxml_ns_prefix_get, 0);
150
+ }
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_parser.c 630 2008-11-24 06:53:01Z cfis $ */
1
+ /* $Id: ruby_xml_parser.c 650 2008-11-30 03:40:22Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -18,7 +18,7 @@ static ID CONTEXT_ATTR;
18
18
  *
19
19
  * As a result, parsing a document creates an in-memory document object
20
20
  * that consist of any number of XML::Node instances. This is simple
21
- * and powerful model, but has the major limitation that the size of
21
+ * and powerful model, but has the major limitation that the size of
22
22
  * the document that can be processed is limited by the amount of
23
23
  * memory available. In such cases, it is better to use the XML::Reader.
24
24
  *
@@ -27,39 +27,42 @@ static ID CONTEXT_ATTR;
27
27
  * parser = XML::Parser.new
28
28
  * parser.file = 'my_file'
29
29
  * doc = parser.parse
30
- *
31
- * You can also parse strings (see XML::Parser.string) and io objects (see
30
+ *
31
+ * You can also parse strings (see XML::Parser.string) and io objects (see
32
32
  * XML::Parser.io).
33
33
  */
34
34
 
35
35
  /*
36
36
  * call-seq:
37
37
  * parser.initialize -> parser
38
- *
38
+ *
39
39
  * Initiliazes instance of parser.
40
40
  */
41
- static VALUE
42
- rxml_parser_initialize(VALUE self) {
41
+ static VALUE rxml_parser_initialize(VALUE self)
42
+ {
43
43
  VALUE input = rb_class_new_instance(0, NULL, cXMLInput);
44
44
  rb_iv_set(self, "@input", input);
45
45
  rb_iv_set(self, "@context", Qnil);
46
46
  return self;
47
47
  }
48
48
 
49
- static xmlParserCtxtPtr
50
- rxml_parser_filename_ctxt(VALUE input) {
49
+ static xmlParserCtxtPtr rxml_parser_filename_ctxt(VALUE input)
50
+ {
51
51
  xmlParserCtxtPtr ctxt;
52
52
  int retry_count = 0;
53
53
  VALUE filename = rb_ivar_get(input, FILE_ATTR);
54
-
55
- retry:
56
- ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
57
- if (ctxt == NULL) {
58
- if ((errno == EMFILE || errno == ENFILE) && retry_count == 0) {
54
+
55
+ retry: ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
56
+ if (ctxt == NULL)
57
+ {
58
+ if ((errno == EMFILE || errno == ENFILE) && retry_count == 0)
59
+ {
59
60
  retry_count++;
60
61
  rb_gc();
61
62
  goto retry;
62
- } else {
63
+ }
64
+ else
65
+ {
63
66
  rb_raise(rb_eIOError, StringValuePtr(filename));
64
67
  }
65
68
  }
@@ -67,34 +70,32 @@ rxml_parser_filename_ctxt(VALUE input) {
67
70
  return ctxt;
68
71
  }
69
72
 
70
- static xmlParserCtxtPtr
71
- rxml_parser_str_ctxt(VALUE input) {
73
+ static xmlParserCtxtPtr rxml_parser_str_ctxt(VALUE input)
74
+ {
72
75
  VALUE str = rb_ivar_get(input, STRING_ATTR);
73
76
  return xmlCreateMemoryParserCtxt(StringValuePtr(str), RSTRING_LEN(str));
74
77
  }
75
78
 
76
- static xmlParserCtxtPtr
77
- rxml_parser_io_ctxt(VALUE input) {
79
+ static xmlParserCtxtPtr rxml_parser_io_ctxt(VALUE input)
80
+ {
78
81
  VALUE io = rb_ivar_get(input, IO_ATTR);
79
82
  VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
80
83
  xmlCharEncoding xmlEncoding = NUM2INT(encoding);
81
84
 
82
85
  return xmlCreateIOParserCtxt(NULL, NULL,
83
- (xmlInputReadCallback) rxml_read_callback,
84
- NULL, (void *)io, xmlEncoding);
86
+ (xmlInputReadCallback) rxml_read_callback, NULL, (void *) io, xmlEncoding);
85
87
  }
86
88
 
87
-
88
89
  /*
89
90
  * call-seq:
90
91
  * parser.parse -> document
91
- *
92
+ *
92
93
  * Parse the input XML and create an XML::Document with
93
94
  * it's content. If an error occurs, XML::Parser::ParseError
94
95
  * is thrown.
95
96
  */
96
- static VALUE
97
- rxml_parser_parse(VALUE self) {
97
+ static VALUE rxml_parser_parse(VALUE self)
98
+ {
98
99
  xmlParserCtxtPtr ctxt;
99
100
  VALUE context;
100
101
  VALUE input = rb_ivar_get(self, INPUT_ATTR);
@@ -108,19 +109,20 @@ rxml_parser_parse(VALUE self) {
108
109
  else if (rb_ivar_get(input, STRING_ATTR) != Qnil)
109
110
  ctxt = rxml_parser_str_ctxt(input);
110
111
  /*else if (rb_ivar_get(input, DOCUMENT_ATTR) != Qnil)
111
- ctxt = rxml_parser_parse_document(input);*/
112
+ ctxt = rxml_parser_parse_document(input);*/
112
113
  else if (rb_ivar_get(input, IO_ATTR) != Qnil)
113
114
  ctxt = rxml_parser_io_ctxt(input);
114
115
  else
115
116
  rb_raise(rb_eArgError, "You must specify a parser data source");
116
-
117
+
117
118
  if (!ctxt)
118
119
  rxml_raise(&xmlLastError);
119
120
 
120
121
  context = rxml_parser_context_wrap(ctxt);
121
122
  rb_ivar_set(self, CONTEXT_ATTR, context);
122
-
123
- if (xmlParseDocument(ctxt) == -1 || !ctxt->wellFormed) {
123
+
124
+ if (xmlParseDocument(ctxt) == -1 || !ctxt->wellFormed)
125
+ {
124
126
  xmlFreeDoc(ctxt->myDoc);
125
127
  rxml_raise(&ctxt->lastError);
126
128
  }
@@ -128,17 +130,16 @@ rxml_parser_parse(VALUE self) {
128
130
  return rxml_document_wrap(ctxt->myDoc);
129
131
  }
130
132
 
131
-
132
- // Rdoc needs to know
133
+ // Rdoc needs to know
133
134
  #ifdef RDOC_NEVER_DEFINED
134
- mLibXML = rb_define_module("LibXML");
135
- mXML = rb_define_module_under(mLibXML, "XML");
135
+ mLibXML = rb_define_module("LibXML");
136
+ mXML = rb_define_module_under(mLibXML, "XML");
136
137
  #endif
137
138
 
138
- void
139
- ruby_init_parser(void) {
139
+ void ruby_init_parser(void)
140
+ {
140
141
  cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
141
-
142
+
142
143
  /* Atributes */
143
144
  INPUT_ATTR = rb_intern("@input");
144
145
  CONTEXT_ATTR = rb_intern("@context");