libxml-ruby 0.6.0-x86-mswin32-60

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.
Files changed (127) hide show
  1. data/CHANGES +122 -0
  2. data/LICENSE +23 -0
  3. data/README +144 -0
  4. data/ext/libxml/cbg.c +76 -0
  5. data/ext/libxml/extconf.rb +308 -0
  6. data/ext/libxml/libxml.c +62 -0
  7. data/ext/libxml/ruby_libxml.h +93 -0
  8. data/ext/libxml/ruby_xml_attr.c +405 -0
  9. data/ext/libxml/ruby_xml_attr.h +19 -0
  10. data/ext/libxml/ruby_xml_document.c +1111 -0
  11. data/ext/libxml/ruby_xml_document.h +27 -0
  12. data/ext/libxml/ruby_xml_dtd.c +168 -0
  13. data/ext/libxml/ruby_xml_dtd.h +17 -0
  14. data/ext/libxml/ruby_xml_html_parser.c +449 -0
  15. data/ext/libxml/ruby_xml_html_parser.h +29 -0
  16. data/ext/libxml/ruby_xml_input_cbg.c +158 -0
  17. data/ext/libxml/ruby_xml_input_cbg.h +20 -0
  18. data/ext/libxml/ruby_xml_node.c +2410 -0
  19. data/ext/libxml/ruby_xml_node.h +27 -0
  20. data/ext/libxml/ruby_xml_node_set.c +170 -0
  21. data/ext/libxml/ruby_xml_node_set.h +20 -0
  22. data/ext/libxml/ruby_xml_ns.c +153 -0
  23. data/ext/libxml/ruby_xml_ns.h +21 -0
  24. data/ext/libxml/ruby_xml_parser.c +1425 -0
  25. data/ext/libxml/ruby_xml_parser.h +31 -0
  26. data/ext/libxml/ruby_xml_parser_context.c +750 -0
  27. data/ext/libxml/ruby_xml_parser_context.h +22 -0
  28. data/ext/libxml/ruby_xml_reader.c +900 -0
  29. data/ext/libxml/ruby_xml_reader.h +14 -0
  30. data/ext/libxml/ruby_xml_sax_parser.c +485 -0
  31. data/ext/libxml/ruby_xml_sax_parser.h +56 -0
  32. data/ext/libxml/ruby_xml_schema.c +146 -0
  33. data/ext/libxml/ruby_xml_schema.h +16 -0
  34. data/ext/libxml/ruby_xml_state.c +113 -0
  35. data/ext/libxml/ruby_xml_state.h +12 -0
  36. data/ext/libxml/ruby_xml_tree.c +43 -0
  37. data/ext/libxml/ruby_xml_tree.h +12 -0
  38. data/ext/libxml/ruby_xml_xinclude.c +20 -0
  39. data/ext/libxml/ruby_xml_xinclude.h +13 -0
  40. data/ext/libxml/ruby_xml_xpath.c +243 -0
  41. data/ext/libxml/ruby_xml_xpath.h +23 -0
  42. data/ext/libxml/ruby_xml_xpath_context.c +118 -0
  43. data/ext/libxml/ruby_xml_xpath_context.h +20 -0
  44. data/ext/libxml/ruby_xml_xpath_object.c +293 -0
  45. data/ext/libxml/ruby_xml_xpath_object.h +28 -0
  46. data/ext/libxml/ruby_xml_xpointer.c +100 -0
  47. data/ext/libxml/ruby_xml_xpointer.h +27 -0
  48. data/ext/libxml/ruby_xml_xpointer_context.c +21 -0
  49. data/ext/libxml/ruby_xml_xpointer_context.h +18 -0
  50. data/ext/libxml/sax_parser_callbacks.inc +213 -0
  51. data/ext/libxml/version.h +9 -0
  52. data/lib/libxml.rb +125 -0
  53. data/lib/libxml_ruby.so +0 -0
  54. data/lib/xml/libxml.rb +5 -0
  55. data/mingw/libiconv-2.dll +0 -0
  56. data/mingw/libxml2-2.dll +0 -0
  57. data/mingw/libxml_ruby.so +0 -0
  58. data/mingw/mingw.rake +36 -0
  59. data/test/dtd-test.rb +24 -0
  60. data/test/etc_doc_to_s.rb +19 -0
  61. data/test/ets_copy_bug.rb +21 -0
  62. data/test/ets_copy_bug2.rb +32 -0
  63. data/test/ets_copy_bug3.rb +38 -0
  64. data/test/ets_doc_file.rb +15 -0
  65. data/test/ets_doc_to_s.rb +21 -0
  66. data/test/ets_gpx.rb +26 -0
  67. data/test/ets_node_gc.rb +21 -0
  68. data/test/ets_test.xml +2 -0
  69. data/test/ets_tsr.rb +9 -0
  70. data/test/gc.log +0 -0
  71. data/test/merge_bug.rb +55 -0
  72. data/test/schema-test.rb +74 -0
  73. data/test/tc_well_formed.rb +11 -0
  74. data/test/tc_xml_document.rb +52 -0
  75. data/test/tc_xml_document_write.rb +24 -0
  76. data/test/tc_xml_document_write2.rb +54 -0
  77. data/test/tc_xml_document_write3.rb +96 -0
  78. data/test/tc_xml_html_parser.rb +63 -0
  79. data/test/tc_xml_node.rb +59 -0
  80. data/test/tc_xml_node2.rb +25 -0
  81. data/test/tc_xml_node3.rb +27 -0
  82. data/test/tc_xml_node4.rb +86 -0
  83. data/test/tc_xml_node5.rb +52 -0
  84. data/test/tc_xml_node6.rb +27 -0
  85. data/test/tc_xml_node7.rb +35 -0
  86. data/test/tc_xml_node8.rb +32 -0
  87. data/test/tc_xml_node9.rb +32 -0
  88. data/test/tc_xml_node_copy.rb +40 -0
  89. data/test/tc_xml_node_set.rb +24 -0
  90. data/test/tc_xml_node_set2.rb +37 -0
  91. data/test/tc_xml_node_text.rb +17 -0
  92. data/test/tc_xml_node_xlink.rb +28 -0
  93. data/test/tc_xml_parser.rb +190 -0
  94. data/test/tc_xml_parser2.rb +16 -0
  95. data/test/tc_xml_parser3.rb +23 -0
  96. data/test/tc_xml_parser4.rb +33 -0
  97. data/test/tc_xml_parser5.rb +27 -0
  98. data/test/tc_xml_parser6.rb +23 -0
  99. data/test/tc_xml_parser7.rb +28 -0
  100. data/test/tc_xml_parser8.rb +32 -0
  101. data/test/tc_xml_parser9.rb +11 -0
  102. data/test/tc_xml_parser_context.rb +88 -0
  103. data/test/tc_xml_reader.rb +112 -0
  104. data/test/tc_xml_sax_parser.rb +104 -0
  105. data/test/tc_xml_sax_parser2.rb +51 -0
  106. data/test/tc_xml_xinclude.rb +30 -0
  107. data/test/tc_xml_xpath.rb +38 -0
  108. data/test/tc_xml_xpath2.rb +14 -0
  109. data/test/tc_xml_xpointer.rb +78 -0
  110. data/vc/libxml.sln +20 -0
  111. data/vc/libxml.vcproj +389 -0
  112. data/work/Rakefile +247 -0
  113. data/work/task/make +26 -0
  114. data/work/task/memory +37 -0
  115. data/work/task/rdoc +39 -0
  116. data/work/task/setup +1616 -0
  117. data/work/task/test +29 -0
  118. data/work/test/ets_runner.rb +33 -0
  119. data/work/test/libxml_test.rb +3 -0
  120. data/work/test/runner.rb +0 -0
  121. data/work/test/runner_ets.rb +33 -0
  122. data/work/vc/debug/libxml.exp +0 -0
  123. data/work/vc/debug/libxml.ilk +0 -0
  124. data/work/vc/debug/libxml.lib +0 -0
  125. data/work/vc/debug/libxml.pdb +0 -0
  126. data/work/vc/debug/libxml.so +0 -0
  127. metadata +224 -0
@@ -0,0 +1,28 @@
1
+ /* $Id $ */
2
+
3
+ #ifndef __RUBY_XML_XPATH_OBJECT__
4
+ #define __RUBY_XML_XPATH_OBJECT__
5
+
6
+ extern VALUE cXMLXPathObject;
7
+
8
+ typedef struct ruby_xml_xpath_object_s {
9
+ xmlXPathObjectPtr xpop;
10
+ } ruby_xml_xpath_object;
11
+
12
+ VALUE ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop);
13
+ VALUE ruby_xml_xpath_object_to_a(VALUE self);
14
+ VALUE ruby_xml_xpath_object_first(VALUE self);
15
+ VALUE ruby_xml_xpath_object_set(VALUE self);
16
+ VALUE ruby_xml_xpath_object_empty_q(VALUE self);
17
+ VALUE ruby_xml_xpath_object_each(VALUE self);
18
+ VALUE ruby_xml_xpath_object_first(VALUE self);
19
+ VALUE ruby_xml_xpath_object_length(VALUE self);
20
+ VALUE ruby_xml_xpath_object_set_type(VALUE self);
21
+ VALUE ruby_xml_xpath_object_string(VALUE self);
22
+
23
+ void ruby_xml_xpath_object_mark(xmlXPathObjectPtr xpop);
24
+ void ruby_xml_xpath_object_free(xmlXPathObjectPtr xpop);
25
+
26
+ void ruby_init_xml_xpath_object(void);
27
+
28
+ #endif
@@ -0,0 +1,100 @@
1
+ /* $Id: ruby_xml_xpointer.c 300 2008-07-01 19:14:15Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_xpointer.h"
7
+
8
+ VALUE cXMLXPointer;
9
+ VALUE eXMLXPointerInvalidExpression;
10
+
11
+ VALUE
12
+ ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
13
+ #ifdef LIBXML_XPTR_ENABLED
14
+ ruby_xml_node *node;
15
+ xmlXPathContextPtr ctxt;
16
+ VALUE rxptr_xpth_ctxt, rxxp;
17
+ xmlXPathObjectPtr xpath;
18
+
19
+ Check_Type(xptr_str, T_STRING);
20
+ if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
21
+ rb_raise(rb_eTypeError, "require an XML::Node object");
22
+
23
+ Data_Get_Struct(rnode, ruby_xml_node, node);
24
+
25
+ rxptr_xpth_ctxt =
26
+ ruby_xml_xpath_context_wrap(ctxt=xmlXPtrNewContext(node->node->doc, node->node, NULL));
27
+
28
+ if (NIL_P(rxptr_xpth_ctxt))
29
+ return(Qnil);
30
+
31
+ xpath = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), ctxt);
32
+ if (xpath == NULL)
33
+ rb_raise(eXMLXPointerInvalidExpression, "invalid xpointer expression");
34
+
35
+ rxxp = ruby_xml_xpath_object_wrap(xpath);
36
+ return(rxxp);
37
+ #else
38
+ rb_warn("libxml was compiled without XPointer support");
39
+ return(Qfalse);
40
+ #endif
41
+ }
42
+
43
+
44
+ VALUE
45
+ ruby_xml_xpointer_point2(VALUE node, VALUE xptr_str) {
46
+ return(ruby_xml_xpointer_point(cXMLXPointer, node, xptr_str));
47
+ }
48
+
49
+
50
+ /*
51
+ * call-seq:
52
+ * XML::XPointer.range(start_node, end_node) => xpath
53
+ *
54
+ * Create an xpath representing the range between the supplied
55
+ * start and end node.
56
+ */
57
+ VALUE
58
+ ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
59
+ #ifdef LIBXML_XPTR_ENABLED
60
+ ruby_xml_node *start, *end;
61
+ VALUE rxxp;
62
+ xmlXPathObjectPtr xpath;
63
+
64
+ if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
65
+ rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
66
+ if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
67
+ rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
68
+
69
+ Data_Get_Struct(rstart, ruby_xml_node, start);
70
+ if (start->node == NULL)
71
+ return(Qnil);
72
+
73
+ Data_Get_Struct(rend, ruby_xml_node, end);
74
+ if (end->node == NULL)
75
+ return(Qnil);
76
+
77
+ xpath = xmlXPtrNewRangeNodes(start->node, end->node);
78
+ if (xpath == NULL)
79
+ rb_fatal("You shouldn't be able to have this happen");
80
+
81
+ rxxp = ruby_xml_xpath_object_wrap(xpath);
82
+ return(rxxp);
83
+ #else
84
+ rb_warn("libxml was compiled without XPointer support");
85
+ return(Qfalse);
86
+ #endif
87
+ }
88
+
89
+ // Rdoc needs to know
90
+ #ifdef RDOC_NEVER_DEFINED
91
+ mXML = rb_define_module("XML");
92
+ #endif
93
+
94
+ void
95
+ ruby_init_xml_xpointer(void) {
96
+ cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
97
+ eXMLXPointerInvalidExpression = rb_define_class_under(cXMLXPointer, "InvalidExpression", eXMLError);
98
+
99
+ rb_define_singleton_method(cXMLXPointer, "range", ruby_xml_xpointer_range, 2);
100
+ }
@@ -0,0 +1,27 @@
1
+ /* $Id: ruby_xml_xpointer.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_XPOINTER__
6
+ #define __RUBY_XML_XPOINTER__
7
+
8
+ extern VALUE cXMLXPointer;
9
+ extern VALUE eXMLXPointerInvalidExpression;
10
+
11
+ typedef struct ruby_xml_xpointer {
12
+ VALUE xd;
13
+ VALUE ctxt;
14
+ /*
15
+ * This needs to go into a xpointer data struct:
16
+ *
17
+ * xmlLocationSetPtr xptr;
18
+ *
19
+ * I also need an xpointer data struct type.
20
+ */
21
+ } ruby_xml_xpointer;
22
+
23
+ VALUE ruby_xml_xpointer_point(VALUE class, VALUE node, VALUE xptr_string);
24
+ VALUE ruby_xml_xpointer_point2(VALUE node, VALUE xptr_string);
25
+ void ruby_init_xml_xpointer(void);
26
+
27
+ #endif
@@ -0,0 +1,21 @@
1
+ /* $Id: ruby_xml_xpointer_context.c 300 2008-07-01 19:14:15Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_xpointer_context.h"
7
+
8
+ VALUE cXMLXPointerContext;
9
+ VALUE eXMLXPointerContextInvalidPath;
10
+
11
+ // Rdoc needs to know
12
+ #ifdef RDOC_NEVER_DEFINED
13
+ mXML = rb_define_module("XML");
14
+ cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
15
+ #endif
16
+
17
+ void
18
+ ruby_init_xml_xpointer_context(void) {
19
+ cXMLXPointerContext = rb_define_class_under(cXMLXPointer, "Context", cXMLXPathContext);
20
+ eXMLXPointerContextInvalidPath = rb_define_class_under(cXMLXPointerContext, "InvalidPath", eXMLError);
21
+ }
@@ -0,0 +1,18 @@
1
+ /* $Id: ruby_xml_xpointer_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_XPOINTER_CONTEXT__
6
+ #define __RUBY_XML_XPOINTER_CONTEXT__
7
+
8
+ extern VALUE cXMLXPointerContext;
9
+ extern VALUE eXMLXPointerContextInvalidPath;
10
+
11
+ typedef struct ruby_xml_xpointer_context {
12
+ VALUE xd;
13
+ xmlXPathContextPtr ctxt;
14
+ } ruby_xml_xpointer_context;
15
+
16
+ void ruby_init_xml_xpointer_context(void);
17
+
18
+ #endif
@@ -0,0 +1,213 @@
1
+ /* $Id: sax_parser_callbacks.inc 120 2006-11-26 12:57:56Z roscopeco $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ /*
6
+ * SAX CALLBACK HANDLERS
7
+ */
8
+ static void internal_subset_func(ruby_xml_sax_parser *cbp,
9
+ const char *name,
10
+ const char *extid,
11
+ const char *sysid) {
12
+ VALUE handler = cbp->callbackHandler;
13
+
14
+ if (handler && handler != Qnil) {
15
+ rb_funcall(handler, cbidOnInternalSubset, 3, rb_str_new2(name),
16
+ rb_str_new2(extid), rb_str_new2(sysid));
17
+ }
18
+ }
19
+
20
+ static void is_standalone_func(ruby_xml_sax_parser *cbp) {
21
+ VALUE handler = cbp->callbackHandler;
22
+
23
+ if (handler && handler != Qnil) {
24
+ rb_funcall(handler,cbidOnIsStandalone,0);
25
+ }
26
+ }
27
+
28
+ static void has_internal_subset_func(ruby_xml_sax_parser *cbp) {
29
+ VALUE handler = cbp->callbackHandler;
30
+
31
+ if (handler && handler != Qnil) {
32
+ rb_funcall(handler,cbidOnHasInternalSubset,0);
33
+ }
34
+ }
35
+
36
+ static void has_external_subset_func(ruby_xml_sax_parser *cbp) {
37
+ VALUE handler = cbp->callbackHandler;
38
+
39
+ if (handler && handler != Qnil) {
40
+ rb_funcall(handler,cbidOnHasExternalSubset,0);
41
+ }
42
+ }
43
+
44
+ static void start_document_func(ruby_xml_sax_parser *cbp) {
45
+ VALUE handler = cbp->callbackHandler;
46
+
47
+ if (handler && handler != Qnil) {
48
+ rb_funcall(handler,cbidOnStartDocument,0);
49
+ }
50
+ }
51
+
52
+ static void end_document_func(ruby_xml_sax_parser *cbp) {
53
+ VALUE handler = cbp->callbackHandler;
54
+
55
+ if (handler && handler != Qnil) {
56
+ rb_funcall(handler,cbidOnEndDocument,0);
57
+ }
58
+ }
59
+
60
+ static void start_element_func(ruby_xml_sax_parser *cbp,
61
+ const char *name, const char **attrs) {
62
+ VALUE handler = cbp->callbackHandler;
63
+ VALUE ahsh = rb_hash_new();
64
+ const char *attr, *value;
65
+
66
+ if (attrs) {
67
+ while ((attr = *(attrs++))) {
68
+ value = *(attrs++);
69
+ rb_hash_aset(ahsh, rb_str_new2(attr), rb_str_new2(value));
70
+ }
71
+ }
72
+
73
+ if (handler && handler != Qnil) {
74
+ rb_funcall(handler,cbidOnStartElement,2,rb_str_new2(name),ahsh);
75
+ }
76
+ }
77
+
78
+ static void end_element_func(ruby_xml_sax_parser *cbp,
79
+ const char *name) {
80
+ VALUE handler = cbp->callbackHandler;
81
+
82
+ if (handler && handler != Qnil) {
83
+ rb_funcall(handler,cbidOnEndElement,1,rb_str_new2(name));
84
+ }
85
+ }
86
+
87
+ static void reference_func(ruby_xml_sax_parser *cbp,
88
+ const char *name) {
89
+ VALUE handler = cbp->callbackHandler;
90
+
91
+ if (handler && handler != Qnil) {
92
+ rb_funcall(handler,cbidOnReference,1,rb_str_new2(name));
93
+ }
94
+ }
95
+
96
+ static void characters_func(ruby_xml_sax_parser *cbp,
97
+ const char *chars, int len) {
98
+ VALUE handler = cbp->callbackHandler;
99
+
100
+ if (handler && handler != Qnil) {
101
+ rb_funcall(handler,cbidOnCharacters,1,rb_str_new(chars, len));
102
+ }
103
+ }
104
+
105
+ static void processing_instruction_func(ruby_xml_sax_parser *cbp,
106
+ const char *target, const char *data) {
107
+ VALUE handler = cbp->callbackHandler;
108
+
109
+ if (handler && handler != Qnil) {
110
+ rb_funcall(handler, cbidOnProcessingInstruction, 2,
111
+ rb_str_new2(target),rb_str_new2(data));
112
+ }
113
+ }
114
+
115
+ static void comment_func(ruby_xml_sax_parser *cbp,
116
+ const char *msg) {
117
+ VALUE handler = cbp->callbackHandler;
118
+
119
+ if (handler && handler != Qnil) {
120
+ rb_funcall(handler,cbidOnComment,1,rb_str_new2(msg));
121
+ }
122
+ }
123
+
124
+ #define FORMAT_AND_CALL(callsym) \
125
+ do { \
126
+ va_list args; \
127
+ char buf[1024]; \
128
+ va_start(args, msg); \
129
+ vsnprintf(buf, sizeof buf, msg, args); \
130
+ rb_funcall(handler,callsym,1,rb_str_new2(buf)); \
131
+ va_end(args); \
132
+ } \
133
+ while (0)
134
+
135
+ // TODO these next three should actually be formatting messages.
136
+ static void warning_func(ruby_xml_sax_parser *cbp,
137
+ const char *msg, ...) {
138
+ VALUE handler = cbp->callbackHandler;
139
+
140
+ if (handler && handler != Qnil) {
141
+ FORMAT_AND_CALL(cbidOnXmlParserWarning);
142
+ }
143
+ }
144
+
145
+ static void error_func(ruby_xml_sax_parser *cbp,
146
+ const char *msg, ...) {
147
+ VALUE handler = cbp->callbackHandler;
148
+
149
+ if (handler && handler != Qnil) {
150
+ FORMAT_AND_CALL(cbidOnXmlParserError);
151
+ }
152
+ }
153
+
154
+ static void fatal_error_func(ruby_xml_sax_parser *cbp,
155
+ const char *msg, ...) {
156
+ VALUE handler = cbp->callbackHandler;
157
+
158
+ if (handler && handler != Qnil) {
159
+ FORMAT_AND_CALL(cbidOnXmlParserFatalError);
160
+ }
161
+ }
162
+
163
+ static void cdata_block_func(ruby_xml_sax_parser *cbp,
164
+ const char *value, int len) {
165
+ VALUE handler = cbp->callbackHandler;
166
+
167
+ if (handler && handler != Qnil) {
168
+ rb_funcall(handler,cbidOnCdataBlock,1,rb_str_new(value, len));
169
+ }
170
+ }
171
+
172
+ static void external_subset_func(ruby_xml_sax_parser *cbp,
173
+ const char *name,
174
+ const char *extid,
175
+ const char *sysid) {
176
+ VALUE handler = cbp->callbackHandler;
177
+
178
+ if (handler && handler != Qnil) {
179
+ rb_funcall(handler, cbidOnExternalSubset, 3, rb_str_new2(name),
180
+ rb_str_new2(extid), rb_str_new2(sysid));
181
+ }
182
+ }
183
+
184
+ static xmlSAXHandler rubySAXHandlerStruct = {
185
+ (internalSubsetSAXFunc)internal_subset_func,
186
+ (isStandaloneSAXFunc)is_standalone_func,
187
+ (hasInternalSubsetSAXFunc)has_internal_subset_func,
188
+ (hasExternalSubsetSAXFunc)has_external_subset_func,
189
+ 0, /* resolveEntity */
190
+ 0, /* getEntity */
191
+ 0, /* entityDecl */
192
+ 0, /* notationDecl */
193
+ 0, /* attributeDecl */
194
+ 0, /* elementDecl */
195
+ 0, /* unparsedEntityDecl */
196
+ 0, /* setDocumentLocator */
197
+ (startDocumentSAXFunc)start_document_func,
198
+ (endDocumentSAXFunc)end_document_func,
199
+ (startElementSAXFunc)start_element_func,
200
+ (endElementSAXFunc)end_element_func,
201
+ (referenceSAXFunc)reference_func,
202
+ (charactersSAXFunc)characters_func,
203
+ 0, /* ignorableWhitespace */
204
+ (processingInstructionSAXFunc)processing_instruction_func,
205
+ (commentSAXFunc)comment_func,
206
+ (warningSAXFunc)warning_func,
207
+ (errorSAXFunc)error_func,
208
+ (fatalErrorSAXFunc)fatal_error_func,
209
+ 0, /* xmlGetParameterEntity */
210
+ (cdataBlockSAXFunc)cdata_block_func,
211
+ (externalSubsetSAXFunc)external_subset_func,
212
+ 1
213
+ };
@@ -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 "0.6.0"
5
+ #define RUBY_LIBXML_VERNUM 0
6
+ #define RUBY_LIBXML_VER_MAJ 0
7
+ #define RUBY_LIBXML_VER_MIN 6
8
+ #define RUBY_LIBXML_VER_MIC 0
9
+ #define RUBY_LIBXML_VER_PATCH 0
data/lib/libxml.rb ADDED
@@ -0,0 +1,125 @@
1
+ # $Id: libxml.rb 291 2008-07-01 08:04:25Z cfis $
2
+ # Please see the LICENSE file for copyright and distribution information
3
+
4
+ require 'libxml_ruby.so'
5
+
6
+ module XML::XMLParserOptions
7
+ XML_PARSE_RECOVER = 1 # recover on errors
8
+ XML_PARSE_NOENT = 2 # substitute entities
9
+ XML_PARSE_DTDLOAD = 4 # load the external subset
10
+ XML_PARSE_DTDATTR = 8 # default DTD attributes
11
+ XML_PARSE_DTDVALID = 16 # validate with the DTD
12
+ XML_PARSE_NOERROR = 32 # suppress error reports
13
+ XML_PARSE_NOWARNING = 64 # suppress warning reports
14
+ XML_PARSE_PEDANTIC = 128 # pedantic error reporting
15
+ XML_PARSE_NOBLANKS = 256 # remove blank nodes
16
+ XML_PARSE_SAX1 = 512 # use the SAX1 interface internally
17
+ XML_PARSE_XINCLUDE = 1024 # Implement XInclude substitition
18
+ XML_PARSE_NONET = 2048 # Forbid network access
19
+ XML_PARSE_NODICT = 4096 # Do not reuse the context dictionnary
20
+ XML_PARSE_NSCLEAN = 8192 # remove redundant namespaces declarations
21
+ XML_PARSE_NOCDATA = 16384 # merge CDATA as text nodes
22
+ XML_PARSE_NOXINCNODE = 32768 # do not generate XINCLUDE START/END nodes
23
+ XML_PARSE_COMPACT = 65536 # compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree)
24
+ end
25
+
26
+ class XML::Document
27
+ include Enumerable
28
+
29
+ # maybe, maybe not...
30
+ def each(&blk)
31
+ find('//*').each(&blk)
32
+ end
33
+ end
34
+
35
+ class XML::Node::Set
36
+ include Enumerable
37
+
38
+ # inefficient, but maybe can find a way to cache the
39
+ # ary and dump on change?
40
+ def [](i, count = nil)
41
+ if count
42
+ to_a[i,count]
43
+ else
44
+ to_a[i]
45
+ end
46
+ end
47
+
48
+ def to_s #:nodoc:
49
+ to_a.to_s
50
+ end
51
+ end
52
+
53
+ module XML::SiblingEnum
54
+ private
55
+
56
+ # Iterates nodes and attributes
57
+ def siblings(node, &blk)
58
+ if n = node
59
+ loop do
60
+ blk.call(n)
61
+ break unless n = n.next
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ class XML::Node
68
+ include XML::SiblingEnum
69
+ include Enumerable
70
+ include Comparable
71
+
72
+ # maybe these don't belong on all nodes...
73
+ def each_child(&blk)
74
+ siblings(child, &blk)
75
+ end
76
+
77
+ def each_attr(&blk)
78
+ siblings(properties, &blk)
79
+ end
80
+
81
+ # all siblings INCLUDING self
82
+ def each_sibling(&blk)
83
+ siblings(self, &blk)
84
+ end
85
+
86
+ # I guess this is what you'd expect?
87
+ alias :each :each_child
88
+
89
+ def to_a
90
+ inject([]) { |ary,n| ary << n }
91
+ end
92
+
93
+ def <=>(other)
94
+ to_s <=> other.to_s
95
+ end
96
+
97
+ def clone
98
+ copy(false)
99
+ end
100
+ end
101
+
102
+ class XML::Attr
103
+ include XML::SiblingEnum
104
+ include Enumerable
105
+
106
+ def each_sibling(&blk)
107
+ siblings(self,&blk)
108
+ end
109
+
110
+ alias :each_attr :each_sibling
111
+ alias :each :each_sibling
112
+
113
+ def to_h
114
+ inject({}) do |h,a| h[a.name] = a.value; h end
115
+ end
116
+
117
+ def to_a
118
+ inject([]) do |ary,a| ary << [a.name, a.value] end
119
+ end
120
+
121
+ def to_s
122
+ "#{name} = #{value}"
123
+ end
124
+ end
125
+