libxml-ruby 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +42 -0
- data/README +123 -117
- data/doc/classes/XML.html +226 -0
- data/doc/classes/XML/Attr.html +969 -0
- data/doc/classes/XML/Attributes.html +487 -0
- data/doc/classes/XML/Document.html +1423 -0
- data/doc/classes/XML/Dtd.html +159 -0
- data/doc/classes/XML/Error.html +111 -0
- data/doc/classes/XML/HTMLParser.html +330 -0
- data/doc/classes/XML/InputCallbacks.html +154 -0
- data/doc/classes/XML/NS.html +366 -0
- data/doc/classes/XML/Node.html +3292 -0
- data/doc/classes/XML/Node/FailedModify.html +111 -0
- data/doc/classes/XML/Node/Set.html +435 -0
- data/doc/classes/XML/Node/SetNamespace.html +111 -0
- data/doc/classes/XML/Node/UnknownType.html +111 -0
- data/doc/classes/XML/Parser.html +2178 -0
- data/doc/classes/XML/Parser/Context.html +1233 -0
- data/doc/classes/XML/Parser/ParseError.html +111 -0
- data/doc/classes/XML/Reader.html +2173 -0
- data/doc/classes/XML/SaxParser.html +396 -0
- data/doc/classes/XML/SiblingEnum.html +142 -0
- data/doc/classes/XML/State.html +118 -0
- data/doc/classes/XML/Tree.html +224 -0
- data/doc/classes/XML/XInclude.html +117 -0
- data/doc/classes/XML/XInclude/Error.html +111 -0
- data/doc/classes/XML/XMLParserOptions.html +198 -0
- data/doc/classes/XML/XPath.html +269 -0
- data/doc/classes/XML/XPath/Context.html +193 -0
- data/doc/classes/XML/XPath/InvalidPath.html +111 -0
- data/doc/classes/XML/XPath/Object.html +439 -0
- data/doc/classes/XML/XPointer.html +164 -0
- data/doc/classes/XML/XPointer/Context.html +117 -0
- data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
- data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
- data/doc/classes/singleton.html +114 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGES.html +375 -0
- data/doc/files/LICENSE.html +133 -0
- data/doc/files/README.html +279 -0
- data/doc/files/VERSION.html +107 -0
- data/doc/files/ext/libxml/cbg_c.html +101 -0
- data/doc/files/ext/libxml/libxml_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
- data/doc/files/lib/libxml_rb.html +115 -0
- data/doc/files/lib/xml/libxml_rb.html +114 -0
- data/doc/fr_class_index.html +60 -0
- data/doc/fr_file_index.html +56 -0
- data/doc/fr_method_index.html +373 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/ext/libxml/cbg.c +76 -76
- data/ext/libxml/extconf.rb +308 -308
- data/ext/libxml/libxml.c +58 -62
- data/ext/libxml/ruby_libxml.h +1 -0
- data/ext/libxml/ruby_xml_attr.c +201 -113
- data/ext/libxml/ruby_xml_attr.h +6 -9
- data/ext/libxml/ruby_xml_attributes.c +268 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_document.c +80 -66
- data/ext/libxml/ruby_xml_dtd.c +2 -2
- data/ext/libxml/ruby_xml_dtd.h +17 -17
- data/ext/libxml/ruby_xml_html_parser.c +18 -19
- data/ext/libxml/ruby_xml_html_parser.h +29 -29
- data/ext/libxml/ruby_xml_input_cbg.c +6 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_node.c +438 -536
- data/ext/libxml/ruby_xml_node.h +17 -27
- data/ext/libxml/ruby_xml_node_set.c +10 -9
- data/ext/libxml/ruby_xml_node_set.h +20 -20
- data/ext/libxml/ruby_xml_ns.c +60 -69
- data/ext/libxml/ruby_xml_ns.h +12 -21
- data/ext/libxml/ruby_xml_parser.c +54 -53
- data/ext/libxml/ruby_xml_parser.h +31 -31
- data/ext/libxml/ruby_xml_parser_context.c +37 -91
- data/ext/libxml/ruby_xml_parser_context.h +20 -22
- data/ext/libxml/ruby_xml_reader.h +14 -14
- data/ext/libxml/ruby_xml_sax_parser.c +55 -55
- data/ext/libxml/ruby_xml_sax_parser.h +56 -56
- data/ext/libxml/ruby_xml_schema.c +44 -51
- data/ext/libxml/ruby_xml_schema.h +16 -16
- data/ext/libxml/ruby_xml_state.c +35 -96
- data/ext/libxml/ruby_xml_state.h +2 -3
- data/ext/libxml/ruby_xml_tree.h +12 -12
- data/ext/libxml/ruby_xml_xinclude.h +13 -13
- data/ext/libxml/ruby_xml_xpath.c +57 -18
- data/ext/libxml/ruby_xml_xpath.h +23 -23
- data/ext/libxml/ruby_xml_xpath_context.c +11 -7
- data/ext/libxml/ruby_xml_xpath_context.h +20 -20
- data/ext/libxml/ruby_xml_xpath_object.c +9 -16
- data/ext/libxml/ruby_xml_xpath_object.h +4 -10
- data/ext/libxml/ruby_xml_xpointer.c +11 -11
- data/ext/libxml/ruby_xml_xpointer.h +27 -27
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
- data/ext/libxml/version.h +2 -2
- data/lib/libxml.rb +134 -125
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/test/ets_copy_bug.rb +1 -1
- data/test/ets_copy_bug2.rb +16 -27
- data/test/ets_doc_to_s.rb +1 -1
- data/test/ets_gpx.rb +1 -1
- data/test/ets_node_gc.rb +1 -1
- data/test/ets_tsr.rb +1 -1
- data/test/tc_well_formed.rb +1 -1
- data/test/tc_xml_attributes.rb +106 -0
- data/test/tc_xml_document.rb +10 -10
- data/test/tc_xml_document_write3.rb +1 -1
- data/test/tc_xml_dtd.rb +49 -0
- data/test/tc_xml_html_parser.rb +3 -3
- data/test/tc_xml_node.rb +69 -33
- data/test/tc_xml_node_attr.rb +170 -0
- data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
- data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
- data/test/tc_xml_node_edit.rb +91 -0
- data/test/tc_xml_parser.rb +97 -50
- data/test/tc_xml_parser_context.rb +61 -23
- data/test/tc_xml_schema.rb +39 -0
- data/test/tc_xml_xinclude.rb +5 -6
- data/test/tc_xml_xpath.rb +51 -27
- data/test/test_suite.rb +27 -0
- data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
- data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
- metadata +106 -54
- data/mingw/mingw.rake +0 -36
- data/test/dtd-test.rb +0 -24
- data/test/merge_bug.rb +0 -55
- data/test/schema-test.rb +0 -74
- data/test/tc_xml_node2.rb +0 -25
- data/test/tc_xml_node3.rb +0 -27
- data/test/tc_xml_node4.rb +0 -86
- data/test/tc_xml_node5.rb +0 -52
- data/test/tc_xml_node6.rb +0 -27
- data/test/tc_xml_node7.rb +0 -35
- data/test/tc_xml_parser2.rb +0 -16
- data/test/tc_xml_parser3.rb +0 -23
- data/test/tc_xml_parser4.rb +0 -33
- data/test/tc_xml_parser5.rb +0 -27
- data/test/tc_xml_parser6.rb +0 -23
- data/test/tc_xml_parser7.rb +0 -28
- data/test/tc_xml_parser8.rb +0 -32
- data/test/tc_xml_parser9.rb +0 -11
- data/test/tc_xml_xpath2.rb +0 -14
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
@@ -1,14 +1,14 @@
|
|
1
|
-
/* Copyright (c) 2006 Apple Computer Inc.
|
2
|
-
* Please see the LICENSE file for copyright and distribution information. */
|
3
|
-
|
4
|
-
#ifndef __RUBY_XML_READER__
|
5
|
-
#define __RUBY_XML_READER__
|
6
|
-
|
7
|
-
extern VALUE cXMLReader;
|
8
|
-
|
9
|
-
void ruby_init_xml_reader(void);
|
10
|
-
|
11
|
-
/* Exported to be used by XML::Document#reader */
|
12
|
-
VALUE ruby_xml_reader_new_walker(VALUE self, VALUE doc);
|
13
|
-
|
14
|
-
#endif /* __RUBY_XML_READER__ */
|
1
|
+
/* Copyright (c) 2006 Apple Computer Inc.
|
2
|
+
* Please see the LICENSE file for copyright and distribution information. */
|
3
|
+
|
4
|
+
#ifndef __RUBY_XML_READER__
|
5
|
+
#define __RUBY_XML_READER__
|
6
|
+
|
7
|
+
extern VALUE cXMLReader;
|
8
|
+
|
9
|
+
void ruby_init_xml_reader(void);
|
10
|
+
|
11
|
+
/* Exported to be used by XML::Document#reader */
|
12
|
+
VALUE ruby_xml_reader_new_walker(VALUE self, VALUE doc);
|
13
|
+
|
14
|
+
#endif /* __RUBY_XML_READER__ */
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_sax_parser.c
|
1
|
+
/* $Id: ruby_xml_sax_parser.c 339 2008-07-09 08:36:26Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -29,61 +29,61 @@ VALUE cbidOnExternalSubset;
|
|
29
29
|
#include "sax_parser_callbacks.inc"
|
30
30
|
|
31
31
|
void
|
32
|
-
ruby_xml_sax_parser_free(ruby_xml_sax_parser *
|
32
|
+
ruby_xml_sax_parser_free(ruby_xml_sax_parser *nodesp) {
|
33
33
|
/* Apparently this isn't needed: time will tell */
|
34
|
-
/* if (
|
35
|
-
/* xmlFreeSax_Parser(
|
34
|
+
/* if (nodesp->xsh != NULL) */
|
35
|
+
/* xmlFreeSax_Parser(nodesp->sax_parser); */
|
36
36
|
}
|
37
37
|
|
38
38
|
void
|
39
|
-
ruby_xml_sax_parser_mark(ruby_xml_sax_parser *
|
40
|
-
if (
|
41
|
-
rb_gc_mark(
|
39
|
+
ruby_xml_sax_parser_mark(ruby_xml_sax_parser *nodesp) {
|
40
|
+
if (nodesp->callbackHandler && (nodesp->callbackHandler != Qnil)) {
|
41
|
+
rb_gc_mark(nodesp->callbackHandler);
|
42
42
|
}
|
43
43
|
|
44
|
-
if (
|
45
|
-
rb_gc_mark(
|
44
|
+
if (nodesp->filename && (nodesp->filename != Qnil)) {
|
45
|
+
rb_gc_mark(nodesp->filename);
|
46
46
|
}
|
47
47
|
|
48
|
-
if (
|
49
|
-
rb_gc_mark(
|
48
|
+
if (nodesp->str && (nodesp->str != Qnil)) {
|
49
|
+
rb_gc_mark(nodesp->str);
|
50
50
|
}
|
51
51
|
}
|
52
52
|
|
53
53
|
/*
|
54
54
|
* call-seq:
|
55
|
-
* XML::SaxParser.new
|
55
|
+
* XML::SaxParser.new -> sax_parser
|
56
56
|
*
|
57
57
|
* Create a new XML::SaxParser instance.
|
58
58
|
*/
|
59
59
|
VALUE
|
60
60
|
ruby_xml_sax_parser_new(VALUE class) {
|
61
|
-
ruby_xml_sax_parser *
|
61
|
+
ruby_xml_sax_parser *nodesp;
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
nodesp = ALLOC(ruby_xml_sax_parser);
|
64
|
+
nodesp->xsh = &rubySAXHandlerStruct;
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
nodesp->callbackHandler = Qnil;
|
67
|
+
nodesp->xpc = NULL;
|
68
|
+
nodesp->filename = Qnil;
|
69
|
+
nodesp->str = Qnil;
|
70
70
|
|
71
71
|
return(Data_Wrap_Struct(class, ruby_xml_sax_parser_mark,
|
72
|
-
ruby_xml_sax_parser_free,
|
72
|
+
ruby_xml_sax_parser_free, nodesp));
|
73
73
|
}
|
74
74
|
|
75
75
|
|
76
76
|
/*
|
77
77
|
* call-seq:
|
78
|
-
* sax_parser.callbacks
|
78
|
+
* sax_parser.callbacks -> #<XML::SaxParser::Callbacks subclass>
|
79
79
|
*
|
80
80
|
* Obtain the callbacks used by this parser.
|
81
81
|
*/
|
82
82
|
VALUE
|
83
83
|
ruby_xml_sax_parser_callbacks_get(VALUE self) {
|
84
|
-
ruby_xml_sax_parser *
|
85
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
86
|
-
return(
|
84
|
+
ruby_xml_sax_parser *nodesp;
|
85
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
86
|
+
return(nodesp->callbackHandler);
|
87
87
|
}
|
88
88
|
|
89
89
|
|
@@ -92,30 +92,30 @@ ruby_xml_sax_parser_callbacks_get(VALUE self) {
|
|
92
92
|
* sax_parser.callbacks = #<XML::SaxParser::Callbacks subclass>
|
93
93
|
*
|
94
94
|
* Set the callbacks used by this parser. The value assigned to
|
95
|
-
* this
|
95
|
+
* this attributesibute will usually be an object that extends the the
|
96
96
|
* XML::SaxParser::Callbacks module, overriding the callbacks it
|
97
97
|
* wishes to process.
|
98
98
|
*/
|
99
99
|
VALUE
|
100
100
|
ruby_xml_sax_parser_callbacks_set(VALUE self, VALUE callbacks) {
|
101
|
-
ruby_xml_sax_parser *
|
102
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
103
|
-
|
104
|
-
return(
|
101
|
+
ruby_xml_sax_parser *nodesp;
|
102
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
103
|
+
nodesp->callbackHandler = callbacks;
|
104
|
+
return(nodesp->callbackHandler);
|
105
105
|
}
|
106
106
|
|
107
107
|
|
108
108
|
/*
|
109
109
|
* call-seq:
|
110
|
-
* sax_parser.filename
|
110
|
+
* sax_parser.filename -> "filename"
|
111
111
|
*
|
112
112
|
* Obtain the filename this parser reads from.
|
113
113
|
*/
|
114
114
|
VALUE
|
115
115
|
ruby_xml_sax_parser_filename_get(VALUE self) {
|
116
|
-
ruby_xml_sax_parser *
|
117
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
118
|
-
return(
|
116
|
+
ruby_xml_sax_parser *nodesp;
|
117
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
118
|
+
return(nodesp->filename);
|
119
119
|
}
|
120
120
|
|
121
121
|
|
@@ -127,35 +127,35 @@ ruby_xml_sax_parser_filename_get(VALUE self) {
|
|
127
127
|
*/
|
128
128
|
VALUE
|
129
129
|
ruby_xml_sax_parser_filename_set(VALUE self, VALUE filename) {
|
130
|
-
ruby_xml_sax_parser *
|
130
|
+
ruby_xml_sax_parser *nodesp;
|
131
131
|
Check_Type(filename, T_STRING);
|
132
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
133
|
-
|
134
|
-
return(
|
132
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
133
|
+
nodesp->filename = filename;
|
134
|
+
return(nodesp->filename);
|
135
135
|
}
|
136
136
|
|
137
137
|
|
138
138
|
/*
|
139
139
|
* call-seq:
|
140
|
-
* parser.parse
|
140
|
+
* parser.parse -> (true|false)
|
141
141
|
*
|
142
142
|
* Parse the input XML, generating callbacks to the object
|
143
|
-
* registered via the +callbacks+
|
143
|
+
* registered via the +callbacks+ attributesibute.
|
144
144
|
*/
|
145
145
|
VALUE
|
146
146
|
ruby_xml_sax_parser_parse(VALUE self) {
|
147
147
|
char *str;
|
148
148
|
int status = 1;
|
149
|
-
ruby_xml_sax_parser *
|
149
|
+
ruby_xml_sax_parser *nodesp;
|
150
150
|
|
151
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
151
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
152
152
|
|
153
|
-
if (
|
154
|
-
status = xmlSAXUserParseFile(
|
155
|
-
} else if (
|
156
|
-
str = StringValuePtr(
|
153
|
+
if (nodesp->filename != Qnil) {
|
154
|
+
status = xmlSAXUserParseFile(nodesp->xsh, nodesp, StringValuePtr(nodesp->filename));
|
155
|
+
} else if (nodesp->str != Qnil) {
|
156
|
+
str = StringValuePtr(nodesp->str);
|
157
157
|
status = //ruby_xml_document_new(cXMLDocument,
|
158
|
-
xmlSAXUserParseMemory(
|
158
|
+
xmlSAXUserParseMemory(nodesp->xsh, nodesp,
|
159
159
|
str, strlen(str)); //);
|
160
160
|
}
|
161
161
|
|
@@ -171,15 +171,15 @@ ruby_xml_sax_parser_parse(VALUE self) {
|
|
171
171
|
|
172
172
|
/*
|
173
173
|
* call-seq:
|
174
|
-
* parser.string
|
174
|
+
* parser.string -> "xml"
|
175
175
|
*
|
176
176
|
* Obtain the parser's input string.
|
177
177
|
*/
|
178
178
|
VALUE
|
179
179
|
ruby_xml_sax_parser_str_get(VALUE self) {
|
180
|
-
ruby_xml_sax_parser *
|
181
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
182
|
-
return(
|
180
|
+
ruby_xml_sax_parser *nodesp;
|
181
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
182
|
+
return(nodesp->str);
|
183
183
|
}
|
184
184
|
|
185
185
|
|
@@ -191,11 +191,11 @@ ruby_xml_sax_parser_str_get(VALUE self) {
|
|
191
191
|
*/
|
192
192
|
VALUE
|
193
193
|
ruby_xml_sax_parser_str_set(VALUE self, VALUE str) {
|
194
|
-
ruby_xml_sax_parser *
|
194
|
+
ruby_xml_sax_parser *nodesp;
|
195
195
|
Check_Type(str, T_STRING);
|
196
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
197
|
-
|
198
|
-
return(
|
196
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
197
|
+
nodesp->str = str;
|
198
|
+
return(nodesp->str);
|
199
199
|
}
|
200
200
|
|
201
201
|
|
@@ -276,7 +276,7 @@ ruby_xml_sax_callbacks_on_end_document(int argc, VALUE *argv, VALUE self) {
|
|
276
276
|
|
277
277
|
/*
|
278
278
|
* call-seq:
|
279
|
-
* callbacks.on_start_element(name,
|
279
|
+
* callbacks.on_start_element(name, attributes_hash)
|
280
280
|
*
|
281
281
|
* Called for an element start event.
|
282
282
|
*/
|
@@ -1,56 +1,56 @@
|
|
1
|
-
/* $Id: ruby_xml_sax_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_SAX_PARSER__
|
6
|
-
#define __RUBY_XML_SAX_PARSER__
|
7
|
-
|
8
|
-
extern VALUE cXMLSaxParser;
|
9
|
-
extern VALUE mXMLSaxParserCallbacks;
|
10
|
-
|
11
|
-
/*
|
12
|
-
typedef struct ruby_xml_sax_parser_callbacks {
|
13
|
-
VALUE internalSubset;
|
14
|
-
VALUE isStandalone;
|
15
|
-
VALUE hasInternalSubset;
|
16
|
-
VALUE hasExternalSubset;
|
17
|
-
VALUE resolveEntity;
|
18
|
-
VALUE getEntity;
|
19
|
-
VALUE entityDecl;
|
20
|
-
VALUE notationDecl;
|
21
|
-
VALUE attributeDecl;
|
22
|
-
VALUE elementDecl;
|
23
|
-
VALUE unparsedEntityDecl;
|
24
|
-
VALUE setDocumentLocator;
|
25
|
-
VALUE startDocument;
|
26
|
-
VALUE endDocument;
|
27
|
-
VALUE startElement;
|
28
|
-
VALUE endElement;
|
29
|
-
VALUE reference;
|
30
|
-
VALUE characters;
|
31
|
-
VALUE ignorableWhitespace;
|
32
|
-
VALUE processingInstruction;
|
33
|
-
VALUE comment;
|
34
|
-
VALUE xmlParserWarning;
|
35
|
-
VALUE xmlParserError;
|
36
|
-
VALUE xmlParserFatalError;
|
37
|
-
VALUE getParameterEntity;
|
38
|
-
VALUE cdataBlock;
|
39
|
-
VALUE externalSubset;
|
40
|
-
} ruby_xml_sax_parser_callbacks;
|
41
|
-
*/
|
42
|
-
|
43
|
-
typedef struct ruby_xml_sax_parser {
|
44
|
-
xmlParserCtxtPtr xpc;
|
45
|
-
xmlSAXHandlerPtr xsh;
|
46
|
-
//ruby_xml_sax_parser_callbacks *cbp;
|
47
|
-
VALUE callbackHandler;
|
48
|
-
VALUE filename;
|
49
|
-
VALUE str;
|
50
|
-
} ruby_xml_sax_parser;
|
51
|
-
|
52
|
-
void ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp);
|
53
|
-
void ruby_init_xml_sax_parser(void);
|
54
|
-
VALUE ruby_xml_sax_parser_new(VALUE class);
|
55
|
-
|
56
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_sax_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_SAX_PARSER__
|
6
|
+
#define __RUBY_XML_SAX_PARSER__
|
7
|
+
|
8
|
+
extern VALUE cXMLSaxParser;
|
9
|
+
extern VALUE mXMLSaxParserCallbacks;
|
10
|
+
|
11
|
+
/*
|
12
|
+
typedef struct ruby_xml_sax_parser_callbacks {
|
13
|
+
VALUE internalSubset;
|
14
|
+
VALUE isStandalone;
|
15
|
+
VALUE hasInternalSubset;
|
16
|
+
VALUE hasExternalSubset;
|
17
|
+
VALUE resolveEntity;
|
18
|
+
VALUE getEntity;
|
19
|
+
VALUE entityDecl;
|
20
|
+
VALUE notationDecl;
|
21
|
+
VALUE attributeDecl;
|
22
|
+
VALUE elementDecl;
|
23
|
+
VALUE unparsedEntityDecl;
|
24
|
+
VALUE setDocumentLocator;
|
25
|
+
VALUE startDocument;
|
26
|
+
VALUE endDocument;
|
27
|
+
VALUE startElement;
|
28
|
+
VALUE endElement;
|
29
|
+
VALUE reference;
|
30
|
+
VALUE characters;
|
31
|
+
VALUE ignorableWhitespace;
|
32
|
+
VALUE processingInstruction;
|
33
|
+
VALUE comment;
|
34
|
+
VALUE xmlParserWarning;
|
35
|
+
VALUE xmlParserError;
|
36
|
+
VALUE xmlParserFatalError;
|
37
|
+
VALUE getParameterEntity;
|
38
|
+
VALUE cdataBlock;
|
39
|
+
VALUE externalSubset;
|
40
|
+
} ruby_xml_sax_parser_callbacks;
|
41
|
+
*/
|
42
|
+
|
43
|
+
typedef struct ruby_xml_sax_parser {
|
44
|
+
xmlParserCtxtPtr xpc;
|
45
|
+
xmlSAXHandlerPtr xsh;
|
46
|
+
//ruby_xml_sax_parser_callbacks *cbp;
|
47
|
+
VALUE callbackHandler;
|
48
|
+
VALUE filename;
|
49
|
+
VALUE str;
|
50
|
+
} ruby_xml_sax_parser;
|
51
|
+
|
52
|
+
void ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp);
|
53
|
+
void ruby_init_xml_sax_parser(void);
|
54
|
+
VALUE ruby_xml_sax_parser_new(VALUE class);
|
55
|
+
|
56
|
+
#endif
|
@@ -20,66 +20,66 @@ ruby_xml_schema_free(ruby_xml_schema *rxschema) {
|
|
20
20
|
|
21
21
|
/*
|
22
22
|
* call-seq:
|
23
|
-
* XML::Schema.new(schema_uri)
|
23
|
+
* XML::Schema.new(schema_uri) -> schema
|
24
24
|
*
|
25
25
|
* Create a new schema from the specified URI.
|
26
26
|
*/
|
27
27
|
VALUE
|
28
|
-
ruby_xml_schema_init_from_uri(
|
28
|
+
ruby_xml_schema_init_from_uri(VALUE class, VALUE uri) {
|
29
29
|
xmlSchemaParserCtxtPtr parser;
|
30
30
|
ruby_xml_schema *schema;
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
parser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
|
41
|
-
schema = ALLOC(ruby_xml_schema);
|
42
|
-
schema->schema = xmlSchemaParse(parser);
|
43
|
-
xmlSchemaFreeParserCtxt(parser);
|
44
|
-
|
45
|
-
result = Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
|
46
|
-
break;
|
47
|
-
default:
|
48
|
-
rb_raise(rb_eArgError, "wrong number of arguments (need 1)");
|
49
|
-
}
|
50
|
-
return(result);
|
31
|
+
|
32
|
+
Check_Type(uri, T_STRING);
|
33
|
+
|
34
|
+
parser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
|
35
|
+
schema = ALLOC(ruby_xml_schema);
|
36
|
+
schema->schema = xmlSchemaParse(parser);
|
37
|
+
xmlSchemaFreeParserCtxt(parser);
|
38
|
+
|
39
|
+
return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
|
51
40
|
}
|
52
41
|
|
53
42
|
/*
|
54
43
|
* call-seq:
|
55
|
-
* XML::Schema.
|
44
|
+
* XML::Schema.document(document) -> schema
|
56
45
|
*
|
57
|
-
* Create a new schema
|
46
|
+
* Create a new schema from the specified URI.
|
58
47
|
*/
|
59
48
|
VALUE
|
60
|
-
|
61
|
-
|
49
|
+
ruby_xml_schema_init_from_document(VALUE class, VALUE document) {
|
50
|
+
ruby_xml_document_t *rdoc;
|
51
|
+
ruby_xml_schema *schema;
|
52
|
+
xmlSchemaParserCtxtPtr parser;
|
53
|
+
|
54
|
+
Data_Get_Struct(document, ruby_xml_document_t, rdoc);
|
55
|
+
|
56
|
+
parser = xmlSchemaNewDocParserCtxt(rdoc->doc);
|
57
|
+
schema = ALLOC(ruby_xml_schema);
|
58
|
+
schema->schema = xmlSchemaParse(parser);
|
59
|
+
xmlSchemaFreeParserCtxt(parser);
|
60
|
+
|
61
|
+
return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
|
62
|
+
}
|
62
63
|
|
64
|
+
/*
|
65
|
+
* call-seq:
|
66
|
+
* XML::Schema.string("schema_data") -> "value"
|
67
|
+
*
|
68
|
+
* Create a new schema using the specified string.
|
69
|
+
*/
|
70
|
+
VALUE
|
71
|
+
ruby_xml_schema_init_from_string(VALUE self, VALUE schema_str) {
|
63
72
|
xmlSchemaParserCtxtPtr parser;
|
64
|
-
//xmlSchemaPtr sptr;
|
65
73
|
ruby_xml_schema *rxschema;
|
66
74
|
|
67
|
-
|
68
|
-
case 1:
|
69
|
-
rb_scan_args(argc, argv, "10", &schema_str);
|
75
|
+
Check_Type(schema_str, T_STRING);
|
70
76
|
|
71
|
-
|
77
|
+
parser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(StringValuePtr(schema_str)));
|
78
|
+
rxschema = ALLOC(ruby_xml_schema);
|
79
|
+
rxschema->schema = xmlSchemaParse(parser);
|
80
|
+
xmlSchemaFreeParserCtxt(parser);
|
72
81
|
|
73
|
-
|
74
|
-
rxschema = ALLOC(ruby_xml_schema);
|
75
|
-
rxschema->schema = xmlSchemaParse(parser);
|
76
|
-
xmlSchemaFreeParserCtxt(parser);
|
77
|
-
|
78
|
-
return( Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, rxschema) );
|
79
|
-
default:
|
80
|
-
rb_raise(rb_eArgError, "wrong number of arguments (need 1)");
|
81
|
-
}
|
82
|
-
return Qnil;
|
82
|
+
return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, rxschema);
|
83
83
|
}
|
84
84
|
|
85
85
|
/* TODO what is this patch doing here?
|
@@ -130,17 +130,10 @@ ruby_xml_schema_init_from_str(int argc, VALUE *argv, VALUE class) {
|
|
130
130
|
} else if (!strcmp(method, "validate_schema_buffer")) {
|
131
131
|
*/
|
132
132
|
|
133
|
-
void ruby_schema_free(ruby_xml_schema *rxs) {
|
134
|
-
}
|
135
|
-
|
136
|
-
// Rdoc needs to know
|
137
|
-
#ifdef RDOC_NEVER_DEFINED
|
138
|
-
mXML = rb_define_module("XML");
|
139
|
-
#endif
|
140
|
-
|
141
133
|
void ruby_init_xml_schema(void) {
|
142
134
|
cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
|
143
|
-
rb_define_singleton_method(cXMLSchema, "new", ruby_xml_schema_init_from_uri,
|
144
|
-
rb_define_singleton_method(cXMLSchema, "from_string",
|
135
|
+
rb_define_singleton_method(cXMLSchema, "new", ruby_xml_schema_init_from_uri, 1);
|
136
|
+
rb_define_singleton_method(cXMLSchema, "from_string", ruby_xml_schema_init_from_string, 1);
|
137
|
+
rb_define_singleton_method(cXMLSchema, "document", ruby_xml_schema_init_from_document, 1);
|
145
138
|
}
|
146
139
|
|