nokogiri 1.16.8-x86-linux → 1.17.0-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +11 -21
  3. data/README.md +4 -0
  4. data/dependencies.yml +6 -6
  5. data/ext/nokogiri/extconf.rb +191 -137
  6. data/ext/nokogiri/gumbo.c +69 -53
  7. data/ext/nokogiri/html4_document.c +10 -4
  8. data/ext/nokogiri/html4_element_description.c +18 -18
  9. data/ext/nokogiri/html4_sax_parser.c +40 -0
  10. data/ext/nokogiri/html4_sax_parser_context.c +48 -58
  11. data/ext/nokogiri/html4_sax_push_parser.c +25 -24
  12. data/ext/nokogiri/include/libexslt/exsltconfig.h +3 -3
  13. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +12 -19
  14. data/ext/nokogiri/include/libxml2/libxml/c14n.h +1 -12
  15. data/ext/nokogiri/include/libxml2/libxml/debugXML.h +1 -1
  16. data/ext/nokogiri/include/libxml2/libxml/encoding.h +9 -0
  17. data/ext/nokogiri/include/libxml2/libxml/entities.h +12 -1
  18. data/ext/nokogiri/include/libxml2/libxml/hash.h +19 -0
  19. data/ext/nokogiri/include/libxml2/libxml/list.h +2 -2
  20. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +17 -0
  21. data/ext/nokogiri/include/libxml2/libxml/parser.h +60 -54
  22. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +9 -1
  23. data/ext/nokogiri/include/libxml2/libxml/pattern.h +6 -0
  24. data/ext/nokogiri/include/libxml2/libxml/tree.h +32 -12
  25. data/ext/nokogiri/include/libxml2/libxml/uri.h +11 -0
  26. data/ext/nokogiri/include/libxml2/libxml/valid.h +29 -2
  27. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +7 -0
  28. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +21 -4
  29. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +14 -0
  30. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +111 -15
  31. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +8 -45
  32. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +2 -0
  33. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +5 -0
  34. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +165 -1
  35. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +7 -171
  36. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +1 -0
  37. data/ext/nokogiri/include/libxml2/libxml/xpath.h +4 -0
  38. data/ext/nokogiri/include/libxslt/xsltInternals.h +3 -0
  39. data/ext/nokogiri/include/libxslt/xsltconfig.h +4 -37
  40. data/ext/nokogiri/libxml2_polyfill.c +114 -0
  41. data/ext/nokogiri/nokogiri.c +9 -2
  42. data/ext/nokogiri/nokogiri.h +18 -33
  43. data/ext/nokogiri/xml_attr.c +1 -1
  44. data/ext/nokogiri/xml_cdata.c +2 -10
  45. data/ext/nokogiri/xml_comment.c +3 -8
  46. data/ext/nokogiri/xml_document.c +163 -156
  47. data/ext/nokogiri/xml_document_fragment.c +10 -25
  48. data/ext/nokogiri/xml_dtd.c +1 -1
  49. data/ext/nokogiri/xml_element_content.c +9 -9
  50. data/ext/nokogiri/xml_encoding_handler.c +4 -4
  51. data/ext/nokogiri/xml_namespace.c +6 -6
  52. data/ext/nokogiri/xml_node.c +130 -104
  53. data/ext/nokogiri/xml_node_set.c +46 -44
  54. data/ext/nokogiri/xml_reader.c +54 -58
  55. data/ext/nokogiri/xml_relax_ng.c +35 -56
  56. data/ext/nokogiri/xml_sax_parser.c +156 -88
  57. data/ext/nokogiri/xml_sax_parser_context.c +213 -131
  58. data/ext/nokogiri/xml_sax_push_parser.c +68 -49
  59. data/ext/nokogiri/xml_schema.c +50 -85
  60. data/ext/nokogiri/xml_syntax_error.c +19 -11
  61. data/ext/nokogiri/xml_text.c +2 -4
  62. data/ext/nokogiri/xml_xpath_context.c +2 -2
  63. data/ext/nokogiri/xslt_stylesheet.c +8 -8
  64. data/lib/nokogiri/3.0/nokogiri.so +0 -0
  65. data/lib/nokogiri/3.1/nokogiri.so +0 -0
  66. data/lib/nokogiri/3.2/nokogiri.so +0 -0
  67. data/lib/nokogiri/3.3/nokogiri.so +0 -0
  68. data/lib/nokogiri/class_resolver.rb +1 -1
  69. data/lib/nokogiri/css/node.rb +6 -2
  70. data/lib/nokogiri/css/parser.rb +6 -4
  71. data/lib/nokogiri/css/parser.y +2 -2
  72. data/lib/nokogiri/css/parser_extras.rb +6 -66
  73. data/lib/nokogiri/css/selector_cache.rb +38 -0
  74. data/lib/nokogiri/css/tokenizer.rb +4 -4
  75. data/lib/nokogiri/css/tokenizer.rex +9 -8
  76. data/lib/nokogiri/css/xpath_visitor.rb +42 -6
  77. data/lib/nokogiri/css.rb +86 -20
  78. data/lib/nokogiri/decorators/slop.rb +3 -5
  79. data/lib/nokogiri/encoding_handler.rb +2 -2
  80. data/lib/nokogiri/html4/document.rb +44 -23
  81. data/lib/nokogiri/html4/document_fragment.rb +124 -12
  82. data/lib/nokogiri/html4/encoding_reader.rb +1 -1
  83. data/lib/nokogiri/html4/sax/parser.rb +23 -38
  84. data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
  85. data/lib/nokogiri/html4.rb +9 -14
  86. data/lib/nokogiri/html5/builder.rb +40 -0
  87. data/lib/nokogiri/html5/document.rb +61 -30
  88. data/lib/nokogiri/html5/document_fragment.rb +130 -20
  89. data/lib/nokogiri/html5/node.rb +4 -4
  90. data/lib/nokogiri/html5.rb +114 -72
  91. data/lib/nokogiri/version/constant.rb +1 -1
  92. data/lib/nokogiri/xml/builder.rb +8 -1
  93. data/lib/nokogiri/xml/document.rb +70 -26
  94. data/lib/nokogiri/xml/document_fragment.rb +84 -13
  95. data/lib/nokogiri/xml/node.rb +82 -11
  96. data/lib/nokogiri/xml/node_set.rb +9 -7
  97. data/lib/nokogiri/xml/parse_options.rb +1 -1
  98. data/lib/nokogiri/xml/pp/node.rb +6 -1
  99. data/lib/nokogiri/xml/reader.rb +46 -13
  100. data/lib/nokogiri/xml/relax_ng.rb +57 -20
  101. data/lib/nokogiri/xml/sax/document.rb +174 -83
  102. data/lib/nokogiri/xml/sax/parser.rb +115 -41
  103. data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
  104. data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
  105. data/lib/nokogiri/xml/sax.rb +48 -0
  106. data/lib/nokogiri/xml/schema.rb +112 -45
  107. data/lib/nokogiri/xml/searchable.rb +6 -8
  108. data/lib/nokogiri/xml/syntax_error.rb +22 -0
  109. data/lib/nokogiri/xml.rb +13 -24
  110. data/lib/nokogiri/xslt.rb +3 -9
  111. data/lib/xsd/xmlparser/nokogiri.rb +3 -4
  112. metadata +8 -4
  113. data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
@@ -2,62 +2,92 @@
2
2
 
3
3
  VALUE cNokogiriXmlSaxParser ;
4
4
 
5
- static ID id_start_document, id_end_document, id_start_element, id_end_element;
6
- static ID id_start_element_namespace, id_end_element_namespace;
7
- static ID id_comment, id_characters, id_xmldecl, id_error, id_warning;
5
+ static ID id_start_document;
6
+ static ID id_end_document;
7
+ static ID id_start_element;
8
+ static ID id_end_element;
9
+ static ID id_start_element_namespace;
10
+ static ID id_end_element_namespace;
11
+ static ID id_comment;
12
+ static ID id_characters;
13
+ static ID id_xmldecl;
14
+ static ID id_error;
15
+ static ID id_warning;
8
16
  static ID id_cdata_block;
9
17
  static ID id_processing_instruction;
18
+ static ID id_reference;
19
+
20
+ static size_t
21
+ xml_sax_parser_memsize(const void *data)
22
+ {
23
+ return sizeof(xmlSAXHandler);
24
+ }
25
+
26
+ /* Used by Nokogiri::XML::SAX::Parser and Nokogiri::HTML::SAX::Parser */
27
+ static const rb_data_type_t xml_sax_parser_type = {
28
+ .wrap_struct_name = "xmlSAXHandler",
29
+ .function = {
30
+ .dfree = RUBY_TYPED_DEFAULT_FREE,
31
+ .dsize = xml_sax_parser_memsize
32
+ },
33
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
34
+ };
10
35
 
11
36
  static void
12
- start_document(void *ctx)
37
+ noko_xml_sax_parser_start_document_callback(void *ctx)
13
38
  {
14
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
39
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
40
+ VALUE self = (VALUE)ctxt->_private;
15
41
  VALUE doc = rb_iv_get(self, "@document");
16
42
 
17
- xmlParserCtxtPtr ctxt = NOKOGIRI_SAX_CTXT(ctx);
18
-
19
- if (NULL != ctxt && ctxt->html != 1) {
20
- if (ctxt->standalone != -1) { /* -1 means there was no declaration */
21
- VALUE encoding = Qnil ;
22
- VALUE standalone = Qnil;
23
- VALUE version;
24
- if (ctxt->encoding) {
25
- encoding = NOKOGIRI_STR_NEW2(ctxt->encoding) ;
26
- } else if (ctxt->input && ctxt->input->encoding) {
27
- encoding = NOKOGIRI_STR_NEW2(ctxt->input->encoding) ;
28
- }
29
-
30
- version = ctxt->version ? NOKOGIRI_STR_NEW2(ctxt->version) : Qnil;
31
-
32
- switch (ctxt->standalone) {
33
- case 0:
34
- standalone = NOKOGIRI_STR_NEW2("no");
35
- break;
36
- case 1:
37
- standalone = NOKOGIRI_STR_NEW2("yes");
38
- break;
39
- }
40
-
41
- rb_funcall(doc, id_xmldecl, 3, version, encoding, standalone);
43
+ xmlSAX2StartDocument(ctx);
44
+
45
+ if (ctxt->standalone != -1) { /* -1 means there was no declaration */
46
+ VALUE encoding = Qnil ;
47
+ VALUE standalone = Qnil;
48
+ VALUE version;
49
+
50
+ if (ctxt->encoding) {
51
+ encoding = NOKOGIRI_STR_NEW2(ctxt->encoding) ;
52
+ } else if (ctxt->input && ctxt->input->encoding) { // unnecessary after v2.12.0 / gnome/libxml2@ec7be506
53
+ encoding = NOKOGIRI_STR_NEW2(ctxt->input->encoding) ;
54
+ }
55
+
56
+ version = ctxt->version ? NOKOGIRI_STR_NEW2(ctxt->version) : Qnil;
57
+
58
+ /* TODO try using xmlSAX2IsStandalone */
59
+ switch (ctxt->standalone) {
60
+ case 0:
61
+ standalone = NOKOGIRI_STR_NEW2("no");
62
+ break;
63
+ case 1:
64
+ standalone = NOKOGIRI_STR_NEW2("yes");
65
+ break;
42
66
  }
67
+
68
+ rb_funcall(doc, id_xmldecl, 3, version, encoding, standalone);
43
69
  }
44
70
 
45
71
  rb_funcall(doc, id_start_document, 0);
46
72
  }
47
73
 
48
74
  static void
49
- end_document(void *ctx)
75
+ noko_xml_sax_parser_end_document_callback(void *ctx)
50
76
  {
51
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
77
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
78
+ VALUE self = (VALUE)ctxt->_private;
52
79
  VALUE doc = rb_iv_get(self, "@document");
80
+
53
81
  rb_funcall(doc, id_end_document, 0);
54
82
  }
55
83
 
56
84
  static void
57
- start_element(void *ctx, const xmlChar *name, const xmlChar **atts)
85
+ noko_xml_sax_parser_start_element_callback(void *ctx, const xmlChar *name, const xmlChar **atts)
58
86
  {
59
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
87
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
88
+ VALUE self = (VALUE)ctxt->_private;
60
89
  VALUE doc = rb_iv_get(self, "@document");
90
+
61
91
  VALUE attributes = rb_ary_new();
62
92
  const xmlChar *attr;
63
93
  int i = 0;
@@ -79,15 +109,17 @@ start_element(void *ctx, const xmlChar *name, const xmlChar **atts)
79
109
  }
80
110
 
81
111
  static void
82
- end_element(void *ctx, const xmlChar *name)
112
+ noko_xml_sax_parser_end_element_callback(void *ctx, const xmlChar *name)
83
113
  {
84
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
114
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
115
+ VALUE self = (VALUE)ctxt->_private;
85
116
  VALUE doc = rb_iv_get(self, "@document");
117
+
86
118
  rb_funcall(doc, id_end_element, 1, NOKOGIRI_STR_NEW2(name));
87
119
  }
88
120
 
89
121
  static VALUE
90
- attributes_as_array(int attributes_len, const xmlChar **c_attributes)
122
+ xml_sax_parser_marshal_attributes(int attributes_len, const xmlChar **c_attributes)
91
123
  {
92
124
  VALUE rb_array = rb_ary_new2((long)attributes_len);
93
125
  VALUE cNokogiriXmlSaxParserAttribute;
@@ -116,7 +148,7 @@ attributes_as_array(int attributes_len, const xmlChar **c_attributes)
116
148
  }
117
149
 
118
150
  static void
119
- start_element_ns(
151
+ noko_xml_sax_parser_start_element_ns_callback(
120
152
  void *ctx,
121
153
  const xmlChar *localname,
122
154
  const xmlChar *prefix,
@@ -127,10 +159,11 @@ start_element_ns(
127
159
  int nb_defaulted,
128
160
  const xmlChar **attributes)
129
161
  {
130
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
162
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
163
+ VALUE self = (VALUE)ctxt->_private;
131
164
  VALUE doc = rb_iv_get(self, "@document");
132
165
 
133
- VALUE attribute_ary = attributes_as_array(nb_attributes, attributes);
166
+ VALUE attribute_ary = xml_sax_parser_marshal_attributes(nb_attributes, attributes);
134
167
 
135
168
  VALUE ns_list = rb_ary_new2((long)nb_namespaces);
136
169
 
@@ -161,13 +194,14 @@ start_element_ns(
161
194
  * end_element_ns was borrowed heavily from libxml-ruby.
162
195
  */
163
196
  static void
164
- end_element_ns(
197
+ noko_xml_sax_parser_end_element_ns_callback(
165
198
  void *ctx,
166
199
  const xmlChar *localname,
167
200
  const xmlChar *prefix,
168
201
  const xmlChar *uri)
169
202
  {
170
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
203
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
204
+ VALUE self = (VALUE)ctxt->_private;
171
205
  VALUE doc = rb_iv_get(self, "@document");
172
206
 
173
207
  rb_funcall(doc, id_end_element_namespace, 3,
@@ -178,29 +212,35 @@ end_element_ns(
178
212
  }
179
213
 
180
214
  static void
181
- characters_func(void *ctx, const xmlChar *ch, int len)
215
+ noko_xml_sax_parser_characters_callback(void *ctx, const xmlChar *ch, int len)
182
216
  {
183
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
217
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
218
+ VALUE self = (VALUE)ctxt->_private;
184
219
  VALUE doc = rb_iv_get(self, "@document");
220
+
185
221
  VALUE str = NOKOGIRI_STR_NEW(ch, len);
186
222
  rb_funcall(doc, id_characters, 1, str);
187
223
  }
188
224
 
189
225
  static void
190
- comment_func(void *ctx, const xmlChar *value)
226
+ noko_xml_sax_parser_comment_callback(void *ctx, const xmlChar *value)
191
227
  {
192
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
228
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
229
+ VALUE self = (VALUE)ctxt->_private;
193
230
  VALUE doc = rb_iv_get(self, "@document");
231
+
194
232
  VALUE str = NOKOGIRI_STR_NEW2(value);
195
233
  rb_funcall(doc, id_comment, 1, str);
196
234
  }
197
235
 
198
236
  PRINTFLIKE_DECL(2, 3)
199
237
  static void
200
- warning_func(void *ctx, const char *msg, ...)
238
+ noko_xml_sax_parser_warning_callback(void *ctx, const char *msg, ...)
201
239
  {
202
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
240
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
241
+ VALUE self = (VALUE)ctxt->_private;
203
242
  VALUE doc = rb_iv_get(self, "@document");
243
+
204
244
  VALUE rb_message;
205
245
 
206
246
  #ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
@@ -219,10 +259,12 @@ warning_func(void *ctx, const char *msg, ...)
219
259
 
220
260
  PRINTFLIKE_DECL(2, 3)
221
261
  static void
222
- error_func(void *ctx, const char *msg, ...)
262
+ noko_xml_sax_parser_error_callback(void *ctx, const char *msg, ...)
223
263
  {
224
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
264
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
265
+ VALUE self = (VALUE)ctxt->_private;
225
266
  VALUE doc = rb_iv_get(self, "@document");
267
+
226
268
  VALUE rb_message;
227
269
 
228
270
  #ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
@@ -240,22 +282,24 @@ error_func(void *ctx, const char *msg, ...)
240
282
  }
241
283
 
242
284
  static void
243
- cdata_block(void *ctx, const xmlChar *value, int len)
285
+ noko_xml_sax_parser_cdata_block_callback(void *ctx, const xmlChar *value, int len)
244
286
  {
245
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
287
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
288
+ VALUE self = (VALUE)ctxt->_private;
246
289
  VALUE doc = rb_iv_get(self, "@document");
290
+
247
291
  VALUE string = NOKOGIRI_STR_NEW(value, len);
248
292
  rb_funcall(doc, id_cdata_block, 1, string);
249
293
  }
250
294
 
251
295
  static void
252
- processing_instruction(void *ctx, const xmlChar *name, const xmlChar *content)
296
+ noko_xml_sax_parser_processing_instruction_callback(void *ctx, const xmlChar *name, const xmlChar *content)
253
297
  {
254
- VALUE rb_content;
255
- VALUE self = NOKOGIRI_SAX_SELF(ctx);
298
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
299
+ VALUE self = (VALUE)ctxt->_private;
256
300
  VALUE doc = rb_iv_get(self, "@document");
257
301
 
258
- rb_content = content ? NOKOGIRI_STR_NEW2(content) : Qnil;
302
+ VALUE rb_content = content ? NOKOGIRI_STR_NEW2(content) : Qnil;
259
303
 
260
304
  rb_funcall(doc,
261
305
  id_processing_instruction,
@@ -265,50 +309,70 @@ processing_instruction(void *ctx, const xmlChar *name, const xmlChar *content)
265
309
  );
266
310
  }
267
311
 
268
- static size_t
269
- memsize(const void *data)
312
+ static void
313
+ noko_xml_sax_parser_reference_callback(void *ctx, const xmlChar *name)
270
314
  {
271
- return sizeof(xmlSAXHandler);
272
- }
315
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctx;
316
+ xmlEntityPtr entity = xmlSAX2GetEntity(ctxt, name);
273
317
 
274
- /* Used by Nokogiri::XML::SAX::Parser and Nokogiri::HTML::SAX::Parser */
275
- static const rb_data_type_t noko_sax_handler_type = {
276
- .wrap_struct_name = "Nokogiri::SAXHandler",
277
- .function = {
278
- .dfree = RUBY_TYPED_DEFAULT_FREE,
279
- .dsize = memsize
280
- },
281
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
282
- };
318
+ VALUE self = (VALUE)ctxt->_private;
319
+ VALUE doc = rb_iv_get(self, "@document");
320
+
321
+ if (entity && entity->content) {
322
+ rb_funcall(doc, id_reference, 2, NOKOGIRI_STR_NEW2(entity->name), NOKOGIRI_STR_NEW2(entity->content));
323
+ } else {
324
+ rb_funcall(doc, id_reference, 2, NOKOGIRI_STR_NEW2(name), Qnil);
325
+ }
326
+ }
283
327
 
284
328
  static VALUE
285
- allocate(VALUE klass)
329
+ noko_xml_sax_parser__initialize_native(VALUE self)
286
330
  {
287
- xmlSAXHandlerPtr handler;
288
- VALUE self = TypedData_Make_Struct(klass, xmlSAXHandler, &noko_sax_handler_type, handler);
289
-
290
- handler->startDocument = start_document;
291
- handler->endDocument = end_document;
292
- handler->startElement = start_element;
293
- handler->endElement = end_element;
294
- handler->startElementNs = start_element_ns;
295
- handler->endElementNs = end_element_ns;
296
- handler->characters = characters_func;
297
- handler->comment = comment_func;
298
- handler->warning = warning_func;
299
- handler->error = error_func;
300
- handler->cdataBlock = cdata_block;
301
- handler->processingInstruction = processing_instruction;
331
+ xmlSAXHandlerPtr handler = noko_xml_sax_parser_unwrap(self);
332
+
333
+ handler->startDocument = noko_xml_sax_parser_start_document_callback;
334
+ handler->endDocument = noko_xml_sax_parser_end_document_callback;
335
+ handler->startElement = noko_xml_sax_parser_start_element_callback;
336
+ handler->endElement = noko_xml_sax_parser_end_element_callback;
337
+ handler->startElementNs = noko_xml_sax_parser_start_element_ns_callback;
338
+ handler->endElementNs = noko_xml_sax_parser_end_element_ns_callback;
339
+ handler->characters = noko_xml_sax_parser_characters_callback;
340
+ handler->comment = noko_xml_sax_parser_comment_callback;
341
+ handler->warning = noko_xml_sax_parser_warning_callback;
342
+ handler->error = noko_xml_sax_parser_error_callback;
343
+ handler->cdataBlock = noko_xml_sax_parser_cdata_block_callback;
344
+ handler->processingInstruction = noko_xml_sax_parser_processing_instruction_callback;
345
+ handler->reference = noko_xml_sax_parser_reference_callback;
346
+
347
+ /* use some of libxml2's default callbacks to managed DTDs and entities */
348
+ handler->getEntity = xmlSAX2GetEntity;
349
+ handler->internalSubset = xmlSAX2InternalSubset;
350
+ handler->externalSubset = xmlSAX2ExternalSubset;
351
+ handler->isStandalone = xmlSAX2IsStandalone;
352
+ handler->hasInternalSubset = xmlSAX2HasInternalSubset;
353
+ handler->hasExternalSubset = xmlSAX2HasExternalSubset;
354
+ handler->resolveEntity = xmlSAX2ResolveEntity;
355
+ handler->getParameterEntity = xmlSAX2GetParameterEntity;
356
+ handler->entityDecl = xmlSAX2EntityDecl;
357
+ handler->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
358
+
302
359
  handler->initialized = XML_SAX2_MAGIC;
303
360
 
304
361
  return self;
305
362
  }
306
363
 
364
+ static VALUE
365
+ noko_xml_sax_parser_allocate(VALUE klass)
366
+ {
367
+ xmlSAXHandlerPtr handler;
368
+ return TypedData_Make_Struct(klass, xmlSAXHandler, &xml_sax_parser_type, handler);
369
+ }
370
+
307
371
  xmlSAXHandlerPtr
308
- noko_sax_handler_unwrap(VALUE rb_sax_handler)
372
+ noko_xml_sax_parser_unwrap(VALUE rb_sax_handler)
309
373
  {
310
374
  xmlSAXHandlerPtr c_sax_handler;
311
- TypedData_Get_Struct(rb_sax_handler, xmlSAXHandler, &noko_sax_handler_type, c_sax_handler);
375
+ TypedData_Get_Struct(rb_sax_handler, xmlSAXHandler, &xml_sax_parser_type, c_sax_handler);
312
376
  return c_sax_handler;
313
377
  }
314
378
 
@@ -317,7 +381,10 @@ noko_init_xml_sax_parser(void)
317
381
  {
318
382
  cNokogiriXmlSaxParser = rb_define_class_under(mNokogiriXmlSax, "Parser", rb_cObject);
319
383
 
320
- rb_define_alloc_func(cNokogiriXmlSaxParser, allocate);
384
+ rb_define_alloc_func(cNokogiriXmlSaxParser, noko_xml_sax_parser_allocate);
385
+
386
+ rb_define_private_method(cNokogiriXmlSaxParser, "initialize_native",
387
+ noko_xml_sax_parser__initialize_native, 0);
321
388
 
322
389
  id_start_document = rb_intern("start_document");
323
390
  id_end_document = rb_intern("end_document");
@@ -332,4 +399,5 @@ noko_init_xml_sax_parser(void)
332
399
  id_start_element_namespace = rb_intern("start_element_namespace");
333
400
  id_end_element_namespace = rb_intern("end_element_namespace");
334
401
  id_processing_instruction = rb_intern("processing_instruction");
402
+ id_reference = rb_intern("reference");
335
403
  }