libxml-ruby 0.8.3-x86-mswin32-60 → 0.9.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +18 -0
- data/RAKEFILE +15 -39
- data/README +48 -47
- data/ext/libxml/libxml.c +847 -22
- data/ext/libxml/ruby_libxml.h +71 -95
- data/ext/libxml/ruby_xml_attr.c +500 -500
- data/ext/libxml/ruby_xml_attributes.c +1 -1
- data/ext/libxml/ruby_xml_document.c +1144 -1135
- data/ext/libxml/ruby_xml_document.h +4 -11
- data/ext/libxml/ruby_xml_dtd.c +27 -0
- data/ext/libxml/ruby_xml_encoding.c +164 -0
- data/ext/libxml/ruby_xml_encoding.h +13 -0
- data/ext/libxml/ruby_xml_error.c +941 -0
- data/ext/libxml/ruby_xml_error.h +13 -0
- data/ext/libxml/ruby_xml_html_parser.c +71 -387
- data/ext/libxml/ruby_xml_html_parser.h +1 -17
- data/ext/libxml/ruby_xml_input.c +179 -0
- data/ext/libxml/ruby_xml_input.h +18 -0
- data/ext/libxml/ruby_xml_input_cbg.c +17 -3
- data/ext/libxml/ruby_xml_node.c +1566 -1582
- data/ext/libxml/ruby_xml_node.h +1 -4
- data/ext/libxml/ruby_xml_ns.c +14 -3
- data/ext/libxml/ruby_xml_parser.c +164 -1398
- data/ext/libxml/ruby_xml_parser.h +5 -17
- data/ext/libxml/ruby_xml_parser_context.c +131 -169
- data/ext/libxml/ruby_xml_parser_context.h +2 -9
- data/ext/libxml/ruby_xml_reader.c +910 -945
- data/ext/libxml/ruby_xml_relaxng.c +32 -3
- data/ext/libxml/ruby_xml_sax_parser.c +106 -364
- data/ext/libxml/ruby_xml_sax_parser.h +1 -37
- data/ext/libxml/ruby_xml_schema.c +174 -145
- data/ext/libxml/ruby_xml_xinclude.c +9 -5
- data/ext/libxml/ruby_xml_xpath.c +25 -6
- data/ext/libxml/ruby_xml_xpath.h +1 -2
- data/ext/libxml/ruby_xml_xpath_context.c +17 -19
- data/ext/libxml/ruby_xml_xpath_object.c +60 -56
- data/ext/libxml/ruby_xml_xpointer.c +11 -5
- data/ext/libxml/sax_parser_callbacks.inc +42 -37
- data/ext/libxml/version.h +3 -3
- data/ext/mingw/Rakefile +20 -27
- data/ext/mingw/build.rake +41 -0
- data/{lib → ext/mingw}/libiconv-2.dll +0 -0
- data/ext/mingw/libxml2-2.dll +0 -0
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +23 -15
- data/lib/libxml.rb +8 -2
- data/lib/libxml/document.rb +16 -4
- data/lib/libxml/error.rb +84 -0
- data/lib/libxml/hpricot.rb +76 -0
- data/lib/libxml/html_parser.rb +61 -0
- data/lib/libxml/node.rb +36 -25
- data/lib/libxml/parser.rb +312 -33
- data/lib/libxml/parser_context.rb +17 -0
- data/lib/libxml/properties.rb +15 -2
- data/lib/libxml/reader.rb +15 -0
- data/lib/libxml/sax_callbacks.rb +179 -0
- data/lib/libxml/sax_parser.rb +42 -0
- data/lib/libxml/tree.rb +1 -2
- data/lib/libxml/xpath_object.rb +12 -0
- data/test/model/atom.xml +4 -0
- data/test/tc_attributes.rb +43 -19
- data/test/tc_document.rb +1 -1
- data/test/tc_document_write.rb +15 -8
- data/test/tc_dtd.rb +36 -20
- data/test/tc_encoding.rb +13 -0
- data/test/tc_error.rb +136 -0
- data/test/tc_node.rb +2 -3
- data/test/tc_node_copy.rb +1 -1
- data/test/tc_node_edit.rb +6 -0
- data/test/tc_ns.rb +18 -0
- data/test/tc_parser.rb +113 -228
- data/test/tc_parser_context.rb +1 -2
- data/test/tc_reader.rb +24 -14
- data/test/tc_relaxng.rb +18 -6
- data/test/tc_sax_parser.rb +48 -13
- data/test/tc_schema.rb +20 -8
- data/test/tc_well_formed.rb +2 -1
- data/test/tc_xml.rb +212 -0
- data/test/tc_xpath.rb +60 -46
- data/test/tc_xpointer.rb +7 -11
- data/test/test_suite.rb +4 -3
- metadata +32 -115
- data/doc/rdoc/classes/LibXML.html +0 -241
- data/doc/rdoc/classes/LibXML/XML.html +0 -185
- data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
- data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
- data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
- data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
- data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
- data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
- data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
- data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
- data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
- data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
- data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
- data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
- data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
- data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
- data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
- data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
- data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
- data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
- data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
- data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
- data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
- data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
- data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
- data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
- data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
- data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
- data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
- data/doc/rdoc/classes/singleton.html +0 -114
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/CHANGES.html +0 -442
- data/doc/rdoc/files/LICENSE.html +0 -133
- data/doc/rdoc/files/README.html +0 -388
- data/doc/rdoc/files/VERSION.html +0 -107
- data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
- data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
- data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
- data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
- data/doc/rdoc/files/lib/libxml_rb.html +0 -124
- data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
- data/doc/rdoc/files/lib/xml_rb.html +0 -134
- data/doc/rdoc/fr_class_index.html +0 -62
- data/doc/rdoc/fr_file_index.html +0 -66
- data/doc/rdoc/fr_method_index.html +0 -392
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/ext/libxml/ruby_xml_node_set.c +0 -172
- data/ext/libxml/ruby_xml_node_set.h +0 -20
- data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
- data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
- data/lib/libxml/node_set.rb +0 -27
- data/lib/libxml2-2.dll +0 -0
- data/lib/libxml_ruby.dll.a +0 -0
- data/lib/libxml_ruby.so +0 -0
- data/test/tc_node_set.rb +0 -24
- data/test/tc_node_set2.rb +0 -37
@@ -1,6 +1,35 @@
|
|
1
1
|
#include "ruby_libxml.h"
|
2
2
|
#include "ruby_xml_relaxng.h"
|
3
3
|
|
4
|
+
/*
|
5
|
+
* Document-class: LibXML::XML::RelaxNG
|
6
|
+
*
|
7
|
+
* The XML::RelaxNG class is used to prepare RelaxNG schemas for validation
|
8
|
+
* of xml documents.
|
9
|
+
*
|
10
|
+
* Schemas can be created from XML documents, strings or URIs using the
|
11
|
+
* corresponding methods (new for URIs).
|
12
|
+
*
|
13
|
+
* Once a schema is prepared, an XML document can be validated by the
|
14
|
+
* XML::Document#validate_relaxng method providing the XML::RelaxNG object
|
15
|
+
* as parameter. The method will raise an exception if the document is
|
16
|
+
* not valid.
|
17
|
+
*
|
18
|
+
* Basic Usage:
|
19
|
+
*
|
20
|
+
* # parse schema as xml document
|
21
|
+
* relaxng_document = XML::Document.file('schema.rng')
|
22
|
+
*
|
23
|
+
* # prepare schema for validation
|
24
|
+
* relaxng_schema = XML::RelaxNG.document(relaxng_document)
|
25
|
+
*
|
26
|
+
* # parse xml document to be validated
|
27
|
+
* instance = XML::Document.file('instance.xml')
|
28
|
+
*
|
29
|
+
* # validate
|
30
|
+
* instance.validate_relaxng(relaxng_schema)
|
31
|
+
*/
|
32
|
+
|
4
33
|
VALUE cXMLRelaxNG;
|
5
34
|
|
6
35
|
// Rdoc needs to know
|
@@ -53,13 +82,13 @@ ruby_xml_relaxng_init_from_uri(VALUE class, VALUE uri) {
|
|
53
82
|
*/
|
54
83
|
VALUE
|
55
84
|
ruby_xml_relaxng_init_from_document(VALUE class, VALUE document) {
|
56
|
-
|
85
|
+
xmlDocPtr xdoc;
|
57
86
|
ruby_xml_relaxng *relaxng;
|
58
87
|
xmlRelaxNGParserCtxtPtr parser;
|
59
88
|
|
60
|
-
Data_Get_Struct(document,
|
89
|
+
Data_Get_Struct(document, xmlDoc, xdoc);
|
61
90
|
|
62
|
-
parser = xmlRelaxNGNewDocParserCtxt(
|
91
|
+
parser = xmlRelaxNGNewDocParserCtxt(xdoc);
|
63
92
|
relaxng = ALLOC(ruby_xml_relaxng);
|
64
93
|
relaxng->relaxng = xmlRelaxNGParse(parser);
|
65
94
|
xmlRelaxNGFreeParserCtxt(parser);
|
@@ -1,13 +1,45 @@
|
|
1
|
-
/* $Id: ruby_xml_sax_parser.c
|
1
|
+
/* $Id: ruby_xml_sax_parser.c 578 2008-11-18 09:23:26Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
5
|
#include "ruby_libxml.h"
|
6
6
|
#include "ruby_xml_sax_parser.h"
|
7
7
|
|
8
|
+
/*
|
9
|
+
* Document-class: LibXML::XML::SaxParser
|
10
|
+
*
|
11
|
+
* XML::SaxParser provides a callback based API for parsing documents,
|
12
|
+
* in contrast to XML::Parser's tree based API and XML::Reader's stream
|
13
|
+
* based API.
|
14
|
+
*
|
15
|
+
* Note that the XML::SaxParser API is fairly complex, not well standardized,
|
16
|
+
* and does not directly support validation making entity, namespace and
|
17
|
+
* base processing relatively hard.
|
18
|
+
*
|
19
|
+
* To use the XML::SaxParser, register a callback class via the
|
20
|
+
* XML::SaxParser#callbacks=. It is easiest to include the
|
21
|
+
* XML::SaxParser::Callbacks module in your class and override
|
22
|
+
* the methods as needed.
|
23
|
+
*
|
24
|
+
* Basic example:
|
25
|
+
*
|
26
|
+
* class MyCallbacks
|
27
|
+
* include XML::SaxParser::Callbacks
|
28
|
+
* def on_start_element(element, attributes)
|
29
|
+
* puts #Element started: #{element}"
|
30
|
+
* end
|
31
|
+
* end
|
32
|
+
*
|
33
|
+
* parser = XML::SaxParser.new
|
34
|
+
* parser.callbacks = MyCallbacks.new
|
35
|
+
* parser.parse
|
36
|
+
*/
|
37
|
+
|
8
38
|
VALUE cXMLSaxParser;
|
9
39
|
VALUE mXMLSaxParserCallbacks;
|
10
40
|
|
41
|
+
ID INPUT_ATTR;
|
42
|
+
|
11
43
|
VALUE cbidOnInternalSubset;
|
12
44
|
VALUE cbidOnIsStandalone;
|
13
45
|
VALUE cbidOnHasInternalSubset;
|
@@ -29,50 +61,53 @@ VALUE cbidOnExternalSubset;
|
|
29
61
|
#include "sax_parser_callbacks.inc"
|
30
62
|
|
31
63
|
void
|
32
|
-
ruby_xml_sax_parser_free(ruby_xml_sax_parser *
|
33
|
-
|
34
|
-
/* if (nodesp->xsh != NULL) */
|
35
|
-
/* xmlFreeSax_Parser(nodesp->sax_parser); */
|
64
|
+
ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp) {
|
65
|
+
xfree(rxsp);
|
36
66
|
}
|
37
67
|
|
38
68
|
void
|
39
|
-
ruby_xml_sax_parser_mark(ruby_xml_sax_parser *
|
40
|
-
if (
|
41
|
-
rb_gc_mark(
|
69
|
+
ruby_xml_sax_parser_mark(ruby_xml_sax_parser *rxsp) {
|
70
|
+
if (rxsp->callbackHandler != Qnil) {
|
71
|
+
rb_gc_mark(rxsp->callbackHandler);
|
42
72
|
}
|
43
73
|
|
44
|
-
if (
|
45
|
-
rb_gc_mark(
|
74
|
+
if (rxsp->filename != Qnil) {
|
75
|
+
rb_gc_mark(rxsp->filename);
|
46
76
|
}
|
47
77
|
|
48
|
-
if (
|
49
|
-
rb_gc_mark(
|
78
|
+
if (rxsp->str != Qnil) {
|
79
|
+
rb_gc_mark(rxsp->str);
|
50
80
|
}
|
51
81
|
}
|
52
82
|
|
83
|
+
VALUE
|
84
|
+
ruby_xml_sax_parser_alloc(VALUE klass) {
|
85
|
+
ruby_xml_sax_parser *rxsp = ALLOC(ruby_xml_sax_parser);
|
86
|
+
rxsp->xsh = &rubySAXHandlerStruct;
|
87
|
+
rxsp->callbackHandler = Qnil;
|
88
|
+
rxsp->xpc = NULL;
|
89
|
+
rxsp->filename = Qnil;
|
90
|
+
rxsp->str = Qnil;
|
91
|
+
|
92
|
+
return Data_Wrap_Struct(cXMLSaxParser,
|
93
|
+
ruby_xml_sax_parser_mark, ruby_xml_sax_parser_free,
|
94
|
+
rxsp);
|
95
|
+
}
|
96
|
+
|
97
|
+
|
53
98
|
/*
|
54
99
|
* call-seq:
|
55
|
-
*
|
100
|
+
* sax_parser.initialize -> sax_parser
|
56
101
|
*
|
57
|
-
*
|
102
|
+
* Initiliazes instance of parser.
|
58
103
|
*/
|
59
104
|
VALUE
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
nodesp->xsh = &rubySAXHandlerStruct;
|
65
|
-
|
66
|
-
nodesp->callbackHandler = Qnil;
|
67
|
-
nodesp->xpc = NULL;
|
68
|
-
nodesp->filename = Qnil;
|
69
|
-
nodesp->str = Qnil;
|
70
|
-
|
71
|
-
return(Data_Wrap_Struct(class, ruby_xml_sax_parser_mark,
|
72
|
-
ruby_xml_sax_parser_free, nodesp));
|
105
|
+
ruby_xml_sax_parser_initialize(VALUE self) {
|
106
|
+
VALUE input = rb_class_new_instance(0, NULL, cXMLInput);
|
107
|
+
rb_iv_set(self, "@input", input);
|
108
|
+
return self;
|
73
109
|
}
|
74
110
|
|
75
|
-
|
76
111
|
/*
|
77
112
|
* call-seq:
|
78
113
|
* sax_parser.callbacks -> #<XML::SaxParser::Callbacks subclass>
|
@@ -81,9 +116,9 @@ ruby_xml_sax_parser_new(VALUE class) {
|
|
81
116
|
*/
|
82
117
|
VALUE
|
83
118
|
ruby_xml_sax_parser_callbacks_get(VALUE self) {
|
84
|
-
ruby_xml_sax_parser *
|
85
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
86
|
-
return(
|
119
|
+
ruby_xml_sax_parser *rxsp;
|
120
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
121
|
+
return(rxsp->callbackHandler);
|
87
122
|
}
|
88
123
|
|
89
124
|
|
@@ -98,43 +133,12 @@ ruby_xml_sax_parser_callbacks_get(VALUE self) {
|
|
98
133
|
*/
|
99
134
|
VALUE
|
100
135
|
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(
|
136
|
+
ruby_xml_sax_parser *rxsp;
|
137
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
138
|
+
rxsp->callbackHandler = callbacks;
|
139
|
+
return(rxsp->callbackHandler);
|
105
140
|
}
|
106
141
|
|
107
|
-
|
108
|
-
/*
|
109
|
-
* call-seq:
|
110
|
-
* sax_parser.filename -> "filename"
|
111
|
-
*
|
112
|
-
* Obtain the filename this parser reads from.
|
113
|
-
*/
|
114
|
-
VALUE
|
115
|
-
ruby_xml_sax_parser_filename_get(VALUE self) {
|
116
|
-
ruby_xml_sax_parser *nodesp;
|
117
|
-
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
118
|
-
return(nodesp->filename);
|
119
|
-
}
|
120
|
-
|
121
|
-
|
122
|
-
/*
|
123
|
-
* call-seq:
|
124
|
-
* sax_parser.filename = "filename"
|
125
|
-
*
|
126
|
-
* Set the filename this parser reads from.
|
127
|
-
*/
|
128
|
-
VALUE
|
129
|
-
ruby_xml_sax_parser_filename_set(VALUE self, VALUE filename) {
|
130
|
-
ruby_xml_sax_parser *nodesp;
|
131
|
-
Check_Type(filename, T_STRING);
|
132
|
-
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
133
|
-
nodesp->filename = filename;
|
134
|
-
return(nodesp->filename);
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
142
|
/*
|
139
143
|
* call-seq:
|
140
144
|
* parser.parse -> (true|false)
|
@@ -146,264 +150,39 @@ VALUE
|
|
146
150
|
ruby_xml_sax_parser_parse(VALUE self) {
|
147
151
|
char *str;
|
148
152
|
int status = 1;
|
149
|
-
ruby_xml_sax_parser *
|
153
|
+
ruby_xml_sax_parser *rxsp;
|
154
|
+
VALUE source;
|
155
|
+
VALUE input = rb_ivar_get(self, INPUT_ATTR);
|
150
156
|
|
151
|
-
Data_Get_Struct(self, ruby_xml_sax_parser,
|
157
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
152
158
|
|
153
|
-
if (
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
159
|
+
if (rb_ivar_get(input, FILE_ATTR) != Qnil)
|
160
|
+
{
|
161
|
+
source = rb_ivar_get(input, FILE_ATTR);
|
162
|
+
status = xmlSAXUserParseFile(rxsp->xsh, rxsp, StringValuePtr(source));
|
163
|
+
}
|
164
|
+
else if (rb_ivar_get(input, STRING_ATTR) != Qnil)
|
165
|
+
{
|
166
|
+
source = rb_ivar_get(input, STRING_ATTR);
|
167
|
+
str = StringValueCStr(source);
|
168
|
+
status = xmlSAXUserParseMemory(rxsp->xsh, rxsp, str, strlen(str));
|
169
|
+
}
|
170
|
+
else
|
171
|
+
{
|
172
|
+
rb_raise(rb_eArgError, "You must specify a parser data source");
|
160
173
|
}
|
161
174
|
|
162
|
-
/* XXX This should return an exception for the various error codes
|
163
|
-
* that can come back in status, but I'm too lazy to do that right
|
164
|
-
* now. */
|
165
175
|
if (status)
|
166
|
-
|
176
|
+
{
|
177
|
+
ruby_xml_raise(&xmlLastError);
|
178
|
+
return Qfalse;
|
179
|
+
}
|
167
180
|
else
|
181
|
+
{
|
168
182
|
return(Qtrue);
|
183
|
+
}
|
169
184
|
}
|
170
185
|
|
171
|
-
|
172
|
-
/*
|
173
|
-
* call-seq:
|
174
|
-
* parser.string -> "xml"
|
175
|
-
*
|
176
|
-
* Obtain the parser's input string.
|
177
|
-
*/
|
178
|
-
VALUE
|
179
|
-
ruby_xml_sax_parser_str_get(VALUE self) {
|
180
|
-
ruby_xml_sax_parser *nodesp;
|
181
|
-
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
182
|
-
return(nodesp->str);
|
183
|
-
}
|
184
|
-
|
185
|
-
|
186
|
-
/*
|
187
|
-
* call-seq:
|
188
|
-
* parser.string = "xml"
|
189
|
-
*
|
190
|
-
* Set the parser's input string.
|
191
|
-
*/
|
192
|
-
VALUE
|
193
|
-
ruby_xml_sax_parser_str_set(VALUE self, VALUE str) {
|
194
|
-
ruby_xml_sax_parser *nodesp;
|
195
|
-
Check_Type(str, T_STRING);
|
196
|
-
Data_Get_Struct(self, ruby_xml_sax_parser, nodesp);
|
197
|
-
nodesp->str = str;
|
198
|
-
return(nodesp->str);
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
/****** SaxCallbacks ******/
|
203
|
-
/* These are all the same. Bloody Rdoc... */
|
204
|
-
|
205
|
-
/*
|
206
|
-
* call-seq:
|
207
|
-
* callbacks.on_internal_subset(name, external_id, system_id)
|
208
|
-
*
|
209
|
-
* Called for an internal subset event.
|
210
|
-
*/
|
211
|
-
VALUE
|
212
|
-
ruby_xml_sax_callbacks_on_internal_subset(int argc, VALUE *argv, VALUE self) {
|
213
|
-
return Qnil;
|
214
|
-
}
|
215
|
-
|
216
|
-
|
217
|
-
/*
|
218
|
-
* call-seq:
|
219
|
-
* callbacks.on_is_standalone()
|
220
|
-
*
|
221
|
-
* Called for 'is standalone' event.
|
222
|
-
*/
|
223
|
-
VALUE
|
224
|
-
ruby_xml_sax_callbacks_on_is_standalone(int argc, VALUE *argv, VALUE self) {
|
225
|
-
return Qnil;
|
226
|
-
}
|
227
|
-
|
228
|
-
|
229
|
-
/*
|
230
|
-
* call-seq:
|
231
|
-
* callbacks.on_has_internal_subset()
|
232
|
-
*
|
233
|
-
* Called for an internal subset notification event.
|
234
|
-
*/
|
235
|
-
VALUE
|
236
|
-
ruby_xml_sax_callbacks_on_has_internal_subset(int argc, VALUE *argv, VALUE self) {
|
237
|
-
return Qnil;
|
238
|
-
}
|
239
|
-
|
240
|
-
|
241
|
-
/*
|
242
|
-
* call-seq:
|
243
|
-
* callbacks.on_has_external_subset()
|
244
|
-
*
|
245
|
-
* Called for an external subset notification event.
|
246
|
-
*/
|
247
|
-
VALUE
|
248
|
-
ruby_xml_sax_callbacks_on_has_external_subset(int argc, VALUE *argv, VALUE self) {
|
249
|
-
return Qnil;
|
250
|
-
}
|
251
|
-
|
252
|
-
|
253
|
-
/*
|
254
|
-
* call-seq:
|
255
|
-
* callbacks.on_start_document()
|
256
|
-
*
|
257
|
-
* Called for a start document event.
|
258
|
-
*/
|
259
|
-
VALUE
|
260
|
-
ruby_xml_sax_callbacks_on_start_document(int argc, VALUE *argv, VALUE self) {
|
261
|
-
return Qnil;
|
262
|
-
}
|
263
|
-
|
264
|
-
|
265
|
-
/*
|
266
|
-
* call-seq:
|
267
|
-
* callbacks.on_end_document()
|
268
|
-
*
|
269
|
-
* Called for an end document event.
|
270
|
-
*/
|
271
|
-
VALUE
|
272
|
-
ruby_xml_sax_callbacks_on_end_document(int argc, VALUE *argv, VALUE self) {
|
273
|
-
return Qnil;
|
274
|
-
}
|
275
|
-
|
276
|
-
|
277
|
-
/*
|
278
|
-
* call-seq:
|
279
|
-
* callbacks.on_start_element(name, attributes_hash)
|
280
|
-
*
|
281
|
-
* Called for an element start event.
|
282
|
-
*/
|
283
|
-
VALUE
|
284
|
-
ruby_xml_sax_callbacks_on_start_element(int argc, VALUE *argv, VALUE self) {
|
285
|
-
return Qnil;
|
286
|
-
}
|
287
|
-
|
288
|
-
|
289
|
-
/*
|
290
|
-
* call-seq:
|
291
|
-
* callbacks.on_end_element(name)
|
292
|
-
*
|
293
|
-
* Called for an element end event.
|
294
|
-
*/
|
295
|
-
VALUE
|
296
|
-
ruby_xml_sax_callbacks_on_end_element(int argc, VALUE *argv, VALUE self) {
|
297
|
-
return Qnil;
|
298
|
-
}
|
299
|
-
|
300
|
-
|
301
|
-
/*
|
302
|
-
* call-seq:
|
303
|
-
* callbacks.on_reference(name)
|
304
|
-
*
|
305
|
-
* Called for a reference event.
|
306
|
-
*/
|
307
|
-
VALUE
|
308
|
-
ruby_xml_sax_callbacks_on_reference(int argc, VALUE *argv, VALUE self) {
|
309
|
-
return Qnil;
|
310
|
-
}
|
311
|
-
|
312
|
-
|
313
|
-
/*
|
314
|
-
* call-seq:
|
315
|
-
* callbacks.on_characters(chars)
|
316
|
-
*
|
317
|
-
* Called for a characters event.
|
318
|
-
*/
|
319
|
-
VALUE
|
320
|
-
ruby_xml_sax_callbacks_on_characters(int argc, VALUE *argv, VALUE self) {
|
321
|
-
return Qnil;
|
322
|
-
}
|
323
|
-
|
324
|
-
|
325
|
-
/*
|
326
|
-
* call-seq:
|
327
|
-
* callbacks.on_processing_instruction(target, data)
|
328
|
-
*
|
329
|
-
* Called for an processing instruction event.
|
330
|
-
*/
|
331
|
-
VALUE
|
332
|
-
ruby_xml_sax_callbacks_on_processing_instruction(int argc, VALUE *argv, VALUE self) {
|
333
|
-
return Qnil;
|
334
|
-
}
|
335
|
-
|
336
|
-
|
337
|
-
/*
|
338
|
-
* call-seq:
|
339
|
-
* callbacks.on_comment(msg)
|
340
|
-
*
|
341
|
-
* Called for a comment event.
|
342
|
-
*/
|
343
|
-
VALUE
|
344
|
-
ruby_xml_sax_callbacks_on_comment(int argc, VALUE *argv, VALUE self) {
|
345
|
-
return Qnil;
|
346
|
-
}
|
347
|
-
|
348
|
-
|
349
|
-
/*
|
350
|
-
* call-seq:
|
351
|
-
* callbacks.on_parser_warning(msg)
|
352
|
-
*
|
353
|
-
* Called for parser warnings.
|
354
|
-
*/
|
355
|
-
VALUE
|
356
|
-
ruby_xml_sax_callbacks_on_parser_warning(int argc, VALUE *argv, VALUE self) {
|
357
|
-
return Qnil;
|
358
|
-
}
|
359
|
-
|
360
|
-
|
361
|
-
/*
|
362
|
-
* call-seq:
|
363
|
-
* callbacks.on_parser_error(msg)
|
364
|
-
*
|
365
|
-
* Called for parser errors.
|
366
|
-
*/
|
367
|
-
VALUE
|
368
|
-
ruby_xml_sax_callbacks_on_parser_error(int argc, VALUE *argv, VALUE self) {
|
369
|
-
return Qnil;
|
370
|
-
}
|
371
|
-
|
372
|
-
|
373
|
-
/*
|
374
|
-
* call-seq:
|
375
|
-
* callbacks.on_parser_fatal_error(msg)
|
376
|
-
*
|
377
|
-
* Called for fatal parser errors.
|
378
|
-
*/
|
379
|
-
VALUE
|
380
|
-
ruby_xml_sax_callbacks_on_parser_fatal_error(int argc, VALUE *argv, VALUE self) {
|
381
|
-
return Qnil;
|
382
|
-
}
|
383
|
-
|
384
|
-
/*
|
385
|
-
* call-seq:
|
386
|
-
* callbacks.on_cdata_block(cdata)
|
387
|
-
*
|
388
|
-
* Called for a CDATA block event.
|
389
|
-
*/
|
390
|
-
VALUE
|
391
|
-
ruby_xml_sax_callbacks_on_cdata_block(int argc, VALUE *argv, VALUE self) {
|
392
|
-
return Qnil;
|
393
|
-
}
|
394
|
-
|
395
|
-
/*
|
396
|
-
* call-seq:
|
397
|
-
* callbacks.on_external_subset(name, external_id, system_id)
|
398
|
-
*
|
399
|
-
* Called for an external subset event.
|
400
|
-
*/
|
401
|
-
VALUE
|
402
|
-
ruby_xml_sax_callbacks_on_external_subset(int argc, VALUE *argv, VALUE self) {
|
403
|
-
return Qnil;
|
404
|
-
}
|
405
|
-
|
406
|
-
|
407
186
|
// Rdoc needs to know
|
408
187
|
#ifdef RDOC_NEVER_DEFINED
|
409
188
|
mLibXML = rb_define_module("LibXML");
|
@@ -412,23 +191,21 @@ ruby_xml_sax_callbacks_on_external_subset(int argc, VALUE *argv, VALUE self) {
|
|
412
191
|
|
413
192
|
void
|
414
193
|
ruby_init_xml_sax_parser(void) {
|
194
|
+
/* SaxParser */
|
415
195
|
cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
|
416
|
-
|
196
|
+
rb_define_alloc_func(cXMLSaxParser, ruby_xml_sax_parser_alloc);
|
197
|
+
rb_define_method(cXMLSaxParser, "callbacks", ruby_xml_sax_parser_callbacks_get, 0);
|
198
|
+
rb_define_method(cXMLSaxParser, "callbacks=", ruby_xml_sax_parser_callbacks_set, 1);
|
199
|
+
rb_define_method(cXMLSaxParser, "parse", ruby_xml_sax_parser_parse, 0);
|
417
200
|
|
418
|
-
/*
|
419
|
-
|
201
|
+
/* Atributes */
|
202
|
+
rb_define_attr(cXMLSaxParser, "input", 1, 0);
|
203
|
+
|
204
|
+
/* Instance Methods */
|
205
|
+
rb_define_method(cXMLSaxParser, "initialize", ruby_xml_sax_parser_initialize, 0);
|
420
206
|
|
421
|
-
|
422
|
-
|
423
|
-
rb_define_method(cXMLSaxParser, "filename=",
|
424
|
-
ruby_xml_sax_parser_filename_set, 1);
|
425
|
-
rb_define_method(cXMLSaxParser, "callbacks",
|
426
|
-
ruby_xml_sax_parser_callbacks_get, 0);
|
427
|
-
rb_define_method(cXMLSaxParser, "callbacks=",
|
428
|
-
ruby_xml_sax_parser_callbacks_set, 1);
|
429
|
-
rb_define_method(cXMLSaxParser, "parse", ruby_xml_sax_parser_parse, 0);
|
430
|
-
rb_define_method(cXMLSaxParser, "string", ruby_xml_sax_parser_str_get, 0);
|
431
|
-
rb_define_method(cXMLSaxParser, "string=", ruby_xml_sax_parser_str_set, 1);
|
207
|
+
|
208
|
+
INPUT_ATTR = rb_intern("@input");
|
432
209
|
|
433
210
|
/* SaxCallbacks */
|
434
211
|
cbidOnInternalSubset = rb_intern("on_internal_subset");
|
@@ -448,39 +225,4 @@ ruby_init_xml_sax_parser(void) {
|
|
448
225
|
cbidOnXmlParserFatalError = rb_intern("on_parser_fatal_error");
|
449
226
|
cbidOnCdataBlock = rb_intern("on_cdata_block");
|
450
227
|
cbidOnExternalSubset = rb_intern("on_external_subset");
|
451
|
-
|
452
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_internal_subset",
|
453
|
-
ruby_xml_sax_callbacks_on_internal_subset, -1);
|
454
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_is_standalone",
|
455
|
-
ruby_xml_sax_callbacks_on_is_standalone, -1);
|
456
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_has_internal_subset",
|
457
|
-
ruby_xml_sax_callbacks_on_has_internal_subset, -1);
|
458
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_has_external_subset",
|
459
|
-
ruby_xml_sax_callbacks_on_has_external_subset, -1);
|
460
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_start_document",
|
461
|
-
ruby_xml_sax_callbacks_on_start_document, -1);
|
462
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_end_document",
|
463
|
-
ruby_xml_sax_callbacks_on_end_document, -1);
|
464
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_start_element",
|
465
|
-
ruby_xml_sax_callbacks_on_start_element, -1);
|
466
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_end_element",
|
467
|
-
ruby_xml_sax_callbacks_on_end_element, -1);
|
468
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_reference",
|
469
|
-
ruby_xml_sax_callbacks_on_reference, -1);
|
470
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_characters",
|
471
|
-
ruby_xml_sax_callbacks_on_characters, -1);
|
472
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_processing_instruction",
|
473
|
-
ruby_xml_sax_callbacks_on_processing_instruction, -1);
|
474
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_comment",
|
475
|
-
ruby_xml_sax_callbacks_on_comment, -1);
|
476
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_parser_warning",
|
477
|
-
ruby_xml_sax_callbacks_on_parser_warning, -1);
|
478
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_parser_error",
|
479
|
-
ruby_xml_sax_callbacks_on_parser_error, -1);
|
480
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_parser_fatal_error",
|
481
|
-
ruby_xml_sax_callbacks_on_parser_fatal_error, -1);
|
482
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_cdata_block",
|
483
|
-
ruby_xml_sax_callbacks_on_cdata_block, -1);
|
484
|
-
rb_define_method(mXMLSaxParserCallbacks, "on_external_subset",
|
485
|
-
ruby_xml_sax_callbacks_on_external_subset, -1);
|
486
228
|
}
|