libxml-ruby 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/CHANGES +41 -1
  2. data/LICENSE +3 -4
  3. data/README +37 -24
  4. data/Rakefile +2 -2
  5. data/ext/libxml/extconf.rb +31 -12
  6. data/ext/libxml/libxml.c +56 -858
  7. data/ext/libxml/ruby_libxml.h +93 -96
  8. data/ext/libxml/ruby_xml.c +855 -0
  9. data/ext/libxml/ruby_xml.h +9 -0
  10. data/ext/libxml/ruby_xml_attr.c +3 -9
  11. data/ext/libxml/ruby_xml_attr.h +2 -2
  12. data/ext/libxml/ruby_xml_attr_decl.c +2 -8
  13. data/ext/libxml/ruby_xml_attr_decl.h +1 -1
  14. data/ext/libxml/ruby_xml_attributes.c +6 -8
  15. data/ext/libxml/ruby_xml_attributes.h +1 -1
  16. data/ext/libxml/ruby_xml_document.c +915 -895
  17. data/ext/libxml/ruby_xml_document.h +2 -2
  18. data/ext/libxml/ruby_xml_dtd.c +257 -136
  19. data/ext/libxml/ruby_xml_dtd.h +1 -1
  20. data/ext/libxml/ruby_xml_encoding.c +55 -37
  21. data/ext/libxml/ruby_xml_encoding.h +1 -1
  22. data/ext/libxml/ruby_xml_error.c +526 -1058
  23. data/ext/libxml/ruby_xml_error.h +1 -1
  24. data/ext/libxml/ruby_xml_html_parser.c +2 -8
  25. data/ext/libxml/ruby_xml_html_parser.h +2 -2
  26. data/ext/libxml/ruby_xml_html_parser_context.c +175 -145
  27. data/ext/libxml/ruby_xml_html_parser_context.h +1 -1
  28. data/ext/libxml/ruby_xml_html_parser_options.c +12 -20
  29. data/ext/libxml/ruby_xml_html_parser_options.h +1 -1
  30. data/ext/libxml/ruby_xml_input_cbg.c +2 -8
  31. data/ext/libxml/ruby_xml_input_cbg.h +1 -1
  32. data/ext/libxml/ruby_xml_namespace.c +2 -8
  33. data/ext/libxml/ruby_xml_namespace.h +2 -2
  34. data/ext/libxml/ruby_xml_namespaces.c +1 -9
  35. data/ext/libxml/ruby_xml_namespaces.h +1 -1
  36. data/ext/libxml/ruby_xml_node.c +182 -121
  37. data/ext/libxml/ruby_xml_node.h +2 -2
  38. data/ext/libxml/ruby_xml_parser.c +2 -8
  39. data/ext/libxml/ruby_xml_parser.h +2 -2
  40. data/ext/libxml/ruby_xml_parser_context.c +952 -901
  41. data/ext/libxml/ruby_xml_parser_context.h +2 -2
  42. data/ext/libxml/ruby_xml_parser_options.c +2 -9
  43. data/ext/libxml/ruby_xml_parser_options.h +1 -1
  44. data/ext/libxml/ruby_xml_reader.c +1002 -993
  45. data/ext/libxml/ruby_xml_reader.h +1 -1
  46. data/ext/libxml/ruby_xml_relaxng.c +1 -7
  47. data/ext/libxml/ruby_xml_relaxng.h +1 -1
  48. data/ext/libxml/ruby_xml_sax2_handler.c +2 -2
  49. data/ext/libxml/ruby_xml_sax2_handler.h +1 -1
  50. data/ext/libxml/ruby_xml_sax_parser.c +2 -8
  51. data/ext/libxml/ruby_xml_sax_parser.h +2 -2
  52. data/ext/libxml/ruby_xml_schema.c +1 -7
  53. data/ext/libxml/ruby_xml_schema.h +1 -1
  54. data/ext/libxml/{version.h → ruby_xml_version.h} +2 -2
  55. data/ext/libxml/ruby_xml_xinclude.c +2 -8
  56. data/ext/libxml/ruby_xml_xinclude.h +2 -2
  57. data/ext/libxml/ruby_xml_xpath.c +17 -18
  58. data/ext/libxml/ruby_xml_xpath.h +2 -2
  59. data/ext/libxml/ruby_xml_xpath_context.c +387 -389
  60. data/ext/libxml/ruby_xml_xpath_context.h +2 -2
  61. data/ext/libxml/ruby_xml_xpath_expression.c +18 -8
  62. data/ext/libxml/ruby_xml_xpath_expression.h +1 -1
  63. data/ext/libxml/ruby_xml_xpath_object.c +19 -8
  64. data/ext/libxml/ruby_xml_xpath_object.h +1 -1
  65. data/ext/libxml/ruby_xml_xpointer.c +2 -8
  66. data/ext/libxml/ruby_xml_xpointer.h +2 -2
  67. data/ext/vc/libxml_ruby.sln +7 -1
  68. data/lib/libxml.rb +1 -12
  69. data/lib/libxml/attr.rb +0 -3
  70. data/lib/libxml/attr_decl.rb +0 -3
  71. data/lib/libxml/attributes.rb +0 -3
  72. data/lib/libxml/document.rb +31 -5
  73. data/lib/libxml/error.rb +8 -4
  74. data/lib/libxml/properties.rb +0 -5
  75. data/lib/libxml/sax_callbacks.rb +30 -19
  76. data/lib/libxml/tree.rb +0 -1
  77. data/lib/libxml/xpath_object.rb +0 -13
  78. data/test/model/definition.dtd +8 -0
  79. data/test/tc_attributes.rb +4 -1
  80. data/test/tc_document.rb +16 -0
  81. data/test/tc_dtd.rb +30 -2
  82. data/test/tc_html_parser.rb +55 -10
  83. data/test/tc_node.rb +67 -1
  84. data/test/tc_node_edit.rb +26 -6
  85. data/test/tc_node_text.rb +41 -23
  86. data/test/tc_parser.rb +50 -0
  87. data/test/tc_reader.rb +15 -0
  88. data/test/tc_relaxng.rb +1 -1
  89. data/test/tc_sax_parser.rb +37 -5
  90. data/test/tc_schema.rb +1 -1
  91. data/test/tc_xpath.rb +1 -0
  92. data/test/tc_xpath_expression.rb +4 -2
  93. metadata +6 -6
  94. data/ext/libxml/ruby_xml_state.c +0 -51
  95. data/ext/libxml/ruby_xml_state.h +0 -11
  96. data/ext/vc/libxml_ruby.vcproj +0 -460
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_document.h 666 2008-12-07 00:16:50Z cfis $ */
1
+ /* $Id: ruby_xml_document.h 758 2009-01-25 20:36:03Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  extern VALUE cXMLDocument;
9
9
 
10
- void ruby_init_xml_document();
10
+ void rxml_init_document();
11
11
 
12
12
 
13
13
  #if defined(_WIN32)
@@ -1,136 +1,257 @@
1
- #include "ruby_libxml.h"
2
- #include "ruby_xml_dtd.h"
3
-
4
- /*
5
- * Document-class: LibXML::XML::Dtd
6
- *
7
- * The XML::Dtd class is used to prepare DTD's for validation of xml
8
- * documents.
9
- *
10
- * DTDs can be created from a string or a pair of public and system identifiers.
11
- * Once a Dtd object is instantiated, an XML document can be validated by the
12
- * XML::Document#validate method providing the XML::Dtd object as parameeter.
13
- * The method will raise an exception if the document is
14
- * not valid.
15
- *
16
- * Basic usage:
17
- *
18
- * # parse DTD
19
- * dtd = XML::Dtd.new(<<EOF)
20
- * <!ELEMENT root (item*) >
21
- * <!ELEMENT item (#PCDATA) >
22
- * EOF
23
- *
24
- * # parse xml document to be validated
25
- * instance = XML::Document.file('instance.xml')
26
- *
27
- * # validate
28
- * instance.validate(dtd)
29
- */
30
-
31
- VALUE cXMLDtd;
32
-
33
- void rxml_dtd_free(xmlDtdPtr xdtd)
34
- {
35
- xmlFreeDtd(xdtd);
36
- }
37
-
38
- static VALUE rxml_dtd_alloc(VALUE klass)
39
- {
40
- return Data_Wrap_Struct(klass, NULL, rxml_dtd_free, NULL);
41
- }
42
-
43
- VALUE rxml_dtd_wrap(xmlDtdPtr xdtd)
44
- {
45
- VALUE result;
46
-
47
- // This node is already wrapped
48
- if (xdtd->_private != NULL)
49
- return (VALUE) xdtd->_private;
50
-
51
- result = Data_Wrap_Struct(cXMLDtd, NULL, NULL, xdtd);
52
-
53
- xdtd->_private = (void*) result;
54
-
55
- return result;
56
- }
57
-
58
-
59
-
60
- /*
61
- * call-seq:
62
- * XML::Dtd.new("public system") -> dtd
63
- * XML::Dtd.new("public", "system") -> dtd
64
- *
65
- * Create a new Dtd from the specified public and system
66
- * identifiers.
67
- */
68
- static VALUE rxml_dtd_initialize(int argc, VALUE *argv, VALUE self)
69
- {
70
- VALUE external, system, dtd_string;
71
- xmlParserInputBufferPtr buffer;
72
- xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
73
- xmlChar *new_string;
74
- xmlDtdPtr xdtd;
75
-
76
- // 1 argument -- string --> parsujeme jako dtd
77
- // 2 argumenty -- public, system --> bude se hledat
78
- switch (argc)
79
- {
80
- case 2:
81
- rb_scan_args(argc, argv, "20", &external, &system);
82
-
83
- Check_Type(external, T_STRING);
84
- Check_Type(system, T_STRING);
85
-
86
- xdtd = xmlParseDTD((xmlChar*) StringValuePtr(external),
87
- (xmlChar*) StringValuePtr(system));
88
-
89
- if (xdtd == NULL)
90
- rxml_raise(&xmlLastError);
91
-
92
- DATA_PTR(self) = xdtd;
93
-
94
- xmlSetTreeDoc((xmlNodePtr) xdtd, NULL);
95
- break;
96
-
97
- case 1:
98
- rb_scan_args(argc, argv, "10", &dtd_string);
99
- Check_Type(dtd_string, T_STRING);
100
-
101
- /* Note that buffer is freed by xmlParserInputBufferPush*/
102
- buffer = xmlAllocParserInputBuffer(enc);
103
- new_string = xmlStrdup((xmlChar*) StringValuePtr(dtd_string));
104
- xmlParserInputBufferPush(buffer, xmlStrlen(new_string),
105
- (const char*) new_string);
106
-
107
- xdtd = xmlIOParseDTD(NULL, buffer, enc);
108
-
109
- if (xdtd == NULL)
110
- rxml_raise(&xmlLastError);
111
-
112
- xmlFree(new_string);
113
-
114
- DATA_PTR( self) = xdtd;
115
- break;
116
-
117
- default:
118
- rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
119
- }
120
-
121
- return self;
122
- }
123
-
124
- // Rdoc needs to know
125
- #ifdef RDOC_NEVER_DEFINED
126
- mLibXML = rb_define_module("LibXML");
127
- mXML = rb_define_module_under(mLibXML, "XML");
128
- #endif
129
-
130
- void ruby_init_xml_dtd()
131
- {
132
- cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
133
- rb_define_alloc_func(cXMLDtd, rxml_dtd_alloc);
134
- rb_define_method(cXMLDtd, "initialize", rxml_dtd_initialize, -1);
135
- }
136
-
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml_dtd.h"
3
+
4
+ /*
5
+ * Document-class: LibXML::XML::Dtd
6
+ *
7
+ * The XML::Dtd class is used to prepare DTD's for validation of xml
8
+ * documents.
9
+ *
10
+ * DTDs can be created from a string or a pair of public and system identifiers.
11
+ * Once a Dtd object is instantiated, an XML document can be validated by the
12
+ * XML::Document#validate method providing the XML::Dtd object as parameeter.
13
+ * The method will raise an exception if the document is
14
+ * not valid.
15
+ *
16
+ * Basic usage:
17
+ *
18
+ * # parse DTD
19
+ * dtd = XML::Dtd.new(<<EOF)
20
+ * <!ELEMENT root (item*) >
21
+ * <!ELEMENT item (#PCDATA) >
22
+ * EOF
23
+ *
24
+ * # parse xml document to be validated
25
+ * instance = XML::Document.file('instance.xml')
26
+ *
27
+ * # validate
28
+ * instance.validate(dtd)
29
+ */
30
+
31
+ VALUE cXMLDtd;
32
+
33
+ void rxml_dtd_free(xmlDtdPtr xdtd)
34
+ {
35
+ /* Set _private to NULL so that we won't reuse the
36
+ same, freed, Ruby wrapper object later.*/
37
+ xdtd->_private = NULL;
38
+
39
+ if (xdtd->doc == NULL && xdtd->parent == NULL)
40
+ xmlFreeDtd(xdtd);
41
+ }
42
+
43
+ void rxml_dtd_mark(xmlDtdPtr xdtd)
44
+ {
45
+ if (xdtd == NULL)
46
+ return;
47
+
48
+ if (xdtd->_private == NULL)
49
+ {
50
+ rb_warning("XmlNode is not bound! (%s:%d)", __FILE__, __LINE__);
51
+ return;
52
+ }
53
+
54
+ rxml_node_mark_common((xmlNodePtr) xdtd);
55
+ }
56
+
57
+
58
+ static VALUE rxml_dtd_alloc(VALUE klass)
59
+ {
60
+ return Data_Wrap_Struct(klass, rxml_dtd_mark, rxml_dtd_free, NULL);
61
+ }
62
+
63
+ VALUE rxml_dtd_wrap(xmlDtdPtr xdtd)
64
+ {
65
+ VALUE result;
66
+
67
+ // This node is already wrapped
68
+ if (xdtd->_private != NULL)
69
+ return (VALUE) xdtd->_private;
70
+
71
+ result = Data_Wrap_Struct(cXMLDtd, NULL, NULL, xdtd);
72
+
73
+ xdtd->_private = (void*) result;
74
+
75
+ return result;
76
+ }
77
+
78
+ /*
79
+ * call-seq:
80
+ * dtd.external_id -> "string"
81
+ *
82
+ * Obtain this dtd's external identifer (for a PUBLIC DTD).
83
+ */
84
+ static VALUE rxml_dtd_external_id_get(VALUE self)
85
+ {
86
+ xmlDtdPtr xdtd;
87
+ Data_Get_Struct(self, xmlDtd, xdtd);
88
+
89
+
90
+ if (xdtd->ExternalID == NULL)
91
+ return (Qnil);
92
+ else
93
+ return (rb_str_new2((const char*) xdtd->ExternalID));
94
+ }
95
+
96
+ /*
97
+ * call-seq:
98
+ * dtd.name -> "string"
99
+ *
100
+ * Obtain this dtd's name.
101
+ */
102
+ static VALUE rxml_dtd_name_get(VALUE self)
103
+ {
104
+ xmlDtdPtr xdtd;
105
+ Data_Get_Struct(self, xmlDtd, xdtd);
106
+
107
+
108
+ if (xdtd->name == NULL)
109
+ return (Qnil);
110
+ else
111
+ return (rb_str_new2((const char*) xdtd->name));
112
+ }
113
+
114
+
115
+ /*
116
+ * call-seq:
117
+ * dtd.uri -> "string"
118
+ *
119
+ * Obtain this dtd's URI (for a SYSTEM or PUBLIC DTD).
120
+ */
121
+ static VALUE rxml_dtd_uri_get(VALUE self)
122
+ {
123
+ xmlDtdPtr xdtd;
124
+ Data_Get_Struct(self, xmlDtd, xdtd);
125
+
126
+
127
+ if (xdtd->SystemID == NULL)
128
+ return (Qnil);
129
+ else
130
+ return (rb_str_new2((const char*) xdtd->SystemID));
131
+ }
132
+
133
+ /*
134
+ * call-seq:
135
+ * XML::Dtd.new("DTD string") -> dtd
136
+ * XML::Dtd.new("public", "system") -> dtd
137
+ * XML::Dtd.new("name", "public", "system", document) -> external subset dtd
138
+ * XML::Dtd.new("name", "public", "system", document, false) -> internal subset dtd
139
+ * XML::Dtd.new("name", "public", "system", document, true) -> internal subset dtd
140
+ *
141
+ * Create a new Dtd from the specified public and system
142
+ * identifiers.
143
+ */
144
+ static VALUE rxml_dtd_initialize(int argc, VALUE *argv, VALUE self)
145
+ {
146
+ VALUE external, system, dtd_string;
147
+ xmlParserInputBufferPtr buffer;
148
+ xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
149
+ xmlChar *new_string;
150
+ xmlDtdPtr xdtd;
151
+
152
+ // 1 argument -- string --> parsujeme jako dtd
153
+ // 2 arguments -- public, system --> bude se hledat
154
+ // 3 arguments -- public, system, name --> creates an external subset (any parameter may be nil)
155
+ // 4 arguments -- public, system, name, doc --> creates an external subset (any parameter may be nil)
156
+ // 5 arguments -- public, system, name, doc, true --> creates an internal subset (all but last parameter may be nil)
157
+ switch (argc)
158
+ {
159
+ case 3:
160
+ case 4:
161
+ case 5: {
162
+ VALUE name, doc, internal;
163
+ const xmlChar *xname = NULL, *xpublic = NULL, *xsystem = NULL;
164
+ xmlDocPtr xdoc = NULL;
165
+
166
+ rb_scan_args(argc, argv, "32", &external, &system, &name, &doc, &internal);
167
+
168
+ if (external != Qnil) {
169
+ Check_Type(external, T_STRING);
170
+ xpublic = (const xmlChar*) StringValuePtr(external);
171
+ }
172
+ if (system != Qnil) {
173
+ Check_Type(system, T_STRING);
174
+ xsystem = (const xmlChar*) StringValuePtr(system);
175
+ }
176
+ if (name != Qnil) {
177
+ Check_Type(name, T_STRING);
178
+ xname = (const xmlChar*) StringValuePtr(name);
179
+ }
180
+ if (doc != Qnil) {
181
+ if (rb_obj_is_kind_of(doc, cXMLDocument) == Qfalse)
182
+ rb_raise(rb_eTypeError, "Must pass an XML::Document object");
183
+ Data_Get_Struct(doc, xmlDoc, xdoc);
184
+ }
185
+
186
+ if (internal == Qnil || internal == Qfalse)
187
+ xdtd = xmlNewDtd(xdoc, xname, xpublic, xsystem);
188
+ else
189
+ xdtd = xmlCreateIntSubset(xdoc, xname, xpublic, xsystem);
190
+
191
+ if (xdtd == NULL)
192
+ rxml_raise(&xmlLastError);
193
+
194
+ /* Document will free this dtd now. */
195
+ RDATA(self)->dfree = NULL;
196
+ DATA_PTR(self) = xdtd;
197
+
198
+ xmlSetTreeDoc((xmlNodePtr) xdtd, xdoc);
199
+ }
200
+ break;
201
+
202
+ case 2:
203
+ rb_scan_args(argc, argv, "20", &external, &system);
204
+
205
+ Check_Type(external, T_STRING);
206
+ Check_Type(system, T_STRING);
207
+
208
+ xdtd = xmlParseDTD((xmlChar*) StringValuePtr(external),
209
+ (xmlChar*) StringValuePtr(system));
210
+
211
+ if (xdtd == NULL)
212
+ rxml_raise(&xmlLastError);
213
+
214
+ DATA_PTR(self) = xdtd;
215
+
216
+ xmlSetTreeDoc((xmlNodePtr) xdtd, NULL);
217
+ break;
218
+
219
+ case 1:
220
+ rb_scan_args(argc, argv, "10", &dtd_string);
221
+ Check_Type(dtd_string, T_STRING);
222
+
223
+ /* Note that buffer is freed by xmlParserInputBufferPush*/
224
+ buffer = xmlAllocParserInputBuffer(enc);
225
+ new_string = xmlStrdup((xmlChar*) StringValuePtr(dtd_string));
226
+ xmlParserInputBufferPush(buffer, xmlStrlen(new_string),
227
+ (const char*) new_string);
228
+
229
+ xdtd = xmlIOParseDTD(NULL, buffer, enc);
230
+
231
+ if (xdtd == NULL)
232
+ rxml_raise(&xmlLastError);
233
+
234
+ xmlFree(new_string);
235
+
236
+ DATA_PTR(self) = xdtd;
237
+ break;
238
+
239
+ default:
240
+ rb_raise(rb_eArgError, "wrong number of arguments");
241
+ }
242
+
243
+ return self;
244
+ }
245
+
246
+ void rxml_init_dtd()
247
+ {
248
+ cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
249
+ rb_define_alloc_func(cXMLDtd, rxml_dtd_alloc);
250
+ rb_define_method(cXMLDtd, "initialize", rxml_dtd_initialize, -1);
251
+ rb_define_method(cXMLDtd, "external_id", rxml_dtd_external_id_get, 0);
252
+ rb_define_method(cXMLDtd, "name", rxml_dtd_name_get, 0);
253
+ rb_define_method(cXMLDtd, "uri", rxml_dtd_uri_get, 0);
254
+
255
+ rb_define_alias(cXMLDtd, "system_id", "uri");
256
+ }
257
+
@@ -3,7 +3,7 @@
3
3
 
4
4
  extern VALUE cXMLDtd;
5
5
 
6
- void ruby_init_xml_dtd(void);
6
+ void rxml_init_dtd(void);
7
7
  VALUE rxml_dtd_wrap(xmlDtdPtr xdtd);
8
8
 
9
9
  #endif
@@ -8,13 +8,14 @@
8
8
  /*
9
9
  * Document-class: LibXML::XML::Encoding
10
10
  *
11
- * The encoding class defines the encodings that libxml
12
- * supports. LibXML converts all data sources to UTF8
13
- * internally before processing them.
11
+ * The encoding class exposes the encodings that libxml
12
+ * supports via constants.
14
13
  *
15
- * By default, LibXML determines a data source's encoding
14
+ * LibXML converts all data sources to UTF8
15
+ * internally before processing them. By default,
16
+ * LibXML determines a data source's encoding
16
17
  * using the algorithm described on its
17
- * website[* http://xmlsoft.org/encoding.html].
18
+ * website[http://xmlsoft.org/encoding.html].
18
19
  *
19
20
  * However, you may override a data source's encoding
20
21
  * by using the encoding constants defined in this
@@ -76,41 +77,58 @@ static VALUE rxml_encoding_to_s(VALUE klass, VALUE encoding)
76
77
  return rb_str_new2(xecoding);
77
78
  }
78
79
 
79
- // Rdoc needs to know
80
- #ifdef RDOC_NEVER_DEFINED
81
- mLibXML = rb_define_module("LibXML");
82
- mXML = rb_define_module_under(mLibXML, "XML");
83
- #endif
84
-
85
- void ruby_init_xml_encoding(void)
80
+ void rxml_init_encoding(void)
86
81
  {
87
82
  mXMLEncoding = rb_define_module_under(mXML, "Encoding");
88
83
  rb_define_module_function(mXMLEncoding, "from_s", rxml_encoding_from_s, 1);
89
84
  rb_define_module_function(mXMLEncoding, "to_s", rxml_encoding_to_s, 1);
90
85
 
91
- rb_define_const(mXMLEncoding, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
92
- rb_define_const(mXMLEncoding, "ERROR", INT2NUM(XML_CHAR_ENCODING_ERROR)); /* No char encoding detected */
93
- rb_define_const(mXMLEncoding, "NONE", INT2NUM(XML_CHAR_ENCODING_NONE)); /* No char encoding detected */
94
- rb_define_const(mXMLEncoding, "UTF_8", INT2NUM(XML_CHAR_ENCODING_UTF8)); /* UTF-8 */
95
- rb_define_const(mXMLEncoding, "UTF_16LE", INT2NUM(XML_CHAR_ENCODING_UTF16LE)); /* UTF-16 little endian */
96
- rb_define_const(mXMLEncoding, "UTF_16BE", INT2NUM(XML_CHAR_ENCODING_UTF16BE)); /* UTF-16 big endian */
97
- rb_define_const(mXMLEncoding, "UCS_4LE", INT2NUM(XML_CHAR_ENCODING_UCS4LE)); /* UCS-4 little endian */
98
- rb_define_const(mXMLEncoding, "UCS_4BE", INT2NUM(XML_CHAR_ENCODING_UCS4BE)); /* UCS-4 big endian */
99
- rb_define_const(mXMLEncoding, "EBCDIC", INT2NUM(XML_CHAR_ENCODING_EBCDIC)); /* EBCDIC uh! */
100
- rb_define_const(mXMLEncoding, "UCS_4_2143", INT2NUM(XML_CHAR_ENCODING_UCS4_2143)); /* UCS-4 unusual ordering */
101
- rb_define_const(mXMLEncoding, "UCS_4_3412", INT2NUM(XML_CHAR_ENCODING_UCS4_3412)); /* UCS-4 unusual ordering */
102
- rb_define_const(mXMLEncoding, "UCS_2", INT2NUM(XML_CHAR_ENCODING_UCS2)); /* UCS-2 */
103
- rb_define_const(mXMLEncoding, "ISO_8859_1", INT2NUM(XML_CHAR_ENCODING_8859_1)); /* ISO-8859-1 ISO Latin 1 */
104
- rb_define_const(mXMLEncoding, "ISO_8859_2", INT2NUM(XML_CHAR_ENCODING_8859_2)); /* ISO-8859-2 ISO Latin 2 */
105
- rb_define_const(mXMLEncoding, "ISO_8859_3", INT2NUM(XML_CHAR_ENCODING_8859_3)); /* ISO-8859-3 */
106
- rb_define_const(mXMLEncoding, "ISO_8859_4", INT2NUM(XML_CHAR_ENCODING_8859_4)); /* ISO-8859-4 */
107
- rb_define_const(mXMLEncoding, "ISO_8859_5", INT2NUM(XML_CHAR_ENCODING_8859_5)); /* ISO-8859-5 */
108
- rb_define_const(mXMLEncoding, "ISO_8859_6", INT2NUM(XML_CHAR_ENCODING_8859_6)); /* ISO-8859-6 */
109
- rb_define_const(mXMLEncoding, "ISO_8859_7", INT2NUM(XML_CHAR_ENCODING_8859_7)); /* ISO-8859-7 */
110
- rb_define_const(mXMLEncoding, "ISO_8859_8", INT2NUM(XML_CHAR_ENCODING_8859_8)); /* ISO-8859-8 */
111
- rb_define_const(mXMLEncoding, "ISO_8859_9", INT2NUM(XML_CHAR_ENCODING_8859_9)); /* ISO-8859-9 */
112
- rb_define_const(mXMLEncoding, "ISO_2022_JP", INT2NUM(XML_CHAR_ENCODING_2022_JP)); /* ISO-2022-JP */
113
- rb_define_const(mXMLEncoding, "SHIFT_JIS", INT2NUM(XML_CHAR_ENCODING_SHIFT_JIS)); /* Shift_JIS */
114
- rb_define_const(mXMLEncoding, "EUC_JP", INT2NUM(XML_CHAR_ENCODING_EUC_JP)); /* EUC-JP */
115
- rb_define_const(mXMLEncoding, "ASCII", INT2NUM(XML_CHAR_ENCODING_ASCII)); /* pure ASCII */
86
+ /* -1: No char encoding detected. */
87
+ rb_define_const(mXMLEncoding, "ERROR", INT2NUM(XML_CHAR_ENCODING_ERROR));
88
+ /* 0: No char encoding detected. */
89
+ rb_define_const(mXMLEncoding, "NONE", INT2NUM(XML_CHAR_ENCODING_NONE));
90
+ /* 1: UTF-8 */
91
+ rb_define_const(mXMLEncoding, "UTF_8", INT2NUM(XML_CHAR_ENCODING_UTF8));
92
+ /* 2: UTF-16 little endian. */
93
+ rb_define_const(mXMLEncoding, "UTF_16LE", INT2NUM(XML_CHAR_ENCODING_UTF16LE));
94
+ /* 3: UTF-16 big endian. */
95
+ rb_define_const(mXMLEncoding, "UTF_16BE", INT2NUM(XML_CHAR_ENCODING_UTF16BE));
96
+ /* 4: UCS-4 little endian. */
97
+ rb_define_const(mXMLEncoding, "UCS_4LE", INT2NUM(XML_CHAR_ENCODING_UCS4LE));
98
+ /* 5: UCS-4 big endian. */
99
+ rb_define_const(mXMLEncoding, "UCS_4BE", INT2NUM(XML_CHAR_ENCODING_UCS4BE));
100
+ /* 6: EBCDIC uh! */
101
+ rb_define_const(mXMLEncoding, "EBCDIC", INT2NUM(XML_CHAR_ENCODING_EBCDIC));
102
+ /* 7: UCS-4 unusual ordering. */
103
+ rb_define_const(mXMLEncoding, "UCS_4_2143", INT2NUM(XML_CHAR_ENCODING_UCS4_2143));
104
+ /* 8: UCS-4 unusual ordering. */
105
+ rb_define_const(mXMLEncoding, "UCS_4_3412", INT2NUM(XML_CHAR_ENCODING_UCS4_3412));
106
+ /* 9: UCS-2. */
107
+ rb_define_const(mXMLEncoding, "UCS_2", INT2NUM(XML_CHAR_ENCODING_UCS2));
108
+ /* 10: ISO-8859-1 ISO Latin 1. */
109
+ rb_define_const(mXMLEncoding, "ISO_8859_1", INT2NUM(XML_CHAR_ENCODING_8859_1));
110
+ /* 11: ISO-8859-2 ISO Latin 2. */
111
+ rb_define_const(mXMLEncoding, "ISO_8859_2", INT2NUM(XML_CHAR_ENCODING_8859_2));
112
+ /* 12: ISO-8859-3. */
113
+ rb_define_const(mXMLEncoding, "ISO_8859_3", INT2NUM(XML_CHAR_ENCODING_8859_3));
114
+ /* 13: ISO-8859-4. */
115
+ rb_define_const(mXMLEncoding, "ISO_8859_4", INT2NUM(XML_CHAR_ENCODING_8859_4));
116
+ /* 14: ISO-8859-5. */
117
+ rb_define_const(mXMLEncoding, "ISO_8859_5", INT2NUM(XML_CHAR_ENCODING_8859_5));
118
+ /* 15: ISO-8859-6. */
119
+ rb_define_const(mXMLEncoding, "ISO_8859_6", INT2NUM(XML_CHAR_ENCODING_8859_6));
120
+ /* 16: ISO-8859-7. */
121
+ rb_define_const(mXMLEncoding, "ISO_8859_7", INT2NUM(XML_CHAR_ENCODING_8859_7));
122
+ /* 17: ISO-8859-8. */
123
+ rb_define_const(mXMLEncoding, "ISO_8859_8", INT2NUM(XML_CHAR_ENCODING_8859_8));
124
+ /* 18: ISO-8859-9. */
125
+ rb_define_const(mXMLEncoding, "ISO_8859_9", INT2NUM(XML_CHAR_ENCODING_8859_9));
126
+ /* 19: ISO-2022-JP. */
127
+ rb_define_const(mXMLEncoding, "ISO_2022_JP", INT2NUM(XML_CHAR_ENCODING_2022_JP));
128
+ /* 20: Shift_JIS. */
129
+ rb_define_const(mXMLEncoding, "SHIFT_JIS", INT2NUM(XML_CHAR_ENCODING_SHIFT_JIS));
130
+ /* 21: EUC-JP. */
131
+ rb_define_const(mXMLEncoding, "EUC_JP", INT2NUM(XML_CHAR_ENCODING_EUC_JP));
132
+ /* 22: pure ASCII. */
133
+ rb_define_const(mXMLEncoding, "ASCII", INT2NUM(XML_CHAR_ENCODING_ASCII));
116
134
  }