libxml-ruby 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/CHANGES +18 -0
  2. data/RAKEFILE +15 -39
  3. data/README +48 -47
  4. data/ext/libxml/libxml.c +847 -22
  5. data/ext/libxml/ruby_libxml.h +71 -95
  6. data/ext/libxml/ruby_xml_attr.c +500 -500
  7. data/ext/libxml/ruby_xml_attributes.c +1 -1
  8. data/ext/libxml/ruby_xml_document.c +1144 -1135
  9. data/ext/libxml/ruby_xml_document.h +4 -11
  10. data/ext/libxml/ruby_xml_dtd.c +27 -0
  11. data/ext/libxml/ruby_xml_encoding.c +164 -0
  12. data/ext/libxml/ruby_xml_encoding.h +13 -0
  13. data/ext/libxml/ruby_xml_error.c +941 -0
  14. data/ext/libxml/ruby_xml_error.h +13 -0
  15. data/ext/libxml/ruby_xml_html_parser.c +71 -387
  16. data/ext/libxml/ruby_xml_html_parser.h +1 -17
  17. data/ext/libxml/ruby_xml_input.c +179 -0
  18. data/ext/libxml/ruby_xml_input.h +18 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +17 -3
  20. data/ext/libxml/ruby_xml_node.c +1566 -1582
  21. data/ext/libxml/ruby_xml_node.h +1 -4
  22. data/ext/libxml/ruby_xml_ns.c +14 -3
  23. data/ext/libxml/ruby_xml_parser.c +164 -1398
  24. data/ext/libxml/ruby_xml_parser.h +5 -17
  25. data/ext/libxml/ruby_xml_parser_context.c +131 -169
  26. data/ext/libxml/ruby_xml_parser_context.h +2 -9
  27. data/ext/libxml/ruby_xml_reader.c +910 -945
  28. data/ext/libxml/ruby_xml_relaxng.c +32 -3
  29. data/ext/libxml/ruby_xml_sax_parser.c +106 -364
  30. data/ext/libxml/ruby_xml_sax_parser.h +1 -37
  31. data/ext/libxml/ruby_xml_schema.c +174 -145
  32. data/ext/libxml/ruby_xml_xinclude.c +9 -5
  33. data/ext/libxml/ruby_xml_xpath.c +25 -6
  34. data/ext/libxml/ruby_xml_xpath.h +1 -2
  35. data/ext/libxml/ruby_xml_xpath_context.c +17 -19
  36. data/ext/libxml/ruby_xml_xpath_object.c +60 -56
  37. data/ext/libxml/ruby_xml_xpointer.c +11 -5
  38. data/ext/libxml/sax_parser_callbacks.inc +42 -37
  39. data/ext/libxml/version.h +3 -3
  40. data/ext/mingw/Rakefile +20 -27
  41. data/ext/mingw/build.rake +41 -0
  42. data/ext/vc/libxml_ruby.vcproj +23 -15
  43. data/lib/libxml.rb +8 -2
  44. data/lib/libxml/document.rb +16 -4
  45. data/lib/libxml/error.rb +84 -0
  46. data/lib/libxml/hpricot.rb +76 -0
  47. data/lib/libxml/html_parser.rb +61 -0
  48. data/lib/libxml/node.rb +36 -25
  49. data/lib/libxml/parser.rb +312 -33
  50. data/lib/libxml/parser_context.rb +17 -0
  51. data/lib/libxml/properties.rb +15 -2
  52. data/lib/libxml/reader.rb +15 -0
  53. data/lib/libxml/sax_callbacks.rb +179 -0
  54. data/lib/libxml/sax_parser.rb +42 -0
  55. data/lib/libxml/tree.rb +1 -2
  56. data/lib/libxml/xpath_object.rb +12 -0
  57. data/test/model/atom.xml +4 -0
  58. data/test/tc_attributes.rb +43 -19
  59. data/test/tc_document.rb +1 -1
  60. data/test/tc_document_write.rb +15 -8
  61. data/test/tc_dtd.rb +36 -20
  62. data/test/tc_encoding.rb +13 -0
  63. data/test/tc_error.rb +136 -0
  64. data/test/tc_node.rb +2 -3
  65. data/test/tc_node_copy.rb +1 -1
  66. data/test/tc_node_edit.rb +6 -0
  67. data/test/tc_ns.rb +18 -0
  68. data/test/tc_parser.rb +113 -228
  69. data/test/tc_parser_context.rb +1 -2
  70. data/test/tc_reader.rb +24 -14
  71. data/test/tc_relaxng.rb +18 -6
  72. data/test/tc_sax_parser.rb +48 -13
  73. data/test/tc_schema.rb +20 -8
  74. data/test/tc_well_formed.rb +2 -1
  75. data/test/tc_xml.rb +212 -0
  76. data/test/tc_xpath.rb +60 -46
  77. data/test/tc_xpointer.rb +7 -11
  78. data/test/test_suite.rb +4 -3
  79. metadata +26 -109
  80. data/doc/rdoc/classes/LibXML.html +0 -241
  81. data/doc/rdoc/classes/LibXML/XML.html +0 -185
  82. data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
  83. data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
  84. data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
  85. data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
  86. data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
  87. data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
  88. data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
  89. data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
  90. data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
  91. data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
  92. data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
  93. data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
  94. data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
  95. data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
  96. data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
  97. data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
  98. data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
  99. data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
  100. data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
  101. data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
  102. data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
  103. data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
  104. data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
  105. data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
  106. data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
  107. data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
  108. data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
  109. data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
  110. data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
  111. data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
  112. data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
  113. data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
  114. data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
  115. data/doc/rdoc/classes/singleton.html +0 -114
  116. data/doc/rdoc/created.rid +0 -1
  117. data/doc/rdoc/files/CHANGES.html +0 -442
  118. data/doc/rdoc/files/LICENSE.html +0 -133
  119. data/doc/rdoc/files/README.html +0 -388
  120. data/doc/rdoc/files/VERSION.html +0 -107
  121. data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
  122. data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
  123. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
  124. data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
  125. data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
  126. data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
  127. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
  128. data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
  129. data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
  130. data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
  131. data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
  132. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
  133. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
  134. data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
  135. data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
  136. data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
  137. data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
  138. data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
  139. data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
  140. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
  141. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
  142. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
  143. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
  144. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
  145. data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
  146. data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
  147. data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
  148. data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
  149. data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
  150. data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
  151. data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
  152. data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
  153. data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
  154. data/doc/rdoc/files/lib/libxml_rb.html +0 -124
  155. data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
  156. data/doc/rdoc/files/lib/xml_rb.html +0 -134
  157. data/doc/rdoc/fr_class_index.html +0 -62
  158. data/doc/rdoc/fr_file_index.html +0 -66
  159. data/doc/rdoc/fr_method_index.html +0 -392
  160. data/doc/rdoc/index.html +0 -24
  161. data/doc/rdoc/rdoc-style.css +0 -208
  162. data/ext/libxml/ruby_xml_node_set.c +0 -172
  163. data/ext/libxml/ruby_xml_node_set.h +0 -20
  164. data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
  165. data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
  166. data/lib/libxml/node_set.rb +0 -27
  167. data/test/tc_node_set.rb +0 -24
  168. data/test/tc_node_set2.rb +0 -37
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_sax_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
1
+ /* $Id: ruby_xml_sax_parser.h 544 2008-11-16 09:50:27Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -6,51 +6,15 @@
6
6
  #define __RUBY_XML_SAX_PARSER__
7
7
 
8
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
9
 
43
10
  typedef struct ruby_xml_sax_parser {
44
11
  xmlParserCtxtPtr xpc;
45
12
  xmlSAXHandlerPtr xsh;
46
- //ruby_xml_sax_parser_callbacks *cbp;
47
13
  VALUE callbackHandler;
48
14
  VALUE filename;
49
15
  VALUE str;
50
16
  } ruby_xml_sax_parser;
51
17
 
52
- void ruby_xml_sax_parser_free(ruby_xml_sax_parser *rxsp);
53
18
  void ruby_init_xml_sax_parser(void);
54
- VALUE ruby_xml_sax_parser_new(VALUE class);
55
19
 
56
20
  #endif
@@ -1,145 +1,174 @@
1
- #include "ruby_libxml.h"
2
- #include "ruby_xml_schema.h"
3
-
4
- VALUE cXMLSchema;
5
-
6
- // Rdoc needs to know
7
- #ifdef RDOC_NEVER_DEFINED
8
- mLibXML = rb_define_module("LibXML");
9
- mXML = rb_define_module_under(mLibXML, "XML");
10
- #endif
11
-
12
- static void
13
- ruby_xml_schema_mark(ruby_xml_schema *rxschema) {
14
- return;
15
- }
16
-
17
- void
18
- ruby_xml_schema_free(ruby_xml_schema *rxschema) {
19
- if (rxschema->schema != NULL) {
20
- xmlSchemaFree(rxschema->schema);
21
- rxschema->schema = NULL;
22
- }
23
-
24
- ruby_xfree(rxschema);
25
- }
26
-
27
- /*
28
- * call-seq:
29
- * XML::Schema.new(schema_uri) -> schema
30
- *
31
- * Create a new schema from the specified URI.
32
- */
33
- VALUE
34
- ruby_xml_schema_init_from_uri(VALUE class, VALUE uri) {
35
- xmlSchemaParserCtxtPtr parser;
36
- ruby_xml_schema *schema;
37
-
38
- Check_Type(uri, T_STRING);
39
-
40
- parser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
41
- schema = ALLOC(ruby_xml_schema);
42
- schema->schema = xmlSchemaParse(parser);
43
- xmlSchemaFreeParserCtxt(parser);
44
-
45
- return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
46
- }
47
-
48
- /*
49
- * call-seq:
50
- * XML::Schema.document(document) -> schema
51
- *
52
- * Create a new schema from the specified document.
53
- */
54
- VALUE
55
- ruby_xml_schema_init_from_document(VALUE class, VALUE document) {
56
- ruby_xml_document_t *rdoc;
57
- ruby_xml_schema *schema;
58
- xmlSchemaParserCtxtPtr parser;
59
-
60
- Data_Get_Struct(document, ruby_xml_document_t, rdoc);
61
-
62
- parser = xmlSchemaNewDocParserCtxt(rdoc->doc);
63
- schema = ALLOC(ruby_xml_schema);
64
- schema->schema = xmlSchemaParse(parser);
65
- xmlSchemaFreeParserCtxt(parser);
66
-
67
- return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
68
- }
69
-
70
- /*
71
- * call-seq:
72
- * XML::Schema.string("schema_data") -> "value"
73
- *
74
- * Create a new schema using the specified string.
75
- */
76
- VALUE
77
- ruby_xml_schema_init_from_string(VALUE self, VALUE schema_str) {
78
- xmlSchemaParserCtxtPtr parser;
79
- ruby_xml_schema *rxschema;
80
-
81
- Check_Type(schema_str, T_STRING);
82
-
83
- parser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(StringValuePtr(schema_str)));
84
- rxschema = ALLOC(ruby_xml_schema);
85
- rxschema->schema = xmlSchemaParse(parser);
86
- xmlSchemaFreeParserCtxt(parser);
87
-
88
- return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, rxschema);
89
- }
90
-
91
- /* TODO what is this patch doing here?
92
-
93
- xmlSchemaParserCtxtPtr parser;
94
- xmlSchemaPtr sptr;
95
- xmlSchemaValidCtxtPtr vptr;
96
- + int is_invalid;
97
-
98
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) {
99
- return;
100
- @@ -598,26 +598,24 @@
101
- convert_to_string_ex(&source);
102
- parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
103
- sptr = xmlSchemaParse(parser);
104
- break;
105
- case SCHEMA_BLOB:
106
- convert_to_string_ex(&source);
107
- parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source));
108
- sptr = xmlSchemaParse(parser);
109
- break;
110
- }
111
-
112
- vptr = xmlSchemaNewValidCtxt(sptr);
113
- + is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
114
- xmlSchemaFree(sptr);
115
- xmlSchemaFreeValidCtxt(vptr);
116
- xmlSchemaFreeParserCtxt(parser);
117
-
118
- - if (is_valid) {
119
- - RETURN_TRUE;
120
- - } else {
121
- + if (is_invalid) {
122
- RETURN_FALSE;
123
- + } else {
124
- + RETURN_TRUE;
125
- }
126
- }
127
- }}}
128
- @@ -695,7 +693,7 @@
129
- {
130
- if (!strcmp(method, "xsearch")) {
131
- simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
132
- -#ifdef xmlSchemaParserCtxtPtr
133
- +#ifdef LIBXML_SCHEMAS_ENABLED
134
- } else if (!strcmp(method, "validate_schema_file")) {
135
- simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE);
136
- } else if (!strcmp(method, "validate_schema_buffer")) {
137
- */
138
-
139
- void ruby_init_xml_schema(void) {
140
- cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
141
- rb_define_singleton_method(cXMLSchema, "new", ruby_xml_schema_init_from_uri, 1);
142
- rb_define_singleton_method(cXMLSchema, "from_string", ruby_xml_schema_init_from_string, 1);
143
- rb_define_singleton_method(cXMLSchema, "document", ruby_xml_schema_init_from_document, 1);
144
- }
145
-
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
+ // Rdoc needs to know
36
+ #ifdef RDOC_NEVER_DEFINED
37
+ mLibXML = rb_define_module("LibXML");
38
+ mXML = rb_define_module_under(mLibXML, "XML");
39
+ #endif
40
+
41
+ static void
42
+ ruby_xml_schema_mark(ruby_xml_schema *rxschema) {
43
+ return;
44
+ }
45
+
46
+ void
47
+ ruby_xml_schema_free(ruby_xml_schema *rxschema) {
48
+ if (rxschema->schema != NULL) {
49
+ xmlSchemaFree(rxschema->schema);
50
+ rxschema->schema = NULL;
51
+ }
52
+
53
+ ruby_xfree(rxschema);
54
+ }
55
+
56
+ /*
57
+ * call-seq:
58
+ * XML::Schema.new(schema_uri) -> schema
59
+ *
60
+ * Create a new schema from the specified URI.
61
+ */
62
+ VALUE
63
+ ruby_xml_schema_init_from_uri(VALUE class, VALUE uri) {
64
+ xmlSchemaParserCtxtPtr parser;
65
+ ruby_xml_schema *schema;
66
+
67
+ Check_Type(uri, T_STRING);
68
+
69
+ parser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
70
+ schema = ALLOC(ruby_xml_schema);
71
+ schema->schema = xmlSchemaParse(parser);
72
+ xmlSchemaFreeParserCtxt(parser);
73
+
74
+ return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
75
+ }
76
+
77
+ /*
78
+ * call-seq:
79
+ * XML::Schema.document(document) -> schema
80
+ *
81
+ * Create a new schema from the specified document.
82
+ */
83
+ VALUE
84
+ ruby_xml_schema_init_from_document(VALUE class, VALUE document) {
85
+ xmlDocPtr xdoc;
86
+ ruby_xml_schema *schema;
87
+ xmlSchemaParserCtxtPtr parser;
88
+
89
+ Data_Get_Struct(document, xmlDoc, xdoc);
90
+
91
+ parser = xmlSchemaNewDocParserCtxt(xdoc);
92
+ schema = ALLOC(ruby_xml_schema);
93
+ schema->schema = xmlSchemaParse(parser);
94
+ xmlSchemaFreeParserCtxt(parser);
95
+
96
+ return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, schema);
97
+ }
98
+
99
+ /*
100
+ * call-seq:
101
+ * XML::Schema.string("schema_data") -> "value"
102
+ *
103
+ * Create a new schema using the specified string.
104
+ */
105
+ VALUE
106
+ ruby_xml_schema_init_from_string(VALUE self, VALUE schema_str) {
107
+ xmlSchemaParserCtxtPtr parser;
108
+ ruby_xml_schema *rxschema;
109
+
110
+ Check_Type(schema_str, T_STRING);
111
+
112
+ parser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(StringValuePtr(schema_str)));
113
+ rxschema = ALLOC(ruby_xml_schema);
114
+ rxschema->schema = xmlSchemaParse(parser);
115
+ xmlSchemaFreeParserCtxt(parser);
116
+
117
+ return Data_Wrap_Struct(cXMLSchema, ruby_xml_schema_mark, ruby_xml_schema_free, rxschema);
118
+ }
119
+
120
+ /* TODO what is this patch doing here?
121
+
122
+ xmlSchemaParserCtxtPtr parser;
123
+ xmlSchemaPtr sptr;
124
+ xmlSchemaValidCtxtPtr vptr;
125
+ + int is_invalid;
126
+
127
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) {
128
+ return;
129
+ @@ -598,26 +598,24 @@
130
+ convert_to_string_ex(&source);
131
+ parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
132
+ sptr = xmlSchemaParse(parser);
133
+ break;
134
+ case SCHEMA_BLOB:
135
+ convert_to_string_ex(&source);
136
+ parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source));
137
+ sptr = xmlSchemaParse(parser);
138
+ break;
139
+ }
140
+
141
+ vptr = xmlSchemaNewValidCtxt(sptr);
142
+ + is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
143
+ xmlSchemaFree(sptr);
144
+ xmlSchemaFreeValidCtxt(vptr);
145
+ xmlSchemaFreeParserCtxt(parser);
146
+
147
+ - if (is_valid) {
148
+ - RETURN_TRUE;
149
+ - } else {
150
+ + if (is_invalid) {
151
+ RETURN_FALSE;
152
+ + } else {
153
+ + RETURN_TRUE;
154
+ }
155
+ }
156
+ }}}
157
+ @@ -695,7 +693,7 @@
158
+ {
159
+ if (!strcmp(method, "xsearch")) {
160
+ simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
161
+ -#ifdef xmlSchemaParserCtxtPtr
162
+ +#ifdef LIBXML_SCHEMAS_ENABLED
163
+ } else if (!strcmp(method, "validate_schema_file")) {
164
+ simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE);
165
+ } else if (!strcmp(method, "validate_schema_buffer")) {
166
+ */
167
+
168
+ void ruby_init_xml_schema(void) {
169
+ cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
170
+ rb_define_singleton_method(cXMLSchema, "new", ruby_xml_schema_init_from_uri, 1);
171
+ rb_define_singleton_method(cXMLSchema, "from_string", ruby_xml_schema_init_from_string, 1);
172
+ rb_define_singleton_method(cXMLSchema, "document", ruby_xml_schema_init_from_document, 1);
173
+ }
174
+
@@ -1,12 +1,17 @@
1
- /* $Id: ruby_xml_xinclude.c 461 2008-07-15 21:35:56Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
1
+ /* $Id: ruby_xml_xinclude.c 566 2008-11-18 06:53:36Z cfis $ */
4
2
 
5
3
  #include "ruby_libxml.h"
6
4
  #include "ruby_xml_xinclude.h"
7
5
 
8
6
  VALUE cXMLXInclude;
9
- VALUE eXMLXIncludeError;
7
+
8
+ /*
9
+ * Document-class: LibXML::XML::XInclude
10
+ *
11
+ * The ruby bindings do not currently expose libxml's
12
+ * XInclude fuctionality.
13
+ */
14
+
10
15
 
11
16
  // Rdoc needs to know
12
17
  #ifdef RDOC_NEVER_DEFINED
@@ -17,5 +22,4 @@ VALUE eXMLXIncludeError;
17
22
  void
18
23
  ruby_init_xml_xinclude(void) {
19
24
  cXMLXInclude = rb_define_class_under(mXML, "XInclude", rb_cObject);
20
- eXMLXIncludeError = rb_define_class_under(cXMLXInclude, "Error", rb_eRuntimeError);
21
25
  }
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath.c 461 2008-07-15 21:35:56Z cfis $ */
1
+ /* $Id: ruby_xml_xpath.c 566 2008-11-18 06:53:36Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -25,10 +25,31 @@
25
25
  * 'xi' => 'http://www.w3.org/2001/XInclude')
26
26
  *
27
27
  *
28
- * === Working With Namespaces
28
+ * === Working With Default Namespaces
29
29
  *
30
30
  * Finding namespaced elements and attributes can be tricky.
31
- * Lets work through some examples using the following xml document:
31
+ * Lets work through an example of a document with a default
32
+ * namespace:
33
+ *
34
+ * <?xml version="1.0" encoding="utf-8"?>
35
+ * <feed xmlns="http://www.w3.org/2005/Atom">
36
+ * <title type="text">Phil Bogle's Contacts</title>
37
+ * </feed>
38
+ *
39
+ * To find nodes you must define the atom namespace for
40
+ * libxml. One way to do this is:
41
+ *
42
+ * node = doc.find('atom:title', 'atom:http://www.w3.org/2005/Atom')
43
+ *
44
+ * Alternatively, you can register the default namespace like this:
45
+ *
46
+ * doc.root.register_default_namespace('atom')
47
+ * node = doc.find('atom:title')
48
+ *
49
+ * === More Complex Namespace Examples
50
+ *
51
+ * Lets work through some more complex examples using the
52
+ * following xml document:
32
53
  *
33
54
  * <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
34
55
  * <soap:Body>
@@ -58,10 +79,9 @@
58
79
  * # xpath expression.
59
80
  * doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
60
81
  ['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
61
- */
82
+ */
62
83
 
63
84
  VALUE mXPath;
64
- VALUE eXMLXPathInvalidPath;
65
85
 
66
86
  // Rdoc needs to know
67
87
  #ifdef RDOC_NEVER_DEFINED
@@ -72,7 +92,6 @@ VALUE eXMLXPathInvalidPath;
72
92
  void
73
93
  ruby_init_xml_xpath(void) {
74
94
  mXPath = rb_define_module_under(mXML, "XPath");
75
- eXMLXPathInvalidPath = rb_define_class_under(mXPath, "InvalidPath", eXMLError);
76
95
 
77
96
  rb_define_const(mXPath, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
78
97
  rb_define_const(mXPath, "NODESET", INT2NUM(XPATH_NODESET));