libxml-ruby 2.0.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/HISTORY +516 -0
  2. data/LICENSE +23 -0
  3. data/MANIFEST +165 -0
  4. data/README.rdoc +161 -0
  5. data/Rakefile +82 -0
  6. data/ext/libxml/extconf.rb +122 -0
  7. data/ext/libxml/libxml.c +93 -0
  8. data/ext/libxml/ruby_libxml.h +101 -0
  9. data/ext/libxml/ruby_xml.c +893 -0
  10. data/ext/libxml/ruby_xml.h +10 -0
  11. data/ext/libxml/ruby_xml_attr.c +352 -0
  12. data/ext/libxml/ruby_xml_attr.h +14 -0
  13. data/ext/libxml/ruby_xml_attr_decl.c +171 -0
  14. data/ext/libxml/ruby_xml_attr_decl.h +13 -0
  15. data/ext/libxml/ruby_xml_attributes.c +277 -0
  16. data/ext/libxml/ruby_xml_attributes.h +17 -0
  17. data/ext/libxml/ruby_xml_cbg.c +85 -0
  18. data/ext/libxml/ruby_xml_document.c +958 -0
  19. data/ext/libxml/ruby_xml_document.h +17 -0
  20. data/ext/libxml/ruby_xml_dtd.c +257 -0
  21. data/ext/libxml/ruby_xml_dtd.h +9 -0
  22. data/ext/libxml/ruby_xml_encoding.c +221 -0
  23. data/ext/libxml/ruby_xml_encoding.h +16 -0
  24. data/ext/libxml/ruby_xml_error.c +1004 -0
  25. data/ext/libxml/ruby_xml_error.h +14 -0
  26. data/ext/libxml/ruby_xml_html_parser.c +92 -0
  27. data/ext/libxml/ruby_xml_html_parser.h +12 -0
  28. data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
  29. data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
  30. data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
  31. data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
  32. data/ext/libxml/ruby_xml_input_cbg.c +191 -0
  33. data/ext/libxml/ruby_xml_input_cbg.h +20 -0
  34. data/ext/libxml/ruby_xml_io.c +30 -0
  35. data/ext/libxml/ruby_xml_io.h +9 -0
  36. data/ext/libxml/ruby_xml_namespace.c +170 -0
  37. data/ext/libxml/ruby_xml_namespace.h +12 -0
  38. data/ext/libxml/ruby_xml_namespaces.c +295 -0
  39. data/ext/libxml/ruby_xml_namespaces.h +11 -0
  40. data/ext/libxml/ruby_xml_node.c +1386 -0
  41. data/ext/libxml/ruby_xml_node.h +13 -0
  42. data/ext/libxml/ruby_xml_parser.c +94 -0
  43. data/ext/libxml/ruby_xml_parser.h +14 -0
  44. data/ext/libxml/ruby_xml_parser_context.c +982 -0
  45. data/ext/libxml/ruby_xml_parser_context.h +12 -0
  46. data/ext/libxml/ruby_xml_parser_options.c +68 -0
  47. data/ext/libxml/ruby_xml_parser_options.h +14 -0
  48. data/ext/libxml/ruby_xml_reader.c +1057 -0
  49. data/ext/libxml/ruby_xml_reader.h +14 -0
  50. data/ext/libxml/ruby_xml_relaxng.c +111 -0
  51. data/ext/libxml/ruby_xml_relaxng.h +10 -0
  52. data/ext/libxml/ruby_xml_sax2_handler.c +334 -0
  53. data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
  54. data/ext/libxml/ruby_xml_sax_parser.c +136 -0
  55. data/ext/libxml/ruby_xml_sax_parser.h +12 -0
  56. data/ext/libxml/ruby_xml_schema.c +159 -0
  57. data/ext/libxml/ruby_xml_schema.h +11 -0
  58. data/ext/libxml/ruby_xml_version.h +9 -0
  59. data/ext/libxml/ruby_xml_xinclude.c +18 -0
  60. data/ext/libxml/ruby_xml_xinclude.h +13 -0
  61. data/ext/libxml/ruby_xml_xpath.c +107 -0
  62. data/ext/libxml/ruby_xml_xpath.h +12 -0
  63. data/ext/libxml/ruby_xml_xpath_context.c +390 -0
  64. data/ext/libxml/ruby_xml_xpath_context.h +11 -0
  65. data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
  66. data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
  67. data/ext/libxml/ruby_xml_xpath_object.c +336 -0
  68. data/ext/libxml/ruby_xml_xpath_object.h +19 -0
  69. data/ext/libxml/ruby_xml_xpointer.c +101 -0
  70. data/ext/libxml/ruby_xml_xpointer.h +13 -0
  71. data/ext/mingw/Rakefile +34 -0
  72. data/ext/mingw/build.rake +41 -0
  73. data/ext/vc/libxml_ruby.sln +26 -0
  74. data/lib/1.8/libxml_ruby.so +0 -0
  75. data/lib/1.9/libxml_ruby.so +0 -0
  76. data/lib/libxml.rb +30 -0
  77. data/lib/libxml/attr.rb +113 -0
  78. data/lib/libxml/attr_decl.rb +80 -0
  79. data/lib/libxml/attributes.rb +14 -0
  80. data/lib/libxml/document.rb +192 -0
  81. data/lib/libxml/error.rb +90 -0
  82. data/lib/libxml/hpricot.rb +78 -0
  83. data/lib/libxml/html_parser.rb +96 -0
  84. data/lib/libxml/namespace.rb +62 -0
  85. data/lib/libxml/namespaces.rb +38 -0
  86. data/lib/libxml/node.rb +399 -0
  87. data/lib/libxml/ns.rb +22 -0
  88. data/lib/libxml/parser.rb +367 -0
  89. data/lib/libxml/properties.rb +23 -0
  90. data/lib/libxml/reader.rb +29 -0
  91. data/lib/libxml/sax_callbacks.rb +180 -0
  92. data/lib/libxml/sax_parser.rb +58 -0
  93. data/lib/libxml/tree.rb +29 -0
  94. data/lib/libxml/xpath_object.rb +16 -0
  95. data/lib/xml.rb +16 -0
  96. data/lib/xml/libxml.rb +10 -0
  97. data/libxml-ruby.gemspec +50 -0
  98. data/script/benchmark/depixelate +634 -0
  99. data/script/benchmark/hamlet.xml +9055 -0
  100. data/script/benchmark/parsecount +170 -0
  101. data/script/benchmark/sock_entries.xml +507 -0
  102. data/script/benchmark/throughput +41 -0
  103. data/script/test +6 -0
  104. data/setup.rb +1585 -0
  105. data/test/etc_doc_to_s.rb +21 -0
  106. data/test/ets_doc_file.rb +17 -0
  107. data/test/ets_doc_to_s.rb +23 -0
  108. data/test/ets_gpx.rb +28 -0
  109. data/test/ets_node_gc.rb +23 -0
  110. data/test/ets_test.xml +2 -0
  111. data/test/ets_tsr.rb +11 -0
  112. data/test/model/atom.xml +13 -0
  113. data/test/model/bands.iso-8859-1.xml +5 -0
  114. data/test/model/bands.utf-8.xml +5 -0
  115. data/test/model/bands.xml +5 -0
  116. data/test/model/books.xml +146 -0
  117. data/test/model/merge_bug_data.xml +58 -0
  118. data/test/model/ruby-lang.html +238 -0
  119. data/test/model/rubynet.xml +79 -0
  120. data/test/model/rubynet_project +1 -0
  121. data/test/model/shiporder.rnc +28 -0
  122. data/test/model/shiporder.rng +86 -0
  123. data/test/model/shiporder.xml +23 -0
  124. data/test/model/shiporder.xsd +31 -0
  125. data/test/model/soap.xml +27 -0
  126. data/test/model/xinclude.xml +5 -0
  127. data/test/rb-magic-comment.rb +33 -0
  128. data/test/tc_attr.rb +181 -0
  129. data/test/tc_attr_decl.rb +133 -0
  130. data/test/tc_attributes.rb +135 -0
  131. data/test/tc_deprecated_require.rb +13 -0
  132. data/test/tc_document.rb +119 -0
  133. data/test/tc_document_write.rb +187 -0
  134. data/test/tc_dtd.rb +125 -0
  135. data/test/tc_error.rb +138 -0
  136. data/test/tc_html_parser.rb +140 -0
  137. data/test/tc_namespace.rb +62 -0
  138. data/test/tc_namespaces.rb +177 -0
  139. data/test/tc_node.rb +258 -0
  140. data/test/tc_node_cdata.rb +51 -0
  141. data/test/tc_node_comment.rb +33 -0
  142. data/test/tc_node_copy.rb +42 -0
  143. data/test/tc_node_edit.rb +160 -0
  144. data/test/tc_node_text.rb +71 -0
  145. data/test/tc_node_write.rb +108 -0
  146. data/test/tc_node_xlink.rb +29 -0
  147. data/test/tc_parser.rb +336 -0
  148. data/test/tc_parser_context.rb +189 -0
  149. data/test/tc_properties.rb +39 -0
  150. data/test/tc_reader.rb +298 -0
  151. data/test/tc_relaxng.rb +54 -0
  152. data/test/tc_sax_parser.rb +276 -0
  153. data/test/tc_schema.rb +53 -0
  154. data/test/tc_traversal.rb +222 -0
  155. data/test/tc_xinclude.rb +21 -0
  156. data/test/tc_xml.rb +226 -0
  157. data/test/tc_xpath.rb +195 -0
  158. data/test/tc_xpath_context.rb +80 -0
  159. data/test/tc_xpath_expression.rb +38 -0
  160. data/test/tc_xpointer.rb +74 -0
  161. data/test/test_helper.rb +14 -0
  162. data/test/test_suite.rb +39 -0
  163. metadata +254 -0
@@ -0,0 +1,12 @@
1
+ /* $Id: ruby_xml_sax_parser.h 666 2008-12-07 00:16:50Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RXML_SAX2_HANDLER__
6
+ #define __RXML_SAX2_HANDLER__
7
+
8
+ extern xmlSAXHandler rxml_sax_handler;
9
+
10
+ void rxml_init_sax2_handler(void);
11
+
12
+ #endif
@@ -0,0 +1,136 @@
1
+ /* $Id$ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_sax_parser.h"
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
+ * 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.string(my_string)
34
+ * parser.callbacks = MyCallbacks.new
35
+ * parser.parse
36
+ *
37
+ * You can also parse strings (see XML::SaxParser.string) and
38
+ * io objects (see XML::SaxParser.io).
39
+ */
40
+
41
+ VALUE cXMLSaxParser;
42
+ static ID CALLBACKS_ATTR;
43
+ static ID CONTEXT_ATTR;
44
+
45
+
46
+ /* ====== Parser =========== */
47
+
48
+ /*static int rxml_sax_parser_parse_io(VALUE self, VALUE input)
49
+ {
50
+ VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
51
+ VALUE io = rb_ivar_get(input, IO_ATTR);
52
+ VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
53
+ xmlCharEncoding xmlEncoding = NUM2INT(encoding);
54
+ xmlParserCtxtPtr ctxt =
55
+ xmlCreateIOParserCtxt((xmlSAXHandlerPtr) &rxml_sax_handler,
56
+ (void *) handler, (xmlInputReadCallback) rxml_read_callback, NULL,
57
+ (void *) io, xmlEncoding);
58
+ return xmlParseDocument(ctxt);
59
+ }*/
60
+
61
+
62
+ /*
63
+ * call-seq:
64
+ * parser.initialize(context) -> XML::Parser
65
+ *
66
+ * Creates a new XML::Parser from the specified
67
+ * XML::Parser::Context.
68
+ */
69
+ static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)
70
+ {
71
+ VALUE context = Qnil;
72
+
73
+ rb_scan_args(argc, argv, "01", &context);
74
+
75
+ if (context == Qnil)
76
+ {
77
+ rb_warn("Passing no parameters to XML::SaxParser.new is deprecated. Pass an instance of XML::Parser::Context instead.");
78
+ context = rb_class_new_instance(0, NULL, cXMLParserContext);
79
+ }
80
+
81
+ rb_ivar_set(self, CONTEXT_ATTR, context);
82
+ return self;
83
+ }
84
+
85
+ /*
86
+ * call-seq:
87
+ * parser.parse -> (true|false)
88
+ *
89
+ * Parse the input XML, generating callbacks to the object
90
+ * registered via the +callbacks+ attributesibute.
91
+ */
92
+ static VALUE rxml_sax_parser_parse(VALUE self)
93
+ {
94
+ int status;
95
+ VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
96
+ xmlParserCtxtPtr ctxt;
97
+ Data_Get_Struct(context, xmlParserCtxt, ctxt);
98
+
99
+ ctxt->sax2 = 1;
100
+ ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
101
+
102
+ if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
103
+ xmlFree(ctxt->sax);
104
+
105
+ ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(rxml_sax_handler));
106
+ if (ctxt->sax == NULL)
107
+ rb_fatal("Not enough memory.");
108
+ memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
109
+
110
+ status = xmlParseDocument(ctxt);
111
+
112
+ /* Now check the parsing result*/
113
+ if (status == -1 || !ctxt->wellFormed)
114
+ {
115
+ if (ctxt->myDoc)
116
+ xmlFreeDoc(ctxt->myDoc);
117
+
118
+ rxml_raise(&ctxt->lastError);
119
+ }
120
+ return Qtrue;
121
+ }
122
+
123
+ void rxml_init_sax_parser(void)
124
+ {
125
+ /* SaxParser */
126
+ cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
127
+
128
+ /* Atributes */
129
+ CALLBACKS_ATTR = rb_intern("@callbacks");
130
+ CONTEXT_ATTR = rb_intern("@context");
131
+ rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
132
+
133
+ /* Instance Methods */
134
+ rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
135
+ rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
136
+ }
@@ -0,0 +1,12 @@
1
+ /* $Id$ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RXML_SAX_PARSER__
6
+ #define __RXML_SAX_PARSER__
7
+
8
+ extern VALUE cXMLSaxParser;
9
+
10
+ void rxml_init_sax_parser(void);
11
+
12
+ #endif
@@ -0,0 +1,159 @@
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml_schema.h"
3
+
4
+ /*
5
+ * Document-class: LibXML::XML::Schema
6
+ *
7
+ * The XML::Schema class is used to prepare XML Schemas for validation of xml
8
+ * 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_schema method providing the XML::Schema object
15
+ * as parameter. The method return true if the document validates, false
16
+ * otherwise.
17
+ *
18
+ * Basic usage:
19
+ *
20
+ * # parse schema as xml document
21
+ * schema_document = XML::Document.file('schema.rng')
22
+ *
23
+ * # prepare schema for validation
24
+ * schema = XML::Schema.document(schema_document)
25
+ *
26
+ * # parse xml document to be validated
27
+ * instance = XML::Document.file('instance.xml')
28
+ *
29
+ * # validate
30
+ * instance.validate_schema(schema)
31
+ */
32
+
33
+ VALUE cXMLSchema;
34
+
35
+ static void rxml_schema_free(xmlSchemaPtr xschema)
36
+ {
37
+ xmlSchemaFree(xschema);
38
+ }
39
+
40
+ /*
41
+ * call-seq:
42
+ * XML::Schema.initialize(schema_uri) -> schema
43
+ *
44
+ * Create a new schema from the specified URI.
45
+ */
46
+ static VALUE rxml_schema_init_from_uri(VALUE class, VALUE uri)
47
+ {
48
+ xmlSchemaParserCtxtPtr xparser;
49
+ xmlSchemaPtr xschema;
50
+
51
+ Check_Type(uri, T_STRING);
52
+
53
+ xparser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
54
+ xschema = xmlSchemaParse(xparser);
55
+ xmlSchemaFreeParserCtxt(xparser);
56
+
57
+ return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
58
+ }
59
+
60
+ /*
61
+ * call-seq:
62
+ * XML::Schema.document(document) -> schema
63
+ *
64
+ * Create a new schema from the specified document.
65
+ */
66
+ static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
67
+ {
68
+ xmlDocPtr xdoc;
69
+ xmlSchemaPtr xschema;
70
+ xmlSchemaParserCtxtPtr xparser;
71
+
72
+ Data_Get_Struct(document, xmlDoc, xdoc);
73
+
74
+ xparser = xmlSchemaNewDocParserCtxt(xdoc);
75
+ xschema = xmlSchemaParse(xparser);
76
+ xmlSchemaFreeParserCtxt(xparser);
77
+
78
+ return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
79
+ }
80
+
81
+ /*
82
+ * call-seq:
83
+ * XML::Schema.string("schema_data") -> "value"
84
+ *
85
+ * Create a new schema using the specified string.
86
+ */
87
+ static VALUE rxml_schema_init_from_string(VALUE self, VALUE schema_str)
88
+ {
89
+ xmlSchemaParserCtxtPtr xparser;
90
+ xmlSchemaPtr xschema;
91
+
92
+ Check_Type(schema_str, T_STRING);
93
+
94
+ xparser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(
95
+ StringValuePtr(schema_str)));
96
+ xschema = xmlSchemaParse(xparser);
97
+ xmlSchemaFreeParserCtxt(xparser);
98
+
99
+ return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
100
+ }
101
+
102
+ /* TODO what is this patch doing here?
103
+
104
+ xmlSchemaParserCtxtPtr parser;
105
+ xmlSchemaPtr sptr;
106
+ xmlSchemaValidCtxtPtr vptr;
107
+ + int is_invalid;
108
+
109
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) {
110
+ return;
111
+ @@ -598,26 +598,24 @@
112
+ convert_to_string_ex(&source);
113
+ parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
114
+ sptr = xmlSchemaParse(parser);
115
+ break;
116
+ case SCHEMA_BLOB:
117
+ convert_to_string_ex(&source);
118
+ parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source));
119
+ sptr = xmlSchemaParse(parser);
120
+ break;
121
+ }
122
+
123
+ vptr = xmlSchemaNewValidCtxt(sptr);
124
+ + is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
125
+ xmlSchemaFree(sptr);
126
+ xmlSchemaFreeValidCtxt(vptr);
127
+ xmlSchemaFreeParserCtxt(parser);
128
+
129
+ - if (is_valid) {
130
+ - RETURN_TRUE;
131
+ - } else {
132
+ + if (is_invalid) {
133
+ RETURN_FALSE;
134
+ + } else {
135
+ + RETURN_TRUE;
136
+ }
137
+ }
138
+ }}}
139
+ @@ -695,7 +693,7 @@
140
+ {
141
+ if (!strcmp(method, "xsearch")) {
142
+ simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
143
+ -#ifdef xmlSchemaParserCtxtPtr
144
+ +#ifdef LIBXML_SCHEMAS_ENABLED
145
+ } else if (!strcmp(method, "validate_schema_file")) {
146
+ simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE);
147
+ } else if (!strcmp(method, "validate_schema_buffer")) {
148
+ */
149
+
150
+ void rxml_init_schema(void)
151
+ {
152
+ cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
153
+ rb_define_singleton_method(cXMLSchema, "new", rxml_schema_init_from_uri, 1);
154
+ rb_define_singleton_method(cXMLSchema, "from_string",
155
+ rxml_schema_init_from_string, 1);
156
+ rb_define_singleton_method(cXMLSchema, "document",
157
+ rxml_schema_init_from_document, 1);
158
+ }
159
+
@@ -0,0 +1,11 @@
1
+ #ifndef __RXML_SCHEMA__
2
+ #define __RXML_SCHEMA__
3
+
4
+ #include <libxml/schemasInternals.h>
5
+ #include <libxml/xmlschemas.h>
6
+
7
+ extern VALUE cXMLSchema;
8
+
9
+ void rxml_init_schema(void);
10
+ #endif
11
+
@@ -0,0 +1,9 @@
1
+ /* Don't nuke this block! It is used for automatically updating the
2
+ * versions below. VERSION = string formatting, VERNUM = numbered
3
+ * version for inline testing: increment both or none at all.*/
4
+ #define RUBY_LIBXML_VERSION "2.0.0"
5
+ #define RUBY_LIBXML_VERNUM 200
6
+ #define RUBY_LIBXML_VER_MAJ 2
7
+ #define RUBY_LIBXML_VER_MIN 0
8
+ #define RUBY_LIBXML_VER_MIC 0
9
+ #define RUBY_LIBXML_VER_PATCH 0
@@ -0,0 +1,18 @@
1
+ /* $Id$ */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include "ruby_xml_xinclude.h"
5
+
6
+ VALUE cXMLXInclude;
7
+
8
+ /*
9
+ * Document-class: LibXML::XML::XInclude
10
+ *
11
+ * The ruby bindings do not currently expose libxml's
12
+ * XInclude fuctionality.
13
+ */
14
+
15
+ void rxml_init_xinclude(void)
16
+ {
17
+ cXMLXInclude = rb_define_class_under(mXML, "XInclude", rb_cObject);
18
+ }
@@ -0,0 +1,13 @@
1
+ /* $Id$ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RXML_XINCLUDE__
6
+ #define __RXML_XINCLUDE__
7
+
8
+ extern VALUE cXMLXInclude;
9
+ extern VALUE eXMLXIncludeError;
10
+
11
+ void rxml_init_xinclude(void);
12
+
13
+ #endif
@@ -0,0 +1,107 @@
1
+ /* $Id$ */
2
+
3
+ /*
4
+ * Document-class: LibXML::XML::XPath
5
+ *
6
+ * The XML::XPath module is used to query XML documents. It is
7
+ * usually accessed via the XML::Document#find or
8
+ * XML::Node#find methods. For example:
9
+ *
10
+ * document.find('/foo', namespaces) -> XML::XPath::Object
11
+ *
12
+ * The optional namespaces parameter can be a string, array or
13
+ * hash table.
14
+ *
15
+ * document.find('/foo', 'xlink:http://www.w3.org/1999/xlink')
16
+ * document.find('/foo', ['xlink:http://www.w3.org/1999/xlink',
17
+ * 'xi:http://www.w3.org/2001/XInclude')
18
+ * document.find('/foo', 'xlink' => 'http://www.w3.org/1999/xlink',
19
+ * 'xi' => 'http://www.w3.org/2001/XInclude')
20
+ *
21
+ *
22
+ * === Working With Default Namespaces
23
+ *
24
+ * Finding namespaced elements and attributes can be tricky.
25
+ * Lets work through an example of a document with a default
26
+ * namespace:
27
+ *
28
+ * <?xml version="1.0" encoding="utf-8"?>
29
+ * <feed xmlns="http://www.w3.org/2005/Atom">
30
+ * <title type="text">Phil Bogle's Contacts</title>
31
+ * </feed>
32
+ *
33
+ * To find nodes you must define the atom namespace for
34
+ * libxml. One way to do this is:
35
+ *
36
+ * node = doc.find('atom:title', 'atom:http://www.w3.org/2005/Atom')
37
+ *
38
+ * Alternatively, you can register the default namespace like this:
39
+ *
40
+ * doc.root.namespaces.default_prefix = 'atom'
41
+ * node = doc.find('atom:title')
42
+ *
43
+ * === More Complex Namespace Examples
44
+ *
45
+ * Lets work through some more complex examples using the
46
+ * following xml document:
47
+ *
48
+ * <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
49
+ * <soap:Body>
50
+ * <getManufacturerNamesResponse xmlns="http://services.somewhere.com">
51
+ * <IDAndNameList xmlns="http://services.somewhere.com">
52
+ * <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com"/>
53
+ * </IDAndNameList>
54
+ * </getManufacturerNamesResponse>
55
+ * </soap:Envelope>
56
+ *
57
+ * # Since the soap namespace is defined on the root
58
+ * # node we can directly use it.
59
+ * doc.find('/soap:Envelope')
60
+ *
61
+ * # Since the ns1 namespace is not defined on the root node
62
+ * # we have to first register it with the xpath engine.
63
+ * doc.find('//ns1:IdAndName',
64
+ * 'ns1:http://domain.somewhere.com')
65
+ *
66
+ * # Since the getManufacturerNamesResponse element uses a default
67
+ * # namespace we first have to give it a prefix and register
68
+ * # it with the xpath engine.
69
+ * doc.find('//ns:getManufacturerNamesResponse',
70
+ * 'ns:http://services.somewhere.com')
71
+ *
72
+ * # Here is an example showing a complex namespace aware
73
+ * # xpath expression.
74
+ * doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
75
+ * ['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
76
+ */
77
+
78
+
79
+ #include "ruby_libxml.h"
80
+
81
+ VALUE mXPath;
82
+
83
+ void rxml_init_xpath(void)
84
+ {
85
+ mXPath = rb_define_module_under(mXML, "XPath");
86
+
87
+ /* 0: Undefined value. */
88
+ rb_define_const(mXPath, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
89
+ /* 1: A nodeset, will be wrapped by XPath Object. */
90
+ rb_define_const(mXPath, "NODESET", INT2NUM(XPATH_NODESET));
91
+ /* 2: A boolean value. */
92
+ rb_define_const(mXPath, "BOOLEAN", INT2NUM(XPATH_BOOLEAN));
93
+ /* 3: A numeric value. */
94
+ rb_define_const(mXPath, "NUMBER", INT2NUM(XPATH_NUMBER));
95
+ /* 4: A string value. */
96
+ rb_define_const(mXPath, "STRING", INT2NUM(XPATH_STRING));
97
+ /* 5: An xpointer point */
98
+ rb_define_const(mXPath, "POINT", INT2NUM(XPATH_POINT));
99
+ /* 6: An xpointer range */
100
+ rb_define_const(mXPath, "RANGE", INT2NUM(XPATH_RANGE));
101
+ /* 7: An xpointer location set */
102
+ rb_define_const(mXPath, "LOCATIONSET", INT2NUM(XPATH_LOCATIONSET));
103
+ /* 8: XPath user type */
104
+ rb_define_const(mXPath, "USERS", INT2NUM(XPATH_USERS));
105
+ /* 9: An XSLT value tree, non modifiable */
106
+ rb_define_const(mXPath, "XSLT_TREE", INT2NUM(XPATH_XSLT_TREE));
107
+ }