libxml-ruby 4.1.2 → 6.0.0

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 (172) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY → CHANGELOG.md} +875 -887
  3. data/LICENSE +20 -20
  4. data/README.md +67 -0
  5. data/Rakefile +77 -98
  6. data/ext/libxml/extconf.rb +39 -20
  7. data/ext/libxml/libxml.c +67 -79
  8. data/ext/libxml/ruby_libxml.h +43 -44
  9. data/ext/libxml/ruby_xml.c +556 -899
  10. data/ext/libxml/ruby_xml.h +9 -10
  11. data/ext/libxml/ruby_xml_attr.c +338 -333
  12. data/ext/libxml/ruby_xml_attr.h +13 -12
  13. data/ext/libxml/ruby_xml_attr_decl.c +19 -12
  14. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  15. data/ext/libxml/ruby_xml_attributes.c +18 -9
  16. data/ext/libxml/ruby_xml_attributes.h +17 -15
  17. data/ext/libxml/ruby_xml_document.c +1142 -1129
  18. data/ext/libxml/ruby_xml_document.h +12 -11
  19. data/ext/libxml/ruby_xml_dtd.c +287 -248
  20. data/ext/libxml/ruby_xml_dtd.h +10 -9
  21. data/ext/libxml/ruby_xml_encoding.c +250 -250
  22. data/ext/libxml/ruby_xml_encoding.h +20 -18
  23. data/ext/libxml/ruby_xml_error.c +1003 -996
  24. data/ext/libxml/ruby_xml_error.h +14 -14
  25. data/ext/libxml/ruby_xml_html_parser.c +91 -91
  26. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  27. data/ext/libxml/ruby_xml_html_parser_context.c +364 -337
  28. data/ext/libxml/ruby_xml_html_parser_context.h +11 -10
  29. data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
  30. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  31. data/ext/libxml/ruby_xml_input_cbg.c +216 -188
  32. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  33. data/ext/libxml/ruby_xml_io.c +49 -47
  34. data/ext/libxml/ruby_xml_io.h +10 -10
  35. data/ext/libxml/ruby_xml_namespace.c +159 -154
  36. data/ext/libxml/ruby_xml_namespace.h +11 -10
  37. data/ext/libxml/ruby_xml_namespaces.c +313 -293
  38. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  39. data/ext/libxml/ruby_xml_node.c +1433 -1398
  40. data/ext/libxml/ruby_xml_node.h +15 -13
  41. data/ext/libxml/ruby_xml_parser.c +91 -91
  42. data/ext/libxml/ruby_xml_parser.h +10 -10
  43. data/ext/libxml/ruby_xml_parser_context.c +1016 -1001
  44. data/ext/libxml/ruby_xml_parser_context.h +11 -10
  45. data/ext/libxml/ruby_xml_parser_options.c +74 -66
  46. data/ext/libxml/ruby_xml_parser_options.h +10 -10
  47. data/ext/libxml/ruby_xml_reader.c +40 -31
  48. data/ext/libxml/ruby_xml_reader.h +14 -14
  49. data/ext/libxml/ruby_xml_registry.c +31 -0
  50. data/ext/libxml/ruby_xml_registry.h +22 -0
  51. data/ext/libxml/ruby_xml_relaxng.c +21 -5
  52. data/ext/libxml/ruby_xml_relaxng.h +9 -8
  53. data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
  54. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  55. data/ext/libxml/ruby_xml_sax_parser.c +108 -116
  56. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  57. data/ext/libxml/ruby_xml_schema.c +22 -15
  58. data/ext/libxml/ruby_xml_schema.h +26 -25
  59. data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
  60. data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
  61. data/ext/libxml/ruby_xml_schema_element.c +8 -8
  62. data/ext/libxml/ruby_xml_schema_element.h +11 -11
  63. data/ext/libxml/ruby_xml_schema_facet.c +50 -50
  64. data/ext/libxml/ruby_xml_schema_facet.h +9 -9
  65. data/ext/libxml/ruby_xml_schema_type.c +12 -19
  66. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  67. data/ext/libxml/ruby_xml_version.h +9 -9
  68. data/ext/libxml/ruby_xml_writer.c +183 -185
  69. data/ext/libxml/ruby_xml_writer.h +6 -6
  70. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  71. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  72. data/ext/libxml/ruby_xml_xpath.c +195 -195
  73. data/ext/libxml/ruby_xml_xpath.h +15 -15
  74. data/ext/libxml/ruby_xml_xpath_context.c +408 -362
  75. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  76. data/ext/libxml/ruby_xml_xpath_expression.c +12 -6
  77. data/ext/libxml/ruby_xml_xpath_expression.h +11 -10
  78. data/ext/libxml/ruby_xml_xpath_object.c +69 -54
  79. data/ext/libxml/ruby_xml_xpath_object.h +19 -17
  80. data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
  81. data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
  82. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  83. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  84. data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
  85. data/lib/libxml/attr.rb +122 -122
  86. data/lib/libxml/attr_decl.rb +80 -80
  87. data/lib/libxml/attributes.rb +13 -13
  88. data/lib/libxml/document.rb +165 -194
  89. data/lib/libxml/error.rb +122 -95
  90. data/lib/libxml/html_parser.rb +80 -96
  91. data/lib/libxml/namespace.rb +61 -61
  92. data/lib/libxml/namespaces.rb +37 -37
  93. data/lib/libxml/node.rb +321 -323
  94. data/lib/libxml/parser.rb +94 -100
  95. data/lib/libxml/sax_callbacks.rb +179 -179
  96. data/lib/libxml/sax_parser.rb +40 -40
  97. data/lib/libxml/schema/attribute.rb +27 -19
  98. data/lib/libxml/schema/element.rb +20 -0
  99. data/lib/libxml/schema/type.rb +44 -21
  100. data/lib/libxml/schema.rb +47 -47
  101. data/lib/libxml/tree.rb +28 -28
  102. data/lib/libxml-ruby.rb +30 -30
  103. data/libxml-ruby.gemspec +46 -48
  104. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  105. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  106. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  107. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  108. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  109. data/test/c14n/result/with-comments/example-1 +5 -5
  110. data/test/c14n/result/with-comments/example-2 +10 -10
  111. data/test/c14n/result/with-comments/example-3 +13 -13
  112. data/test/c14n/result/with-comments/example-4 +8 -8
  113. data/test/c14n/result/with-comments/example-5 +3 -3
  114. data/test/c14n/result/without-comments/example-1 +3 -3
  115. data/test/c14n/result/without-comments/example-2 +10 -10
  116. data/test/c14n/result/without-comments/example-3 +13 -13
  117. data/test/c14n/result/without-comments/example-4 +8 -8
  118. data/test/c14n/result/without-comments/example-5 +2 -2
  119. data/test/test_attr.rb +179 -180
  120. data/test/test_attr_decl.rb +131 -131
  121. data/test/test_attributes.rb +135 -135
  122. data/test/test_canonicalize.rb +122 -120
  123. data/test/test_document.rb +138 -132
  124. data/test/test_document_write.rb +142 -145
  125. data/test/test_dtd.rb +134 -129
  126. data/test/test_encoding.rb +126 -129
  127. data/test/test_encoding_sax.rb +114 -114
  128. data/test/test_error.rb +197 -194
  129. data/test/test_helper.rb +21 -13
  130. data/test/test_html_parser.rb +166 -162
  131. data/test/test_html_parser_context.rb +22 -22
  132. data/test/test_input_callbacks.rb +36 -0
  133. data/test/test_namespace.rb +58 -60
  134. data/test/test_namespaces.rb +200 -200
  135. data/test/test_node.rb +251 -237
  136. data/test/test_node_cdata.rb +50 -50
  137. data/test/test_node_comment.rb +32 -32
  138. data/test/test_node_copy.rb +40 -40
  139. data/test/test_node_edit.rb +176 -158
  140. data/test/test_node_pi.rb +37 -37
  141. data/test/test_node_text.rb +69 -69
  142. data/test/test_node_write.rb +93 -96
  143. data/test/test_node_xlink.rb +28 -28
  144. data/test/test_parser.rb +297 -324
  145. data/test/test_parser_context.rb +198 -198
  146. data/test/test_properties.rb +38 -38
  147. data/test/test_reader.rb +413 -364
  148. data/test/test_relaxng.rb +59 -53
  149. data/test/test_sax_parser.rb +345 -326
  150. data/test/test_schema.rb +28 -0
  151. data/test/test_traversal.rb +152 -152
  152. data/test/test_writer.rb +469 -468
  153. data/test/test_xinclude.rb +20 -20
  154. data/test/test_xml.rb +164 -267
  155. data/test/test_xpath.rb +244 -244
  156. data/test/test_xpath_context.rb +87 -87
  157. data/test/test_xpath_expression.rb +37 -37
  158. metadata +49 -31
  159. data/README.rdoc +0 -217
  160. data/ext/libxml/extconf.h +0 -3
  161. data/ext/libxml/ruby_xml_cbg.c +0 -85
  162. data/lib/libxml/hpricot.rb +0 -78
  163. data/lib/libxml.rb +0 -5
  164. data/lib/xml/libxml.rb +0 -10
  165. data/lib/xml.rb +0 -14
  166. data/script/benchmark/depixelate +0 -634
  167. data/script/benchmark/hamlet.xml +0 -9055
  168. data/script/benchmark/parsecount +0 -170
  169. data/script/benchmark/sock_entries.xml +0 -507
  170. data/script/benchmark/throughput +0 -41
  171. data/script/test +0 -6
  172. data/test/test_deprecated_require.rb +0 -12
@@ -1,116 +1,108 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include "ruby_libxml.h"
4
- #include "ruby_xml_sax_parser.h"
5
-
6
- /*
7
- * Document-class: LibXML::XML::SaxParser
8
- *
9
- * XML::SaxParser provides a callback based API for parsing documents,
10
- * in contrast to XML::Parser's tree based API and XML::Reader's stream
11
- * based API.
12
- *
13
- * The XML::SaxParser API is fairly complex, not well standardized,
14
- * and does not directly support validation making entity, namespace and
15
- * base processing relatively hard.
16
- *
17
- * To use the XML::SaxParser, register a callback class via the
18
- * XML::SaxParser#callbacks=. It is easiest to include the
19
- * XML::SaxParser::Callbacks module in your class and override
20
- * the methods as needed.
21
- *
22
- * Basic example:
23
- *
24
- * class MyCallbacks
25
- * include XML::SaxParser::Callbacks
26
- * def on_start_element(element, attributes)
27
- * puts #Element started: #{element}"
28
- * end
29
- * end
30
- *
31
- * parser = XML::SaxParser.string(my_string)
32
- * parser.callbacks = MyCallbacks.new
33
- * parser.parse
34
- *
35
- * You can also parse strings (see XML::SaxParser.string) and
36
- * io objects (see XML::SaxParser.io).
37
- */
38
-
39
- VALUE cXMLSaxParser;
40
- static ID CALLBACKS_ATTR;
41
- static ID CONTEXT_ATTR;
42
-
43
-
44
- /* ====== Parser =========== */
45
-
46
- /*
47
- * call-seq:
48
- * parser.initialize(context) -> XML::Parser
49
- *
50
- * Creates a new XML::Parser from the specified
51
- * XML::Parser::Context.
52
- */
53
- static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)
54
- {
55
- VALUE context = Qnil;
56
-
57
- rb_scan_args(argc, argv, "01", &context);
58
-
59
- if (context == Qnil)
60
- {
61
- rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::SaxParser.new");
62
- }
63
-
64
- rb_ivar_set(self, CONTEXT_ATTR, context);
65
- return self;
66
- }
67
-
68
- /*
69
- * call-seq:
70
- * parser.parse -> (true|false)
71
- *
72
- * Parse the input XML, generating callbacks to the object
73
- * registered via the +callbacks+ attributesibute.
74
- */
75
- static VALUE rxml_sax_parser_parse(VALUE self)
76
- {
77
- int status;
78
- VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
79
- xmlParserCtxtPtr ctxt;
80
- Data_Get_Struct(context, xmlParserCtxt, ctxt);
81
-
82
- ctxt->sax2 = 1;
83
- ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
84
-
85
- if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
86
- xmlFree(ctxt->sax);
87
-
88
- ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(rxml_sax_handler));
89
- if (ctxt->sax == NULL)
90
- rb_fatal("Not enough memory.");
91
- memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
92
-
93
- status = xmlParseDocument(ctxt);
94
-
95
- /* Now check the parsing result*/
96
- if (status == -1 || !ctxt->wellFormed)
97
- {
98
- rxml_raise(&ctxt->lastError);
99
- }
100
- return Qtrue;
101
- }
102
-
103
- void rxml_init_sax_parser(void)
104
- {
105
- /* SaxParser */
106
- cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
107
-
108
- /* Atributes */
109
- CALLBACKS_ATTR = rb_intern("@callbacks");
110
- CONTEXT_ATTR = rb_intern("@context");
111
- rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
112
-
113
- /* Instance Methods */
114
- rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
115
- rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
116
- }
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include "ruby_xml_sax_parser.h"
5
+
6
+ /*
7
+ * Document-class: LibXML::XML::SaxParser
8
+ *
9
+ * XML::SaxParser provides a callback based API for parsing documents,
10
+ * in contrast to XML::Parser's tree based API and XML::Reader's stream
11
+ * based API.
12
+ *
13
+ * The XML::SaxParser API is fairly complex, not well standardized,
14
+ * and does not directly support validation making entity, namespace and
15
+ * base processing relatively hard.
16
+ *
17
+ * To use the XML::SaxParser, register a callback class via the
18
+ * XML::SaxParser#callbacks=. It is easiest to include the
19
+ * XML::SaxParser::Callbacks module in your class and override
20
+ * the methods as needed.
21
+ *
22
+ * Basic example:
23
+ *
24
+ * class MyCallbacks
25
+ * include XML::SaxParser::Callbacks
26
+ * def on_start_element(element, attributes)
27
+ * puts #Element started: #{element}"
28
+ * end
29
+ * end
30
+ *
31
+ * parser = XML::SaxParser.string(my_string)
32
+ * parser.callbacks = MyCallbacks.new
33
+ * parser.parse
34
+ *
35
+ * You can also parse strings (see XML::SaxParser.string) and
36
+ * io objects (see XML::SaxParser.io).
37
+ */
38
+
39
+ VALUE cXMLSaxParser;
40
+ static ID CALLBACKS_ATTR;
41
+ static ID CONTEXT_ATTR;
42
+
43
+
44
+ /* ====== Parser =========== */
45
+
46
+ /*
47
+ * call-seq:
48
+ * parser.initialize(context) -> XML::Parser
49
+ *
50
+ * Creates a new XML::Parser from the specified
51
+ * XML::Parser::Context.
52
+ */
53
+ static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)
54
+ {
55
+ VALUE context = Qnil;
56
+
57
+ rb_scan_args(argc, argv, "01", &context);
58
+
59
+ if (context == Qnil)
60
+ {
61
+ rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::SaxParser.new");
62
+ }
63
+
64
+ rb_ivar_set(self, CONTEXT_ATTR, context);
65
+ return self;
66
+ }
67
+
68
+ /*
69
+ * call-seq:
70
+ * parser.parse -> (true|false)
71
+ *
72
+ * Parse the input XML, generating callbacks to the object
73
+ * registered via the +callbacks+ attributesibute.
74
+ */
75
+ static VALUE rxml_sax_parser_parse(VALUE self)
76
+ {
77
+ VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
78
+ xmlParserCtxtPtr ctxt;
79
+ TypedData_Get_Struct(context, xmlParserCtxt, &rxml_parser_context_type, ctxt);
80
+
81
+ ctxt->sax2 = 1;
82
+ ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
83
+ memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
84
+
85
+ int status = xmlParseDocument(ctxt);
86
+
87
+ /* Now check the parsing result*/
88
+ if (status == -1 || !ctxt->wellFormed)
89
+ {
90
+ rxml_raise(&ctxt->lastError);
91
+ }
92
+ return Qtrue;
93
+ }
94
+
95
+ void rxml_init_sax_parser(void)
96
+ {
97
+ /* SaxParser */
98
+ cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
99
+
100
+ /* Atributes */
101
+ CALLBACKS_ATTR = rb_intern("@callbacks");
102
+ CONTEXT_ATTR = rb_intern("@context");
103
+ rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
104
+
105
+ /* Instance Methods */
106
+ rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
107
+ rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
108
+ }
@@ -1,10 +1,10 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_SAX_PARSER__
4
- #define __RXML_SAX_PARSER__
5
-
6
- extern VALUE cXMLSaxParser;
7
-
8
- void rxml_init_sax_parser(void);
9
-
10
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_SAX_PARSER__
4
+ #define __RXML_SAX_PARSER__
5
+
6
+ extern VALUE cXMLSaxParser;
7
+
8
+ void rxml_init_sax_parser(void);
9
+
10
+ #endif
@@ -109,11 +109,18 @@ struct _xmlSchemaImport {
109
109
 
110
110
  VALUE cXMLSchema;
111
111
 
112
- static void rxml_schema_free(xmlSchemaPtr xschema)
112
+ static void rxml_schema_free(void *data)
113
113
  {
114
+ xmlSchemaPtr xschema = (xmlSchemaPtr)data;
114
115
  xmlSchemaFree(xschema);
115
116
  }
116
117
 
118
+ const rb_data_type_t rxml_schema_type = {
119
+ "XML::Schema",
120
+ {NULL, rxml_schema_free, NULL},
121
+ NULL, NULL, 0
122
+ };
123
+
117
124
  VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
118
125
  {
119
126
  VALUE result;
@@ -121,7 +128,7 @@ VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
121
128
  if (!xschema)
122
129
  rb_raise(rb_eArgError, "XML::Schema is required!");
123
130
 
124
- result = Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
131
+ result = TypedData_Wrap_Struct(cXMLSchema, &rxml_schema_type, xschema);
125
132
 
126
133
  /*
127
134
  * Create these as instance variables to provide the output of inspect/to_str some
@@ -130,7 +137,7 @@ VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
130
137
  rb_iv_set(result, "@target_namespace", QNIL_OR_STRING(xschema->targetNamespace));
131
138
  rb_iv_set(result, "@name", QNIL_OR_STRING(xschema->name));
132
139
  rb_iv_set(result, "@id", QNIL_OR_STRING(xschema->id));
133
- rb_iv_set(result, "@version", QNIL_OR_STRING(xschema->name));
140
+ rb_iv_set(result, "@version", QNIL_OR_STRING(xschema->version));
134
141
 
135
142
  return result;
136
143
  }
@@ -143,7 +150,7 @@ static VALUE rxml_schema_init(VALUE class, xmlSchemaParserCtxtPtr xparser)
143
150
  xmlSchemaFreeParserCtxt(xparser);
144
151
 
145
152
  if (!xschema)
146
- rxml_raise(&xmlLastError);
153
+ rxml_raise(xmlGetLastError());
147
154
 
148
155
  return rxml_wrap_schema(xschema);
149
156
  }
@@ -163,7 +170,7 @@ static VALUE rxml_schema_init_from_uri(VALUE class, VALUE uri)
163
170
  xmlResetLastError();
164
171
  xparser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
165
172
  if (!xparser)
166
- rxml_raise(&xmlLastError);
173
+ rxml_raise(xmlGetLastError());
167
174
 
168
175
  return rxml_schema_init(class, xparser);
169
176
  }
@@ -179,12 +186,12 @@ static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
179
186
  xmlDocPtr xdoc;
180
187
  xmlSchemaParserCtxtPtr xparser;
181
188
 
182
- Data_Get_Struct(document, xmlDoc, xdoc);
189
+ TypedData_Get_Struct(document, xmlDoc, &rxml_document_data_type, xdoc);
183
190
 
184
191
  xmlResetLastError();
185
192
  xparser = xmlSchemaNewDocParserCtxt(xdoc);
186
193
  if (!xparser)
187
- rxml_raise(&xmlLastError);
194
+ rxml_raise(xmlGetLastError());
188
195
 
189
196
  return rxml_schema_init(class, xparser);
190
197
  }
@@ -204,7 +211,7 @@ static VALUE rxml_schema_init_from_string(VALUE class, VALUE schema_str)
204
211
  xmlResetLastError();
205
212
  xparser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), (int)strlen(StringValuePtr(schema_str)));
206
213
  if (!xparser)
207
- rxml_raise(&xmlLastError);
214
+ rxml_raise(xmlGetLastError());
208
215
 
209
216
  return rxml_schema_init(class, xparser);
210
217
  }
@@ -219,7 +226,7 @@ static VALUE rxml_schema_document(VALUE self)
219
226
  {
220
227
  xmlSchemaPtr xschema;
221
228
 
222
- Data_Get_Struct(self, xmlSchema, xschema);
229
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
223
230
 
224
231
  return rxml_node_wrap(xmlDocGetRootElement(xschema->doc));
225
232
  }
@@ -254,7 +261,7 @@ static VALUE rxml_schema_namespaces(VALUE self)
254
261
  VALUE result;
255
262
  xmlSchemaPtr xschema;
256
263
 
257
- Data_Get_Struct(self, xmlSchema, xschema);
264
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
258
265
 
259
266
  result = rb_ary_new();
260
267
  xmlHashScan(xschema->schemasImports, (xmlHashScanner)scan_namespaces, (void *)result);
@@ -273,7 +280,7 @@ static VALUE rxml_schema_elements(VALUE self)
273
280
  VALUE result = rb_hash_new();
274
281
  xmlSchemaPtr xschema;
275
282
 
276
- Data_Get_Struct(self, xmlSchema, xschema);
283
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
277
284
  xmlHashScan(xschema->elemDecl, (xmlHashScanner)scan_schema_element, (void *)result);
278
285
 
279
286
  return result;
@@ -300,7 +307,7 @@ static VALUE rxml_schema_imported_ns_elements(VALUE self)
300
307
  xmlSchemaPtr xschema;
301
308
  VALUE result = rb_hash_new();
302
309
 
303
- Data_Get_Struct(self, xmlSchema, xschema);
310
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
304
311
 
305
312
  if (xschema)
306
313
  {
@@ -321,7 +328,7 @@ static VALUE rxml_schema_types(VALUE self)
321
328
  VALUE result = rb_hash_new();
322
329
  xmlSchemaPtr xschema;
323
330
 
324
- Data_Get_Struct(self, xmlSchema, xschema);
331
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
325
332
 
326
333
  if (xschema != NULL && xschema->typeDecl != NULL)
327
334
  {
@@ -350,7 +357,7 @@ static VALUE rxml_schema_imported_types(VALUE self)
350
357
  xmlSchemaPtr xschema;
351
358
  VALUE result = rb_hash_new();
352
359
 
353
- Data_Get_Struct(self, xmlSchema, xschema);
360
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
354
361
 
355
362
  if (xschema)
356
363
  {
@@ -381,7 +388,7 @@ static VALUE rxml_schema_imported_ns_types(VALUE self)
381
388
  xmlSchemaPtr xschema;
382
389
  VALUE result = rb_hash_new();
383
390
 
384
- Data_Get_Struct(self, xmlSchema, xschema);
391
+ TypedData_Get_Struct(self, xmlSchema, &rxml_schema_type, xschema);
385
392
 
386
393
  if (xschema)
387
394
  {
@@ -1,25 +1,26 @@
1
- #ifndef __RXML_SCHEMA__
2
- #define __RXML_SCHEMA__
3
-
4
- #include <libxml/schemasInternals.h>
5
- #include <libxml/xmlschemastypes.h>
6
-
7
- typedef struct _xmlSchemaItemList xmlSchemaItemList;
8
- typedef xmlSchemaItemList *xmlSchemaItemListPtr;
9
- struct _xmlSchemaItemList {
10
- void **items;
11
- /* used for dynamic addition of schemata */
12
- int nbItems;
13
- /* used for dynamic addition of schemata */
14
- int sizeItems; /* used for dynamic addition of schemata */
15
- };
16
-
17
- #define QNIL_OR_STRING(slot) \
18
- (slot == NULL) ? Qnil : rb_str_new2((const char *)slot)
19
-
20
- extern VALUE cXMLSchema;
21
-
22
- void rxml_init_schema(void);
23
-
24
- #endif
25
-
1
+ #ifndef __RXML_SCHEMA__
2
+ #define __RXML_SCHEMA__
3
+
4
+ #include <libxml/schemasInternals.h>
5
+ #include <libxml/xmlschemastypes.h>
6
+
7
+ typedef struct _xmlSchemaItemList xmlSchemaItemList;
8
+ typedef xmlSchemaItemList *xmlSchemaItemListPtr;
9
+ struct _xmlSchemaItemList {
10
+ void **items;
11
+ /* used for dynamic addition of schemata */
12
+ int nbItems;
13
+ /* used for dynamic addition of schemata */
14
+ int sizeItems; /* used for dynamic addition of schemata */
15
+ };
16
+
17
+ #define QNIL_OR_STRING(slot) \
18
+ (slot == NULL) ? Qnil : rb_str_new2((const char *)slot)
19
+
20
+ extern VALUE cXMLSchema;
21
+ extern const rb_data_type_t rxml_schema_type;
22
+
23
+ void rxml_init_schema(void);
24
+
25
+ #endif
26
+
@@ -50,11 +50,11 @@ struct _xmlSchemaAttributeUseProhib {
50
50
 
51
51
  VALUE cXMLSchemaAttribute;
52
52
 
53
- static void rxml_schema_attribute_free(xmlSchemaAttributeUsePtr attr)
54
- {
55
- attr = NULL;
56
- xmlFree(attr);
57
- }
53
+ static const rb_data_type_t rxml_schema_attribute_type = {
54
+ "XML::Schema::Attribute",
55
+ {NULL, NULL, NULL},
56
+ NULL, NULL, 0
57
+ };
58
58
 
59
59
  VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr)
60
60
  {
@@ -64,7 +64,7 @@ VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr)
64
64
  if (!attr)
65
65
  rb_raise(rb_eArgError, "XML::Schema::Attribute required!");
66
66
 
67
- result = Data_Wrap_Struct(cXMLSchemaAttribute, NULL, rxml_schema_attribute_free, attr);
67
+ result = TypedData_Wrap_Struct(cXMLSchemaAttribute, &rxml_schema_attribute_type, attr);
68
68
 
69
69
  if (attr->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
70
70
  tns_str = ((xmlSchemaAttributeUseProhibPtr) attr)->targetNamespace;
@@ -89,7 +89,7 @@ static VALUE rxml_schema_attribute_node(VALUE self)
89
89
  {
90
90
  xmlSchemaAttributeUsePtr attr;
91
91
 
92
- Data_Get_Struct(self, xmlSchemaAttributeUse, attr);
92
+ TypedData_Get_Struct(self, xmlSchemaAttributeUse, &rxml_schema_attribute_type, attr);
93
93
 
94
94
  return rxml_node_wrap(attr->node);
95
95
  }
@@ -1,37 +1,37 @@
1
- #ifndef __RXML_SCHEMA_ATTRIBUTE__
2
- #define __RXML_SCHEMA_ATTRIBUTE__
3
-
4
- #include "ruby_xml_schema.h"
5
-
6
- extern VALUE cXMLSchemaAttribute;
7
-
8
- /**
9
- * xmlSchemaAttributeUsePtr:
10
- *
11
- * The abstract base type for tree-like structured schema components.
12
- * (Extends xmlSchemaTreeItem)
13
- */
14
- typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse;
15
- typedef xmlSchemaAttributeUse *xmlSchemaAttributeUsePtr;
16
- struct _xmlSchemaAttributeUse {
17
- xmlSchemaTypeType type;
18
- xmlSchemaAnnotPtr annot;
19
- xmlSchemaAttributeUsePtr next; /* The next attr. use. */
20
- /*
21
- * The attr. decl. OR a QName-ref. to an attr. decl. OR
22
- * a QName-ref. to an attribute group definition.
23
- */
24
- xmlSchemaAttributePtr attrDecl;
25
-
26
- int flags;
27
- xmlNodePtr node;
28
- int occurs;
29
- /* required, optional */
30
- const xmlChar *defValue;
31
- xmlSchemaValPtr defVal;
32
- };
33
-
34
- void rxml_init_schema_attribute(void);
35
- VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr);
36
-
37
- #endif
1
+ #ifndef __RXML_SCHEMA_ATTRIBUTE__
2
+ #define __RXML_SCHEMA_ATTRIBUTE__
3
+
4
+ #include "ruby_xml_schema.h"
5
+
6
+ extern VALUE cXMLSchemaAttribute;
7
+
8
+ /**
9
+ * xmlSchemaAttributeUsePtr:
10
+ *
11
+ * The abstract base type for tree-like structured schema components.
12
+ * (Extends xmlSchemaTreeItem)
13
+ */
14
+ typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse;
15
+ typedef xmlSchemaAttributeUse *xmlSchemaAttributeUsePtr;
16
+ struct _xmlSchemaAttributeUse {
17
+ xmlSchemaTypeType type;
18
+ xmlSchemaAnnotPtr annot;
19
+ xmlSchemaAttributeUsePtr next; /* The next attr. use. */
20
+ /*
21
+ * The attr. decl. OR a QName-ref. to an attr. decl. OR
22
+ * a QName-ref. to an attribute group definition.
23
+ */
24
+ xmlSchemaAttributePtr attrDecl;
25
+
26
+ int flags;
27
+ xmlNodePtr node;
28
+ int occurs;
29
+ /* required, optional */
30
+ const xmlChar *defValue;
31
+ xmlSchemaValPtr defVal;
32
+ };
33
+
34
+ void rxml_init_schema_attribute(void);
35
+ VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr);
36
+
37
+ #endif
@@ -4,11 +4,11 @@
4
4
 
5
5
  VALUE cXMLSchemaElement;
6
6
 
7
- static void rxml_schema_element_free(xmlSchemaElementPtr xschema_element)
8
- {
9
- xschema_element = NULL;
10
- xmlFree(xschema_element);
11
- }
7
+ static const rb_data_type_t rxml_schema_element_type = {
8
+ "XML::Schema::Element",
9
+ {NULL, NULL, NULL},
10
+ NULL, NULL, 0
11
+ };
12
12
 
13
13
  VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelem)
14
14
  {
@@ -17,7 +17,7 @@ VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelem)
17
17
  if (!xelem)
18
18
  rb_raise(rb_eArgError, "XML::Schema::Element is required!");
19
19
 
20
- result = Data_Wrap_Struct(cXMLSchemaElement, NULL, rxml_schema_element_free, xelem);
20
+ result = TypedData_Wrap_Struct(cXMLSchemaElement, &rxml_schema_element_type, xelem);
21
21
 
22
22
  rb_iv_set(result, "@name", QNIL_OR_STRING(xelem->name));
23
23
  rb_iv_set(result, "@value", QNIL_OR_STRING(xelem->value));
@@ -31,7 +31,7 @@ static VALUE rxml_schema_element_node(VALUE self)
31
31
  {
32
32
  xmlSchemaElementPtr xelem;
33
33
 
34
- Data_Get_Struct(self, xmlSchemaElement, xelem);
34
+ TypedData_Get_Struct(self, xmlSchemaElement, &rxml_schema_element_type, xelem);
35
35
 
36
36
  return rxml_node_wrap(xelem->node);
37
37
  }
@@ -41,7 +41,7 @@ static VALUE rxml_schema_element_annot(VALUE self)
41
41
  xmlSchemaElementPtr xelem;
42
42
  VALUE annotation = Qnil;
43
43
 
44
- Data_Get_Struct(self, xmlSchemaElement, xelem);
44
+ TypedData_Get_Struct(self, xmlSchemaElement, &rxml_schema_element_type, xelem);
45
45
 
46
46
  if ((xelem->annot != NULL) && (xelem->annot->content != NULL))
47
47
  {
@@ -1,11 +1,11 @@
1
- #ifndef __RXML_SCHEMA_ELEMENT__
2
- #define __RXML_SCHEMA_ELEMENT__
3
-
4
- #include "ruby_xml_schema.h"
5
-
6
- extern VALUE cXMLSchemaElement;
7
-
8
- VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelement);
9
- void rxml_init_schema_element(void);
10
-
11
- #endif
1
+ #ifndef __RXML_SCHEMA_ELEMENT__
2
+ #define __RXML_SCHEMA_ELEMENT__
3
+
4
+ #include "ruby_xml_schema.h"
5
+
6
+ extern VALUE cXMLSchemaElement;
7
+
8
+ VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelement);
9
+ void rxml_init_schema_element(void);
10
+
11
+ #endif