libxml-ruby 0.3.6
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.
- data/CHANGELOG +49 -0
- data/LICENSE +22 -0
- data/README +129 -0
- data/Rakefile +197 -0
- data/TODO +84 -0
- data/ext/xml/cbg.c +76 -0
- data/ext/xml/extconf.rb +95 -0
- data/ext/xml/libxml.c +86 -0
- data/ext/xml/libxml.h +79 -0
- data/ext/xml/ruby_xml_attr.c +372 -0
- data/ext/xml/ruby_xml_attr.h +21 -0
- data/ext/xml/ruby_xml_attribute.c +224 -0
- data/ext/xml/ruby_xml_attribute.h +21 -0
- data/ext/xml/ruby_xml_document.c +1159 -0
- data/ext/xml/ruby_xml_document.h +27 -0
- data/ext/xml/ruby_xml_dtd.c +168 -0
- data/ext/xml/ruby_xml_dtd.h +17 -0
- data/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/ext/xml/ruby_xml_node.c +2052 -0
- data/ext/xml/ruby_xml_node.h +28 -0
- data/ext/xml/ruby_xml_node_set.c +197 -0
- data/ext/xml/ruby_xml_node_set.h +26 -0
- data/ext/xml/ruby_xml_ns.c +153 -0
- data/ext/xml/ruby_xml_ns.h +21 -0
- data/ext/xml/ruby_xml_parser.c +1363 -0
- data/ext/xml/ruby_xml_parser.h +31 -0
- data/ext/xml/ruby_xml_parser_context.c +715 -0
- data/ext/xml/ruby_xml_parser_context.h +22 -0
- data/ext/xml/ruby_xml_sax_parser.c +181 -0
- data/ext/xml/ruby_xml_sax_parser.h +21 -0
- data/ext/xml/ruby_xml_schema.c +142 -0
- data/ext/xml/ruby_xml_schema.h +16 -0
- data/ext/xml/ruby_xml_tree.c +43 -0
- data/ext/xml/ruby_xml_tree.h +12 -0
- data/ext/xml/ruby_xml_xinclude.c +20 -0
- data/ext/xml/ruby_xml_xinclude.h +13 -0
- data/ext/xml/ruby_xml_xpath.c +357 -0
- data/ext/xml/ruby_xml_xpath.h +24 -0
- data/ext/xml/ruby_xml_xpath_context.c +124 -0
- data/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/ext/xml/ruby_xml_xpointer.c +100 -0
- data/ext/xml/ruby_xml_xpointer.h +27 -0
- data/ext/xml/ruby_xml_xpointer_context.c +22 -0
- data/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/tests/copy_bug.rb +21 -0
- data/tests/dtd-test.rb +24 -0
- data/tests/model/default_validation_bug.rb +0 -0
- data/tests/model/rubynet.xml +78 -0
- data/tests/model/rubynet_project +13 -0
- data/tests/model/xinclude.xml +5 -0
- data/tests/runner.rb +13 -0
- data/tests/schema-test.rb +74 -0
- data/tests/tc_default_validation.rb +0 -0
- data/tests/tc_xml_document.rb +51 -0
- data/tests/tc_xml_document_write.rb +25 -0
- data/tests/tc_xml_document_write2.rb +55 -0
- data/tests/tc_xml_document_write3.rb +97 -0
- data/tests/tc_xml_node.rb +59 -0
- data/tests/tc_xml_node2.rb +26 -0
- data/tests/tc_xml_node_set.rb +25 -0
- data/tests/tc_xml_node_xlink.rb +28 -0
- data/tests/tc_xml_parser.rb +175 -0
- data/tests/tc_xml_parser2.rb +17 -0
- data/tests/tc_xml_parser3.rb +23 -0
- data/tests/tc_xml_parser4.rb +33 -0
- data/tests/tc_xml_parser5.rb +27 -0
- data/tests/tc_xml_parser6.rb +23 -0
- data/tests/tc_xml_parser7.rb +28 -0
- data/tests/tc_xml_parser_context.rb +89 -0
- data/tests/tc_xml_xinclude.rb +30 -0
- data/tests/tc_xml_xpath.rb +23 -0
- data/tests/tc_xml_xpointer.rb +78 -0
- metadata +144 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
/* $Id: ruby_xml_parser_context.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_PARSER_CONTEXT__
|
6
|
+
#define __RUBY_XML_PARSER_CONTEXT__
|
7
|
+
|
8
|
+
extern VALUE cXMLParserContext;
|
9
|
+
|
10
|
+
typedef struct ruby_xml_parser_context {
|
11
|
+
xmlParserCtxtPtr ctxt;
|
12
|
+
int is_ptr;
|
13
|
+
} ruby_xml_parser_context;
|
14
|
+
|
15
|
+
void ruby_xml_parser_context_free(ruby_xml_parser_context *ctxt);
|
16
|
+
void ruby_init_xml_parser_context(void);
|
17
|
+
VALUE ruby_xml_parser_context_new(VALUE class, xmlParserCtxtPtr ctxt);
|
18
|
+
VALUE ruby_xml_parser_context_new2(VALUE class);
|
19
|
+
VALUE ruby_xml_parser_context_new3();
|
20
|
+
VALUE ruby_xml_parser_context_each(VALUE self);
|
21
|
+
|
22
|
+
#endif
|
@@ -0,0 +1,181 @@
|
|
1
|
+
/* $Id: ruby_xml_sax_parser.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
#include "ruby_xml_sax_parser.h"
|
7
|
+
|
8
|
+
VALUE cXMLSaxParser;
|
9
|
+
|
10
|
+
void
|
11
|
+
ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp) {
|
12
|
+
/* Apparently this isn't needed: time will tell */
|
13
|
+
/* if (rxsp->xsh != NULL) */
|
14
|
+
/* xmlFreeSax_Parser(rxsp->sax_parser); */
|
15
|
+
}
|
16
|
+
|
17
|
+
/*
|
18
|
+
* call-seq:
|
19
|
+
* XML::SaxParser.new => sax_parser
|
20
|
+
*
|
21
|
+
* Create a new XML::SaxParser instance.
|
22
|
+
*/
|
23
|
+
VALUE
|
24
|
+
ruby_xml_sax_parser_new(VALUE class) {
|
25
|
+
ruby_xml_sax_parser *rxsp;
|
26
|
+
|
27
|
+
xmlSAXHandler emptySAXHandlerStruct = {
|
28
|
+
NULL, /* internalSubset */
|
29
|
+
NULL, /* isStandalone */
|
30
|
+
NULL, /* hasInternalSubset */
|
31
|
+
NULL, /* hasExternalSubset */
|
32
|
+
NULL, /* resolveEntity */
|
33
|
+
NULL, /* getEntity */
|
34
|
+
NULL, /* entityDecl */
|
35
|
+
NULL, /* notationDecl */
|
36
|
+
NULL, /* attributeDecl */
|
37
|
+
NULL, /* elementDecl */
|
38
|
+
NULL, /* unparsedEntityDecl */
|
39
|
+
NULL, /* setDocumentLocator */
|
40
|
+
NULL, /* startDocument */
|
41
|
+
NULL, /* endDocument */
|
42
|
+
NULL, /* startElement */
|
43
|
+
NULL, /* endElement */
|
44
|
+
NULL, /* reference */
|
45
|
+
NULL, /* characters */
|
46
|
+
NULL, /* ignorableWhitespace */
|
47
|
+
NULL, /* processingInstruction */
|
48
|
+
NULL, /* comment */
|
49
|
+
NULL, /* xmlParserWarning */
|
50
|
+
NULL, /* xmlParserError */
|
51
|
+
NULL, /* xmlParserError */
|
52
|
+
NULL, /* getParameterEntity */
|
53
|
+
NULL, /* cdataBlock; */
|
54
|
+
NULL, /* externalSubset; */
|
55
|
+
1
|
56
|
+
};
|
57
|
+
|
58
|
+
rxsp = ALLOC(ruby_xml_sax_parser);
|
59
|
+
rxsp->xsh = &emptySAXHandlerStruct;
|
60
|
+
|
61
|
+
rxsp->xpc = NULL;
|
62
|
+
rxsp->filename = Qnil;
|
63
|
+
rxsp->str = Qnil;
|
64
|
+
|
65
|
+
return(Data_Wrap_Struct(class, 0, ruby_xml_sax_parser_free, rxsp));
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
/*
|
70
|
+
* call-seq:
|
71
|
+
* sax_parser.filename => "filename"
|
72
|
+
*
|
73
|
+
* Obtain the filename this parser reads from.
|
74
|
+
*/
|
75
|
+
VALUE
|
76
|
+
ruby_xml_sax_parser_filename_get(VALUE self) {
|
77
|
+
ruby_xml_sax_parser *rxsp;
|
78
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
79
|
+
return(rxsp->filename);
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
/*
|
84
|
+
* call-seq:
|
85
|
+
* sax_parser.filename = "filename"
|
86
|
+
*
|
87
|
+
* Set the filename this parser reads from.
|
88
|
+
*/
|
89
|
+
VALUE
|
90
|
+
ruby_xml_sax_parser_filename_set(VALUE self, VALUE filename) {
|
91
|
+
ruby_xml_sax_parser *rxsp;
|
92
|
+
Check_Type(filename, T_STRING);
|
93
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
94
|
+
rxsp->filename = filename;
|
95
|
+
return(rxsp->filename);
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
/*
|
100
|
+
* call-seq:
|
101
|
+
* parser.parse => document
|
102
|
+
*
|
103
|
+
* Parse the input XML.
|
104
|
+
*/
|
105
|
+
VALUE
|
106
|
+
ruby_xml_sax_parser_parse(VALUE self) {
|
107
|
+
char *str;
|
108
|
+
int status;
|
109
|
+
ruby_xml_sax_parser *rxsp;
|
110
|
+
VALUE docobj = Qnil;
|
111
|
+
|
112
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
113
|
+
|
114
|
+
if (rxsp->filename != Qnil) {
|
115
|
+
status = xmlSAXUserParseFile(rxsp->xsh, NULL, StringValuePtr(rxsp->filename));
|
116
|
+
|
117
|
+
/* XXX This should return an exception for the various error codes
|
118
|
+
* that can come back in status, but I'm too lazy to do that right
|
119
|
+
* now. */
|
120
|
+
if (status)
|
121
|
+
docobj = Qfalse;
|
122
|
+
else
|
123
|
+
docobj = Qtrue;
|
124
|
+
} else if (rxsp->str != Qnil) {
|
125
|
+
str = StringValuePtr(rxsp->str);
|
126
|
+
docobj = ruby_xml_document_new(cXMLDocument,
|
127
|
+
xmlSAXParseMemory(rxsp->xsh, str,
|
128
|
+
strlen(str), 0));
|
129
|
+
}
|
130
|
+
return(docobj);
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
/*
|
135
|
+
* call-seq:
|
136
|
+
* parser.string => "xml"
|
137
|
+
*
|
138
|
+
* Obtain the parser's input string.
|
139
|
+
*/
|
140
|
+
VALUE
|
141
|
+
ruby_xml_sax_parser_str_get(VALUE self) {
|
142
|
+
ruby_xml_sax_parser *rxsp;
|
143
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
144
|
+
return(rxsp->str);
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
/*
|
149
|
+
* call-seq:
|
150
|
+
* parser.string = "xml"
|
151
|
+
*
|
152
|
+
* Set the parser's input string.
|
153
|
+
*/
|
154
|
+
VALUE
|
155
|
+
ruby_xml_sax_parser_str_set(VALUE self, VALUE str) {
|
156
|
+
ruby_xml_sax_parser *rxsp;
|
157
|
+
Check_Type(str, T_STRING);
|
158
|
+
Data_Get_Struct(self, ruby_xml_sax_parser, rxsp);
|
159
|
+
rxsp->str = str;
|
160
|
+
return(rxsp->str);
|
161
|
+
}
|
162
|
+
|
163
|
+
// Rdoc needs to know
|
164
|
+
#ifdef RDOC_NEVER_DEFINED
|
165
|
+
mXML = rb_define_module("XML");
|
166
|
+
#endif
|
167
|
+
|
168
|
+
void
|
169
|
+
ruby_init_xml_sax_parser(void) {
|
170
|
+
cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
|
171
|
+
|
172
|
+
rb_define_singleton_method(cXMLSaxParser, "new", ruby_xml_sax_parser_new, 0);
|
173
|
+
|
174
|
+
rb_define_method(cXMLSaxParser, "filename",
|
175
|
+
ruby_xml_sax_parser_filename_get, 0);
|
176
|
+
rb_define_method(cXMLSaxParser, "filename=",
|
177
|
+
ruby_xml_sax_parser_filename_set, 1);
|
178
|
+
rb_define_method(cXMLSaxParser, "parse", ruby_xml_sax_parser_parse, 0);
|
179
|
+
rb_define_method(cXMLSaxParser, "string", ruby_xml_sax_parser_str_get, 0);
|
180
|
+
rb_define_method(cXMLSaxParser, "string=", ruby_xml_sax_parser_str_set, 1);
|
181
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* $Id: ruby_xml_sax_parser.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
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
|
+
|
10
|
+
typedef struct ruby_xml_sax_parser {
|
11
|
+
xmlParserCtxtPtr xpc;
|
12
|
+
xmlSAXHandlerPtr xsh;
|
13
|
+
VALUE filename;
|
14
|
+
VALUE str;
|
15
|
+
} ruby_xml_sax_parser;
|
16
|
+
|
17
|
+
void ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp);
|
18
|
+
void ruby_init_xml_sax_parser(void);
|
19
|
+
VALUE ruby_xml_sax_parser_new(VALUE class);
|
20
|
+
|
21
|
+
#endif
|
@@ -0,0 +1,142 @@
|
|
1
|
+
#include "libxml.h"
|
2
|
+
#include "ruby_xml_schema.h"
|
3
|
+
|
4
|
+
VALUE cXMLSchema;
|
5
|
+
|
6
|
+
static void
|
7
|
+
ruby_xml_schema_mark(ruby_xml_schema *rxschema) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
|
11
|
+
void
|
12
|
+
ruby_xml_schema_free(ruby_xml_schema *rxschema) {
|
13
|
+
if (rxschema->schema != NULL) {
|
14
|
+
xmlSchemaFree(rxschema->schema);
|
15
|
+
rxschema->schema = NULL;
|
16
|
+
}
|
17
|
+
|
18
|
+
free(rxschema);
|
19
|
+
}
|
20
|
+
|
21
|
+
/*
|
22
|
+
* call-seq:
|
23
|
+
* XML::Scheme.new(schema_uri) => schema
|
24
|
+
*
|
25
|
+
* Create a new schema from the specified URI.
|
26
|
+
*/
|
27
|
+
VALUE
|
28
|
+
ruby_xml_schema_init_from_uri(int argc, VALUE *argv, VALUE class) {
|
29
|
+
VALUE uri;
|
30
|
+
xmlSchemaParserCtxtPtr parser;
|
31
|
+
xmlSchemaPtr sptr;
|
32
|
+
|
33
|
+
switch (argc) {
|
34
|
+
case 1:
|
35
|
+
rb_scan_args(argc, argv, "10", &uri);
|
36
|
+
|
37
|
+
Check_Type(uri, T_STRING);
|
38
|
+
|
39
|
+
parser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
|
40
|
+
sptr = xmlSchemaParse(parser);
|
41
|
+
xmlSchemaFreeParserCtxt(parser);
|
42
|
+
break;
|
43
|
+
default:
|
44
|
+
rb_raise(rb_eArgError, "wrong number of arguments (need 1)");
|
45
|
+
}
|
46
|
+
return Qnil;
|
47
|
+
}
|
48
|
+
|
49
|
+
/*
|
50
|
+
* call-seq:
|
51
|
+
* XML::Schema.from_string("schema_data") => "value"
|
52
|
+
*
|
53
|
+
* Create a new schema using the specified string.
|
54
|
+
*/
|
55
|
+
VALUE
|
56
|
+
ruby_xml_schema_init_from_str(int argc, VALUE *argv, VALUE class) {
|
57
|
+
VALUE schema_str;
|
58
|
+
|
59
|
+
xmlSchemaParserCtxtPtr parser;
|
60
|
+
//xmlSchemaPtr sptr;
|
61
|
+
ruby_xml_schema *rxschema;
|
62
|
+
|
63
|
+
switch (argc) {
|
64
|
+
case 1:
|
65
|
+
rb_scan_args(argc, argv, "10", &schema_str);
|
66
|
+
|
67
|
+
Check_Type(schema_str, T_STRING);
|
68
|
+
|
69
|
+
parser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(StringValuePtr(schema_str)));
|
70
|
+
rxschema = ALLOC(ruby_xml_schema);
|
71
|
+
rxschema->schema = xmlSchemaParse(parser);
|
72
|
+
xmlSchemaFreeParserCtxt(parser);
|
73
|
+
|
74
|
+
return( Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, rxschema) );
|
75
|
+
default:
|
76
|
+
rb_raise(rb_eArgError, "wrong number of arguments (need 1)");
|
77
|
+
}
|
78
|
+
return Qnil;
|
79
|
+
}
|
80
|
+
|
81
|
+
/* TODO what is this patch doing here?
|
82
|
+
|
83
|
+
xmlSchemaParserCtxtPtr parser;
|
84
|
+
xmlSchemaPtr sptr;
|
85
|
+
xmlSchemaValidCtxtPtr vptr;
|
86
|
+
+ int is_invalid;
|
87
|
+
|
88
|
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) {
|
89
|
+
return;
|
90
|
+
@@ -598,26 +598,24 @@
|
91
|
+
convert_to_string_ex(&source);
|
92
|
+
parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
|
93
|
+
sptr = xmlSchemaParse(parser);
|
94
|
+
break;
|
95
|
+
case SCHEMA_BLOB:
|
96
|
+
convert_to_string_ex(&source);
|
97
|
+
parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source));
|
98
|
+
sptr = xmlSchemaParse(parser);
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
|
102
|
+
vptr = xmlSchemaNewValidCtxt(sptr);
|
103
|
+
+ is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
|
104
|
+
xmlSchemaFree(sptr);
|
105
|
+
xmlSchemaFreeValidCtxt(vptr);
|
106
|
+
xmlSchemaFreeParserCtxt(parser);
|
107
|
+
|
108
|
+
- if (is_valid) {
|
109
|
+
- RETURN_TRUE;
|
110
|
+
- } else {
|
111
|
+
+ if (is_invalid) {
|
112
|
+
RETURN_FALSE;
|
113
|
+
+ } else {
|
114
|
+
+ RETURN_TRUE;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}}}
|
118
|
+
@@ -695,7 +693,7 @@
|
119
|
+
{
|
120
|
+
if (!strcmp(method, "xsearch")) {
|
121
|
+
simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
122
|
+
-#ifdef xmlSchemaParserCtxtPtr
|
123
|
+
+#ifdef LIBXML_SCHEMAS_ENABLED
|
124
|
+
} else if (!strcmp(method, "validate_schema_file")) {
|
125
|
+
simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE);
|
126
|
+
} else if (!strcmp(method, "validate_schema_buffer")) {
|
127
|
+
*/
|
128
|
+
|
129
|
+
void ruby_schema_free(ruby_xml_schema *rxs) {
|
130
|
+
}
|
131
|
+
|
132
|
+
// Rdoc needs to know
|
133
|
+
#ifdef RDOC_NEVER_DEFINED
|
134
|
+
mXML = rb_define_module("XML");
|
135
|
+
#endif
|
136
|
+
|
137
|
+
void ruby_init_xml_schema(void) {
|
138
|
+
cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
|
139
|
+
rb_define_singleton_method(cXMLSchema, "new", ruby_xml_schema_init_from_uri, -1);
|
140
|
+
rb_define_singleton_method(cXMLSchema, "from_string", ruby_xml_schema_init_from_str, -1);
|
141
|
+
}
|
142
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#ifndef __RUBY_XML_SCHEMA__
|
2
|
+
#define __RUBY_XML_SCHEMA__
|
3
|
+
|
4
|
+
#include <libxml/schemasInternals.h>
|
5
|
+
#include <libxml/xmlschemas.h>
|
6
|
+
|
7
|
+
extern VALUE cXMLDtd;
|
8
|
+
|
9
|
+
typedef struct rxp_schema {
|
10
|
+
xmlSchemaPtr schema; /* Schema interface */
|
11
|
+
} ruby_xml_schema;
|
12
|
+
|
13
|
+
void ruby_init_xml_schema(void);
|
14
|
+
void ruby_schema_free(ruby_xml_schema *rxs);
|
15
|
+
#endif
|
16
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/* $Id: ruby_xml_tree.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
#include "ruby_xml_tree.h"
|
7
|
+
|
8
|
+
VALUE cXMLTree;
|
9
|
+
|
10
|
+
// Rdoc needs to know
|
11
|
+
#ifdef RDOC_NEVER_DEFINED
|
12
|
+
mXML = rb_define_module("XML");
|
13
|
+
#endif
|
14
|
+
|
15
|
+
void
|
16
|
+
ruby_init_xml_tree(void) {
|
17
|
+
cXMLTree = rb_define_class_under(mXML, "Tree", rb_cObject);
|
18
|
+
|
19
|
+
rb_define_const(cXMLTree, "ELEMENT_NODE", INT2FIX(XML_ELEMENT_NODE));
|
20
|
+
rb_define_const(cXMLTree, "ATTRIBUTE_NODE", INT2FIX(XML_ATTRIBUTE_NODE));
|
21
|
+
rb_define_const(cXMLTree, "TEXT_NODE", INT2FIX(XML_TEXT_NODE));
|
22
|
+
rb_define_const(cXMLTree, "CDATA_SECTION_NODE", INT2FIX(XML_CDATA_SECTION_NODE));
|
23
|
+
rb_define_const(cXMLTree, "ENTITY_REF_NODE", INT2FIX(XML_ENTITY_REF_NODE));
|
24
|
+
rb_define_const(cXMLTree, "ENTITY_NODE", INT2FIX(XML_ENTITY_NODE));
|
25
|
+
rb_define_const(cXMLTree, "PI_NODE", INT2FIX(XML_PI_NODE));
|
26
|
+
rb_define_const(cXMLTree, "COMMENT_NODE", INT2FIX(XML_COMMENT_NODE));
|
27
|
+
rb_define_const(cXMLTree, "DOCUMENT_NODE", INT2FIX(XML_DOCUMENT_NODE));
|
28
|
+
rb_define_const(cXMLTree, "DOCUMENT_TYPE_NODE", INT2FIX(XML_DOCUMENT_TYPE_NODE));
|
29
|
+
rb_define_const(cXMLTree, "DOCUMENT_FRAG_NODE", INT2FIX(XML_DOCUMENT_FRAG_NODE));
|
30
|
+
rb_define_const(cXMLTree, "NOTATION_NODE", INT2FIX(XML_NOTATION_NODE));
|
31
|
+
rb_define_const(cXMLTree, "HTML_DOCUMENT_NODE", INT2FIX(XML_HTML_DOCUMENT_NODE));
|
32
|
+
rb_define_const(cXMLTree, "DTD_NODE", INT2FIX(XML_DTD_NODE));
|
33
|
+
rb_define_const(cXMLTree, "ELEMENT_DECL", INT2FIX(XML_ELEMENT_DECL));
|
34
|
+
rb_define_const(cXMLTree, "ATTRIBUTE_DECL", INT2FIX(XML_ATTRIBUTE_DECL));
|
35
|
+
rb_define_const(cXMLTree, "ENTITY_DECL", INT2FIX(XML_ENTITY_DECL));
|
36
|
+
rb_define_const(cXMLTree, "NAMESPACE_DECL", INT2FIX(XML_NAMESPACE_DECL));
|
37
|
+
rb_define_const(cXMLTree, "XINCLUDE_START", INT2FIX(XML_XINCLUDE_START));
|
38
|
+
rb_define_const(cXMLTree, "XINCLUDE_END", INT2FIX(XML_XINCLUDE_END));
|
39
|
+
|
40
|
+
#ifdef LIBXML_DOCB_ENABLED
|
41
|
+
rb_define_const(cXMLTree, "DOCB_DOCUMENT_NODE", INT2FIX(XML_DOCB_DOCUMENT_NODE));
|
42
|
+
#endif
|
43
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/* $Id: ruby_xml_tree.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_TREE__
|
6
|
+
#define __RUBY_XML_TREE__
|
7
|
+
|
8
|
+
extern VALUE cXMLTree;
|
9
|
+
|
10
|
+
void ruby_init_xml_tree(void);
|
11
|
+
|
12
|
+
#endif
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/* $Id: ruby_xml_xinclude.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
#include "ruby_xml_xinclude.h"
|
7
|
+
|
8
|
+
VALUE cXMLXInclude;
|
9
|
+
VALUE eXMLXIncludeError;
|
10
|
+
|
11
|
+
// Rdoc needs to know
|
12
|
+
#ifdef RDOC_NEVER_DEFINED
|
13
|
+
mXML = rb_define_module("XML");
|
14
|
+
#endif
|
15
|
+
|
16
|
+
void
|
17
|
+
ruby_init_xml_xinclude(void) {
|
18
|
+
cXMLXInclude = rb_define_class_under(mXML, "XInclude", rb_cObject);
|
19
|
+
eXMLXIncludeError = rb_define_class_under(cXMLXInclude, "Error", rb_eRuntimeError);
|
20
|
+
}
|