libxml-ruby 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +15 -0
- data/README.rdoc +7 -7
- data/Rakefile +80 -78
- data/ext/libxml/extconf.h +4 -0
- data/ext/libxml/extconf.rb +57 -116
- data/ext/libxml/libxml.c +4 -0
- data/ext/libxml/ruby_xml.c +977 -893
- data/ext/libxml/ruby_xml.h +20 -10
- data/ext/libxml/ruby_xml_attr.c +333 -333
- data/ext/libxml/ruby_xml_attr_decl.c +2 -2
- data/ext/libxml/ruby_xml_cbg.c +85 -85
- data/ext/libxml/ruby_xml_document.c +1133 -1147
- data/ext/libxml/ruby_xml_dtd.c +261 -268
- data/ext/libxml/ruby_xml_encoding.c +262 -260
- data/ext/libxml/ruby_xml_encoding.h +19 -19
- data/ext/libxml/ruby_xml_html_parser_context.c +337 -338
- data/ext/libxml/ruby_xml_input_cbg.c +191 -191
- data/ext/libxml/ruby_xml_io.c +52 -50
- data/ext/libxml/ruby_xml_namespace.c +2 -2
- data/ext/libxml/ruby_xml_node.c +1446 -1452
- data/ext/libxml/ruby_xml_parser_context.c +999 -1001
- data/ext/libxml/ruby_xml_reader.c +1226 -1228
- data/ext/libxml/ruby_xml_relaxng.c +110 -111
- data/ext/libxml/ruby_xml_sax2_handler.c +326 -328
- data/ext/libxml/ruby_xml_schema.c +300 -301
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/ext/libxml/ruby_xml_writer.c +14 -15
- data/ext/libxml/ruby_xml_xpath.c +188 -188
- data/ext/libxml/ruby_xml_xpath_context.c +360 -361
- data/ext/libxml/ruby_xml_xpath_object.c +335 -335
- data/libxml-ruby.gemspec +47 -44
- data/test/tc_attr.rb +5 -7
- data/test/tc_attr_decl.rb +5 -6
- data/test/tc_attributes.rb +1 -2
- data/test/tc_canonicalize.rb +1 -2
- data/test/tc_deprecated_require.rb +1 -2
- data/test/tc_document.rb +4 -5
- data/test/tc_document_write.rb +2 -3
- data/test/tc_dtd.rb +4 -5
- data/test/tc_encoding.rb +126 -126
- data/test/tc_encoding_sax.rb +4 -3
- data/test/tc_error.rb +14 -15
- data/test/tc_html_parser.rb +15 -7
- data/test/tc_html_parser_context.rb +1 -2
- data/test/tc_namespace.rb +2 -3
- data/test/tc_namespaces.rb +5 -6
- data/test/tc_node.rb +2 -3
- data/test/tc_node_cdata.rb +2 -3
- data/test/tc_node_comment.rb +1 -2
- data/test/tc_node_copy.rb +1 -2
- data/test/tc_node_edit.rb +5 -7
- data/test/tc_node_pi.rb +1 -2
- data/test/tc_node_text.rb +2 -3
- data/test/tc_node_write.rb +2 -3
- data/test/tc_node_xlink.rb +1 -2
- data/test/tc_parser.rb +18 -24
- data/test/tc_parser_context.rb +6 -7
- data/test/tc_properties.rb +1 -2
- data/test/tc_reader.rb +9 -10
- data/test/tc_relaxng.rb +4 -5
- data/test/tc_sax_parser.rb +9 -10
- data/test/tc_schema.rb +4 -5
- data/test/tc_traversal.rb +1 -2
- data/test/tc_writer.rb +1 -2
- data/test/tc_xinclude.rb +1 -2
- data/test/tc_xml.rb +1 -2
- data/test/tc_xpath.rb +8 -9
- data/test/tc_xpath_context.rb +3 -4
- data/test/tc_xpath_expression.rb +3 -4
- data/test/tc_xpointer.rb +1 -3
- data/test/test_helper.rb +3 -1
- data/test/test_suite.rb +0 -1
- metadata +47 -11
- data/test/etc_doc_to_s.rb +0 -21
- data/test/ets_doc_file.rb +0 -17
- data/test/ets_doc_to_s.rb +0 -23
- data/test/ets_gpx.rb +0 -28
- data/test/ets_node_gc.rb +0 -23
- data/test/ets_test.xml +0 -2
- data/test/ets_tsr.rb +0 -11
@@ -1,301 +1,300 @@
|
|
1
|
-
#include "ruby_libxml.h"
|
2
|
-
#define LIBXML_OUTPUT_ENABLED
|
3
|
-
#define DUMP_CONTENT_MODEL
|
4
|
-
#include "ruby_xml_schema.h"
|
5
|
-
|
6
|
-
#include "ruby_xml_schema_type.h"
|
7
|
-
#include "ruby_xml_schema_element.h"
|
8
|
-
#include "ruby_xml_schema_attribute.h"
|
9
|
-
#include "ruby_xml_schema_facet.h"
|
10
|
-
|
11
|
-
|
12
|
-
/*
|
13
|
-
* Document-class: LibXML::XML::Schema
|
14
|
-
*
|
15
|
-
* The XML::Schema class is used to prepare XML Schemas for validation of xml
|
16
|
-
* documents.
|
17
|
-
*
|
18
|
-
* Schemas can be created from XML documents, strinings or URIs using the
|
19
|
-
* corresponding methods (new for URIs).
|
20
|
-
*
|
21
|
-
* Once a schema is prepared, an XML document can be validated by the
|
22
|
-
* XML::Document#validate_schema method providing the XML::Schema object
|
23
|
-
* as parameter. The method return true if the document validates, false
|
24
|
-
* otherwise.
|
25
|
-
*
|
26
|
-
* Basic usage:
|
27
|
-
*
|
28
|
-
* # parse schema as xml document
|
29
|
-
* schema_document = XML::Document.file('schema.rng')
|
30
|
-
*
|
31
|
-
* # prepare schema for validation
|
32
|
-
* schema = XML::Schema.document(schema_document)
|
33
|
-
*
|
34
|
-
* # parse xml document to be validated
|
35
|
-
* instance = XML::Document.file('instance.xml')
|
36
|
-
*
|
37
|
-
* # validate
|
38
|
-
* instance.validate_schema(schema)
|
39
|
-
*/
|
40
|
-
|
41
|
-
VALUE cXMLSchema;
|
42
|
-
|
43
|
-
static void rxml_schema_free(xmlSchemaPtr xschema)
|
44
|
-
{
|
45
|
-
xmlSchemaFree(xschema);
|
46
|
-
}
|
47
|
-
|
48
|
-
VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
|
49
|
-
{
|
50
|
-
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
51
|
-
}
|
52
|
-
|
53
|
-
|
54
|
-
/*
|
55
|
-
* call-seq:
|
56
|
-
* XML::Schema.initialize(schema_uri) -> schema
|
57
|
-
*
|
58
|
-
* Create a new schema from the specified URI.
|
59
|
-
*/
|
60
|
-
static VALUE rxml_schema_init_from_uri(VALUE class, VALUE uri)
|
61
|
-
{
|
62
|
-
xmlSchemaParserCtxtPtr xparser;
|
63
|
-
xmlSchemaPtr xschema;
|
64
|
-
|
65
|
-
Check_Type(uri, T_STRING);
|
66
|
-
|
67
|
-
xparser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
|
68
|
-
xschema = xmlSchemaParse(xparser);
|
69
|
-
xmlSchemaFreeParserCtxt(xparser);
|
70
|
-
|
71
|
-
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
72
|
-
}
|
73
|
-
|
74
|
-
/*
|
75
|
-
* call-seq:
|
76
|
-
* XML::Schema.document(document) -> schema
|
77
|
-
*
|
78
|
-
* Create a new schema from the specified document.
|
79
|
-
*/
|
80
|
-
static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
|
81
|
-
{
|
82
|
-
xmlDocPtr xdoc;
|
83
|
-
xmlSchemaPtr xschema;
|
84
|
-
xmlSchemaParserCtxtPtr xparser;
|
85
|
-
|
86
|
-
Data_Get_Struct(document, xmlDoc, xdoc);
|
87
|
-
|
88
|
-
xparser = xmlSchemaNewDocParserCtxt(xdoc);
|
89
|
-
xschema = xmlSchemaParse(xparser);
|
90
|
-
xmlSchemaFreeParserCtxt(xparser);
|
91
|
-
|
92
|
-
if (xschema == NULL)
|
93
|
-
return Qnil;
|
94
|
-
|
95
|
-
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
96
|
-
}
|
97
|
-
|
98
|
-
/*
|
99
|
-
* call-seq:
|
100
|
-
* XML::Schema.from_string("schema_data") -> "value"
|
101
|
-
*
|
102
|
-
* Create a new schema using the specified string.
|
103
|
-
*/
|
104
|
-
static VALUE rxml_schema_init_from_string(VALUE self, VALUE schema_str)
|
105
|
-
{
|
106
|
-
xmlSchemaParserCtxtPtr xparser;
|
107
|
-
xmlSchemaPtr xschema;
|
108
|
-
|
109
|
-
Check_Type(schema_str, T_STRING);
|
110
|
-
|
111
|
-
xparser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
VALUE
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
types
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
VALUE
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
elements
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
{
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
cXMLSchema
|
282
|
-
rb_define_singleton_method(cXMLSchema, "
|
283
|
-
rb_define_singleton_method(cXMLSchema, "
|
284
|
-
|
285
|
-
|
286
|
-
rb_define_method(cXMLSchema, "
|
287
|
-
rb_define_method(cXMLSchema, "
|
288
|
-
rb_define_method(cXMLSchema, "
|
289
|
-
rb_define_method(cXMLSchema, "
|
290
|
-
|
291
|
-
|
292
|
-
rb_define_method(cXMLSchema, "
|
293
|
-
rb_define_method(cXMLSchema, "
|
294
|
-
rb_define_method(cXMLSchema, "
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
}
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#define LIBXML_OUTPUT_ENABLED
|
3
|
+
#define DUMP_CONTENT_MODEL
|
4
|
+
#include "ruby_xml_schema.h"
|
5
|
+
|
6
|
+
#include "ruby_xml_schema_type.h"
|
7
|
+
#include "ruby_xml_schema_element.h"
|
8
|
+
#include "ruby_xml_schema_attribute.h"
|
9
|
+
#include "ruby_xml_schema_facet.h"
|
10
|
+
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Document-class: LibXML::XML::Schema
|
14
|
+
*
|
15
|
+
* The XML::Schema class is used to prepare XML Schemas for validation of xml
|
16
|
+
* documents.
|
17
|
+
*
|
18
|
+
* Schemas can be created from XML documents, strinings or URIs using the
|
19
|
+
* corresponding methods (new for URIs).
|
20
|
+
*
|
21
|
+
* Once a schema is prepared, an XML document can be validated by the
|
22
|
+
* XML::Document#validate_schema method providing the XML::Schema object
|
23
|
+
* as parameter. The method return true if the document validates, false
|
24
|
+
* otherwise.
|
25
|
+
*
|
26
|
+
* Basic usage:
|
27
|
+
*
|
28
|
+
* # parse schema as xml document
|
29
|
+
* schema_document = XML::Document.file('schema.rng')
|
30
|
+
*
|
31
|
+
* # prepare schema for validation
|
32
|
+
* schema = XML::Schema.document(schema_document)
|
33
|
+
*
|
34
|
+
* # parse xml document to be validated
|
35
|
+
* instance = XML::Document.file('instance.xml')
|
36
|
+
*
|
37
|
+
* # validate
|
38
|
+
* instance.validate_schema(schema)
|
39
|
+
*/
|
40
|
+
|
41
|
+
VALUE cXMLSchema;
|
42
|
+
|
43
|
+
static void rxml_schema_free(xmlSchemaPtr xschema)
|
44
|
+
{
|
45
|
+
xmlSchemaFree(xschema);
|
46
|
+
}
|
47
|
+
|
48
|
+
VALUE rxml_wrap_schema(xmlSchemaPtr xschema)
|
49
|
+
{
|
50
|
+
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
/*
|
55
|
+
* call-seq:
|
56
|
+
* XML::Schema.initialize(schema_uri) -> schema
|
57
|
+
*
|
58
|
+
* Create a new schema from the specified URI.
|
59
|
+
*/
|
60
|
+
static VALUE rxml_schema_init_from_uri(VALUE class, VALUE uri)
|
61
|
+
{
|
62
|
+
xmlSchemaParserCtxtPtr xparser;
|
63
|
+
xmlSchemaPtr xschema;
|
64
|
+
|
65
|
+
Check_Type(uri, T_STRING);
|
66
|
+
|
67
|
+
xparser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
|
68
|
+
xschema = xmlSchemaParse(xparser);
|
69
|
+
xmlSchemaFreeParserCtxt(xparser);
|
70
|
+
|
71
|
+
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
72
|
+
}
|
73
|
+
|
74
|
+
/*
|
75
|
+
* call-seq:
|
76
|
+
* XML::Schema.document(document) -> schema
|
77
|
+
*
|
78
|
+
* Create a new schema from the specified document.
|
79
|
+
*/
|
80
|
+
static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
|
81
|
+
{
|
82
|
+
xmlDocPtr xdoc;
|
83
|
+
xmlSchemaPtr xschema;
|
84
|
+
xmlSchemaParserCtxtPtr xparser;
|
85
|
+
|
86
|
+
Data_Get_Struct(document, xmlDoc, xdoc);
|
87
|
+
|
88
|
+
xparser = xmlSchemaNewDocParserCtxt(xdoc);
|
89
|
+
xschema = xmlSchemaParse(xparser);
|
90
|
+
xmlSchemaFreeParserCtxt(xparser);
|
91
|
+
|
92
|
+
if (xschema == NULL)
|
93
|
+
return Qnil;
|
94
|
+
|
95
|
+
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
96
|
+
}
|
97
|
+
|
98
|
+
/*
|
99
|
+
* call-seq:
|
100
|
+
* XML::Schema.from_string("schema_data") -> "value"
|
101
|
+
*
|
102
|
+
* Create a new schema using the specified string.
|
103
|
+
*/
|
104
|
+
static VALUE rxml_schema_init_from_string(VALUE self, VALUE schema_str)
|
105
|
+
{
|
106
|
+
xmlSchemaParserCtxtPtr xparser;
|
107
|
+
xmlSchemaPtr xschema;
|
108
|
+
|
109
|
+
Check_Type(schema_str, T_STRING);
|
110
|
+
|
111
|
+
xparser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), (int)strlen(StringValuePtr(schema_str)));
|
112
|
+
xschema = xmlSchemaParse(xparser);
|
113
|
+
xmlSchemaFreeParserCtxt(xparser);
|
114
|
+
|
115
|
+
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
static VALUE rxml_schema_target_namespace(VALUE self)
|
120
|
+
{
|
121
|
+
xmlSchemaPtr xschema;
|
122
|
+
|
123
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
124
|
+
|
125
|
+
QNIL_OR_STRING(xschema->targetNamespace)
|
126
|
+
}
|
127
|
+
|
128
|
+
static VALUE rxml_schema_name(VALUE self)
|
129
|
+
{
|
130
|
+
xmlSchemaPtr xschema;
|
131
|
+
|
132
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
133
|
+
|
134
|
+
QNIL_OR_STRING(xschema->name)
|
135
|
+
}
|
136
|
+
|
137
|
+
static VALUE rxml_schema_version(VALUE self)
|
138
|
+
{
|
139
|
+
xmlSchemaPtr xschema;
|
140
|
+
|
141
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
142
|
+
|
143
|
+
QNIL_OR_STRING(xschema->version)
|
144
|
+
}
|
145
|
+
|
146
|
+
static VALUE rxml_schema_id(VALUE self)
|
147
|
+
{
|
148
|
+
xmlSchemaPtr xschema;
|
149
|
+
|
150
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
151
|
+
|
152
|
+
QNIL_OR_STRING(xschema->id)
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
static VALUE rxml_schema_document(VALUE self)
|
157
|
+
{
|
158
|
+
xmlSchemaPtr xschema;
|
159
|
+
|
160
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
161
|
+
|
162
|
+
return rxml_node_wrap(xmlDocGetRootElement(xschema->doc));
|
163
|
+
}
|
164
|
+
|
165
|
+
static void storeNs(xmlSchemaImportPtr import, VALUE self, xmlChar *nsname)
|
166
|
+
{
|
167
|
+
VALUE schemas;
|
168
|
+
xmlNodePtr xnode;
|
169
|
+
xmlNsPtr xns;
|
170
|
+
|
171
|
+
schemas = rb_iv_get(self, "@namespaces");
|
172
|
+
if (import->doc) {
|
173
|
+
xnode = xmlDocGetRootElement(import->doc);
|
174
|
+
|
175
|
+
xns = xnode->nsDef;
|
176
|
+
|
177
|
+
while (xns) {
|
178
|
+
VALUE anamespace = rxml_namespace_wrap(xns);
|
179
|
+
rb_ary_push(schemas, anamespace);
|
180
|
+
xns = xns->next;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
static VALUE rxml_schema_namespaces(VALUE self)
|
186
|
+
{
|
187
|
+
VALUE schemas;
|
188
|
+
xmlSchemaPtr xschema;
|
189
|
+
|
190
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
191
|
+
|
192
|
+
if (rb_iv_get(self, "@namespaces") == Qnil) {
|
193
|
+
schemas = rb_ary_new();
|
194
|
+
rb_iv_set(self, "@namespaces", schemas);
|
195
|
+
xmlHashScan(xschema->schemasImports, (xmlHashScanner) storeNs, (void *)self);
|
196
|
+
}
|
197
|
+
|
198
|
+
return rb_iv_get(self, "@namespaces");
|
199
|
+
}
|
200
|
+
|
201
|
+
static void storeType(xmlSchemaTypePtr type, VALUE self, xmlChar *name)
|
202
|
+
{
|
203
|
+
VALUE types;
|
204
|
+
VALUE rtype;
|
205
|
+
|
206
|
+
types = rb_iv_get(self, "@types");
|
207
|
+
rtype = rxml_wrap_schema_type(type);
|
208
|
+
|
209
|
+
rb_hash_aset(types, rb_str_new2((const char*)name), rtype);
|
210
|
+
}
|
211
|
+
|
212
|
+
static VALUE rxml_schema_collect_types(VALUE self);
|
213
|
+
|
214
|
+
static VALUE rxml_schema_types(VALUE self)
|
215
|
+
{
|
216
|
+
VALUE types;
|
217
|
+
xmlSchemaPtr xschema;
|
218
|
+
|
219
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
220
|
+
|
221
|
+
if (rb_iv_get(self, "@types") == Qnil) {
|
222
|
+
types = rb_hash_new();
|
223
|
+
rb_iv_set(self, "@types", types);
|
224
|
+
rxml_schema_collect_types(self);
|
225
|
+
if(xschema != NULL && xschema->typeDecl != NULL)
|
226
|
+
xmlHashScan(xschema->typeDecl, (xmlHashScanner) storeType, (void *)self);
|
227
|
+
}
|
228
|
+
|
229
|
+
return rb_iv_get(self, "@types");
|
230
|
+
}
|
231
|
+
|
232
|
+
static void storeElement(xmlSchemaElementPtr element, VALUE self, xmlChar *name)
|
233
|
+
{
|
234
|
+
VALUE elements;
|
235
|
+
VALUE relement;
|
236
|
+
|
237
|
+
elements = rb_iv_get(self, "@elements");
|
238
|
+
relement = rxml_wrap_schema_element(element);
|
239
|
+
rb_hash_aset(elements, rb_str_new2((const char*)name), relement);
|
240
|
+
}
|
241
|
+
|
242
|
+
static VALUE rxml_schema_elements(VALUE self)
|
243
|
+
{
|
244
|
+
VALUE elements;
|
245
|
+
xmlSchemaPtr xschema;
|
246
|
+
|
247
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
248
|
+
|
249
|
+
if (rb_iv_get(self, "@elements") == Qnil) {
|
250
|
+
elements = rb_hash_new();
|
251
|
+
rb_iv_set(self, "@elements", elements);
|
252
|
+
xmlHashScan(xschema->elemDecl, (xmlHashScanner) storeElement, (void *)self);
|
253
|
+
}
|
254
|
+
|
255
|
+
return rb_iv_get(self, "@elements");
|
256
|
+
}
|
257
|
+
|
258
|
+
static void collectSchemaTypes(xmlSchemaImportPtr import, VALUE self)
|
259
|
+
{
|
260
|
+
if (import->imported && import->schema) {
|
261
|
+
xmlHashScan(import->schema->typeDecl, (xmlHashScanner) storeType, (void *)self);
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
static VALUE rxml_schema_collect_types(VALUE self)
|
266
|
+
{
|
267
|
+
xmlSchemaPtr xschema;
|
268
|
+
|
269
|
+
Data_Get_Struct(self, xmlSchema, xschema);
|
270
|
+
|
271
|
+
if(xschema){
|
272
|
+
xmlHashScan(xschema->schemasImports, (xmlHashScanner) collectSchemaTypes, (void *)self);
|
273
|
+
}
|
274
|
+
|
275
|
+
return Qnil;
|
276
|
+
}
|
277
|
+
|
278
|
+
void rxml_init_schema(void)
|
279
|
+
{
|
280
|
+
cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
|
281
|
+
rb_define_singleton_method(cXMLSchema, "new", rxml_schema_init_from_uri, 1);
|
282
|
+
rb_define_singleton_method(cXMLSchema, "from_string", rxml_schema_init_from_string, 1);
|
283
|
+
rb_define_singleton_method(cXMLSchema, "document", rxml_schema_init_from_document, 1);
|
284
|
+
|
285
|
+
rb_define_method(cXMLSchema, "target_namespace", rxml_schema_target_namespace, 0);
|
286
|
+
rb_define_method(cXMLSchema, "name", rxml_schema_name, 0);
|
287
|
+
rb_define_method(cXMLSchema, "id", rxml_schema_id, 0);
|
288
|
+
rb_define_method(cXMLSchema, "version", rxml_schema_version, 0);
|
289
|
+
rb_define_method(cXMLSchema, "document", rxml_schema_document, 0);
|
290
|
+
|
291
|
+
rb_define_method(cXMLSchema, "_namespaces", rxml_schema_namespaces, 0);
|
292
|
+
rb_define_method(cXMLSchema, "_collect_types", rxml_schema_collect_types, 0);
|
293
|
+
rb_define_method(cXMLSchema, "types", rxml_schema_types, 0);
|
294
|
+
rb_define_method(cXMLSchema, "elements", rxml_schema_elements, 0);
|
295
|
+
|
296
|
+
rxml_init_schema_facet();
|
297
|
+
rxml_init_schema_element();
|
298
|
+
rxml_init_schema_attribute();
|
299
|
+
rxml_init_schema_type();
|
300
|
+
}
|