nokogiri-backport 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +1682 -0
- data/LICENSE.md +9 -0
- data/README.md +272 -0
- data/bin/nokogiri +118 -0
- data/dependencies.yml +74 -0
- data/ext/java/nokogiri/EncodingHandler.java +124 -0
- data/ext/java/nokogiri/HtmlDocument.java +178 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +148 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +79 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +282 -0
- data/ext/java/nokogiri/HtmlSaxPushParser.java +222 -0
- data/ext/java/nokogiri/NokogiriService.java +597 -0
- data/ext/java/nokogiri/XmlAttr.java +162 -0
- data/ext/java/nokogiri/XmlAttributeDecl.java +129 -0
- data/ext/java/nokogiri/XmlCdata.java +82 -0
- data/ext/java/nokogiri/XmlComment.java +97 -0
- data/ext/java/nokogiri/XmlDocument.java +633 -0
- data/ext/java/nokogiri/XmlDocumentFragment.java +185 -0
- data/ext/java/nokogiri/XmlDtd.java +481 -0
- data/ext/java/nokogiri/XmlElement.java +68 -0
- data/ext/java/nokogiri/XmlElementContent.java +382 -0
- data/ext/java/nokogiri/XmlElementDecl.java +147 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +157 -0
- data/ext/java/nokogiri/XmlEntityReference.java +101 -0
- data/ext/java/nokogiri/XmlNamespace.java +199 -0
- data/ext/java/nokogiri/XmlNode.java +1684 -0
- data/ext/java/nokogiri/XmlNodeSet.java +434 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +100 -0
- data/ext/java/nokogiri/XmlReader.java +531 -0
- data/ext/java/nokogiri/XmlRelaxng.java +151 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +374 -0
- data/ext/java/nokogiri/XmlSaxPushParser.java +286 -0
- data/ext/java/nokogiri/XmlSchema.java +388 -0
- data/ext/java/nokogiri/XmlSyntaxError.java +138 -0
- data/ext/java/nokogiri/XmlText.java +110 -0
- data/ext/java/nokogiri/XmlXpathContext.java +301 -0
- data/ext/java/nokogiri/XsltStylesheet.java +347 -0
- data/ext/java/nokogiri/internals/ClosedStreamException.java +10 -0
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +252 -0
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +20 -0
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +151 -0
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +116 -0
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +121 -0
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +69 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +327 -0
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +734 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +217 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +127 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +100 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +121 -0
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +78 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +180 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +72 -0
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +60 -0
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +87 -0
- data/ext/java/nokogiri/internals/ParserContext.java +259 -0
- data/ext/java/nokogiri/internals/ReaderNode.java +488 -0
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +778 -0
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +73 -0
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +168 -0
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +42 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +274 -0
- data/ext/java/nokogiri/internals/XmlSaxParser.java +65 -0
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +119 -0
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +159 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +37 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +93 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +252 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +639 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +367 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +295 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +40 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +43 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +630 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +173 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +76 -0
- data/ext/java/nokogiri/internals/c14n/Constants.java +42 -0
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +293 -0
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +93 -0
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +79 -0
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +166 -0
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +76 -0
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +402 -0
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +51 -0
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +179 -0
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +507 -0
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1745 -0
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +685 -0
- data/ext/nokogiri/depend +477 -0
- data/ext/nokogiri/extconf.rb +836 -0
- data/ext/nokogiri/html_document.c +171 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +279 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +116 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/html_sax_push_parser.c +87 -0
- data/ext/nokogiri/html_sax_push_parser.h +9 -0
- data/ext/nokogiri/nokogiri.c +135 -0
- data/ext/nokogiri/nokogiri.h +130 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +62 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +69 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +622 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +63 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +111 -0
- data/ext/nokogiri/xml_namespace.h +14 -0
- data/ext/nokogiri/xml_node.c +1773 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +486 -0
- data/ext/nokogiri/xml_node_set.h +12 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +657 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +179 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +305 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +262 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +159 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +276 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +64 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +52 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +374 -0
- data/ext/nokogiri/xml_xpath_context.h +10 -0
- data/ext/nokogiri/xslt_stylesheet.c +263 -0
- data/ext/nokogiri/xslt_stylesheet.h +14 -0
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/nokogiri/css/node.rb +53 -0
- data/lib/nokogiri/css/parser.rb +751 -0
- data/lib/nokogiri/css/parser.y +272 -0
- data/lib/nokogiri/css/parser_extras.rb +94 -0
- data/lib/nokogiri/css/syntax_error.rb +8 -0
- data/lib/nokogiri/css/tokenizer.rb +154 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +260 -0
- data/lib/nokogiri/css.rb +28 -0
- data/lib/nokogiri/decorators/slop.rb +43 -0
- data/lib/nokogiri/html/builder.rb +36 -0
- data/lib/nokogiri/html/document.rb +322 -0
- data/lib/nokogiri/html/document_fragment.rb +50 -0
- data/lib/nokogiri/html/element_description.rb +24 -0
- data/lib/nokogiri/html/element_description_defaults.rb +672 -0
- data/lib/nokogiri/html/entity_lookup.rb +14 -0
- data/lib/nokogiri/html/sax/parser.rb +63 -0
- data/lib/nokogiri/html/sax/parser_context.rb +17 -0
- data/lib/nokogiri/html/sax/push_parser.rb +37 -0
- data/lib/nokogiri/html.rb +38 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +5 -0
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/xml/attr.rb +15 -0
- data/lib/nokogiri/xml/attribute_decl.rb +19 -0
- data/lib/nokogiri/xml/builder.rb +447 -0
- data/lib/nokogiri/xml/cdata.rb +12 -0
- data/lib/nokogiri/xml/character_data.rb +8 -0
- data/lib/nokogiri/xml/document.rb +290 -0
- data/lib/nokogiri/xml/document_fragment.rb +159 -0
- data/lib/nokogiri/xml/dtd.rb +33 -0
- data/lib/nokogiri/xml/element_content.rb +37 -0
- data/lib/nokogiri/xml/element_decl.rb +14 -0
- data/lib/nokogiri/xml/entity_decl.rb +20 -0
- data/lib/nokogiri/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +14 -0
- data/lib/nokogiri/xml/node/save_options.rb +62 -0
- data/lib/nokogiri/xml/node.rb +1240 -0
- data/lib/nokogiri/xml/node_set.rb +372 -0
- data/lib/nokogiri/xml/notation.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +127 -0
- data/lib/nokogiri/xml/pp/character_data.rb +19 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/pp.rb +3 -0
- data/lib/nokogiri/xml/processing_instruction.rb +9 -0
- data/lib/nokogiri/xml/reader.rb +116 -0
- data/lib/nokogiri/xml/relax_ng.rb +37 -0
- data/lib/nokogiri/xml/sax/document.rb +172 -0
- data/lib/nokogiri/xml/sax/parser.rb +123 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/sax.rb +5 -0
- data/lib/nokogiri/xml/schema.rb +72 -0
- data/lib/nokogiri/xml/searchable.rb +239 -0
- data/lib/nokogiri/xml/syntax_error.rb +71 -0
- data/lib/nokogiri/xml/text.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
- data/lib/nokogiri/xml/xpath.rb +11 -0
- data/lib/nokogiri/xml/xpath_context.rb +17 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xslt/stylesheet.rb +26 -0
- data/lib/nokogiri/xslt.rb +57 -0
- data/lib/nokogiri.rb +144 -0
- data/lib/serializer.jar +0 -0
- data/lib/xalan.jar +0 -0
- data/lib/xercesImpl.jar +0 -0
- data/lib/xml-apis.jar +0 -0
- data/lib/xsd/xmlparser/nokogiri.rb +103 -0
- metadata +531 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
#include <html_sax_push_parser.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* native_write(chunk, last_chunk)
|
6
|
+
*
|
7
|
+
* Write +chunk+ to PushParser. +last_chunk+ triggers the end_document handle
|
8
|
+
*/
|
9
|
+
static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
|
10
|
+
{
|
11
|
+
xmlParserCtxtPtr ctx;
|
12
|
+
const char * chunk = NULL;
|
13
|
+
int size = 0;
|
14
|
+
|
15
|
+
|
16
|
+
Data_Get_Struct(self, xmlParserCtxt, ctx);
|
17
|
+
|
18
|
+
if(Qnil != _chunk) {
|
19
|
+
chunk = StringValuePtr(_chunk);
|
20
|
+
size = (int)RSTRING_LEN(_chunk);
|
21
|
+
}
|
22
|
+
|
23
|
+
if(htmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
|
24
|
+
if (!(ctx->options & XML_PARSE_RECOVER)) {
|
25
|
+
xmlErrorPtr e = xmlCtxtGetLastError(ctx);
|
26
|
+
Nokogiri_error_raise(NULL, e);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return self;
|
31
|
+
}
|
32
|
+
|
33
|
+
/*
|
34
|
+
* call-seq:
|
35
|
+
* initialize_native(xml_sax, filename)
|
36
|
+
*
|
37
|
+
* Initialize the push parser with +xml_sax+ using +filename+
|
38
|
+
*/
|
39
|
+
static VALUE initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename,
|
40
|
+
VALUE encoding)
|
41
|
+
{
|
42
|
+
htmlSAXHandlerPtr sax;
|
43
|
+
const char * filename = NULL;
|
44
|
+
htmlParserCtxtPtr ctx;
|
45
|
+
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
46
|
+
|
47
|
+
Data_Get_Struct(_xml_sax, xmlSAXHandler, sax);
|
48
|
+
|
49
|
+
if(_filename != Qnil) filename = StringValueCStr(_filename);
|
50
|
+
|
51
|
+
if (!NIL_P(encoding)) {
|
52
|
+
enc = xmlParseCharEncoding(StringValueCStr(encoding));
|
53
|
+
if (enc == XML_CHAR_ENCODING_ERROR)
|
54
|
+
rb_raise(rb_eArgError, "Unsupported Encoding");
|
55
|
+
}
|
56
|
+
|
57
|
+
ctx = htmlCreatePushParserCtxt(
|
58
|
+
sax,
|
59
|
+
NULL,
|
60
|
+
NULL,
|
61
|
+
0,
|
62
|
+
filename,
|
63
|
+
enc
|
64
|
+
);
|
65
|
+
if(ctx == NULL)
|
66
|
+
rb_raise(rb_eRuntimeError, "Could not create a parser context");
|
67
|
+
|
68
|
+
ctx->userData = NOKOGIRI_SAX_TUPLE_NEW(ctx, self);
|
69
|
+
|
70
|
+
ctx->sax2 = 1;
|
71
|
+
DATA_PTR(self) = ctx;
|
72
|
+
return self;
|
73
|
+
}
|
74
|
+
|
75
|
+
VALUE cNokogiriHtmlSaxPushParser;
|
76
|
+
void init_html_sax_push_parser()
|
77
|
+
{
|
78
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
79
|
+
VALUE html = rb_define_module_under(nokogiri, "HTML");
|
80
|
+
VALUE sax = rb_define_module_under(html, "SAX");
|
81
|
+
VALUE klass = rb_define_class_under(sax, "PushParser", cNokogiriXmlSaxPushParser);
|
82
|
+
|
83
|
+
cNokogiriHtmlSaxPushParser = klass;
|
84
|
+
|
85
|
+
rb_define_private_method(klass, "initialize_native", initialize_native, 3);
|
86
|
+
rb_define_private_method(klass, "native_write", native_write, 2);
|
87
|
+
}
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE mNokogiri ;
|
4
|
+
VALUE mNokogiriXml ;
|
5
|
+
VALUE mNokogiriHtml ;
|
6
|
+
VALUE mNokogiriXslt ;
|
7
|
+
VALUE mNokogiriXmlSax ;
|
8
|
+
VALUE mNokogiriHtmlSax ;
|
9
|
+
|
10
|
+
#ifndef HAVE_VASPRINTF
|
11
|
+
/*
|
12
|
+
* Thank you Geoffroy Couprie for this implementation of vasprintf!
|
13
|
+
*/
|
14
|
+
int vasprintf(char **strp, const char *fmt, va_list ap)
|
15
|
+
{
|
16
|
+
/* Mingw32/64 have a broken vsnprintf implementation that fails when
|
17
|
+
* using a zero-byte limit in order to retrieve the required size for malloc.
|
18
|
+
* So we use a one byte buffer instead.
|
19
|
+
*/
|
20
|
+
char tmp[1];
|
21
|
+
int len = vsnprintf (tmp, 1, fmt, ap) + 1;
|
22
|
+
char *res = (char *)malloc((unsigned int)len);
|
23
|
+
if (res == NULL) {
|
24
|
+
return -1;
|
25
|
+
}
|
26
|
+
*strp = res;
|
27
|
+
return vsnprintf(res, (unsigned int)len, fmt, ap);
|
28
|
+
}
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#include "ruby/util.h"
|
32
|
+
|
33
|
+
void nokogiri_root_node(xmlNodePtr node)
|
34
|
+
{
|
35
|
+
xmlDocPtr doc;
|
36
|
+
nokogiriTuplePtr tuple;
|
37
|
+
|
38
|
+
doc = node->doc;
|
39
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
|
40
|
+
tuple = (nokogiriTuplePtr)doc->_private;
|
41
|
+
st_insert(tuple->unlinkedNodes, (st_data_t)node, (st_data_t)node);
|
42
|
+
}
|
43
|
+
|
44
|
+
void nokogiri_root_nsdef(xmlNsPtr ns, xmlDocPtr doc)
|
45
|
+
{
|
46
|
+
nokogiriTuplePtr tuple;
|
47
|
+
|
48
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
|
49
|
+
tuple = (nokogiriTuplePtr)doc->_private;
|
50
|
+
st_insert(tuple->unlinkedNodes, (st_data_t)ns, (st_data_t)ns);
|
51
|
+
}
|
52
|
+
|
53
|
+
void Init_nokogiri()
|
54
|
+
{
|
55
|
+
xmlMemSetup(
|
56
|
+
(xmlFreeFunc)ruby_xfree,
|
57
|
+
(xmlMallocFunc)ruby_xmalloc,
|
58
|
+
(xmlReallocFunc)ruby_xrealloc,
|
59
|
+
ruby_strdup
|
60
|
+
);
|
61
|
+
|
62
|
+
mNokogiri = rb_define_module("Nokogiri");
|
63
|
+
mNokogiriXml = rb_define_module_under(mNokogiri, "XML");
|
64
|
+
mNokogiriHtml = rb_define_module_under(mNokogiri, "HTML");
|
65
|
+
mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT");
|
66
|
+
mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
|
67
|
+
mNokogiriHtmlSax = rb_define_module_under(mNokogiriHtml, "SAX");
|
68
|
+
|
69
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION));
|
70
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion));
|
71
|
+
|
72
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
73
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
74
|
+
|
75
|
+
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
76
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
77
|
+
#ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
78
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qtrue);
|
79
|
+
#else
|
80
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
81
|
+
#endif
|
82
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
83
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
84
|
+
#else
|
85
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qfalse);
|
86
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
87
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), Qnil);
|
88
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), Qnil);
|
89
|
+
#endif
|
90
|
+
|
91
|
+
#ifdef LIBXML_ICONV_ENABLED
|
92
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue);
|
93
|
+
#else
|
94
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
95
|
+
#endif
|
96
|
+
|
97
|
+
#ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
|
98
|
+
rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
|
99
|
+
#endif
|
100
|
+
|
101
|
+
xmlInitParser();
|
102
|
+
|
103
|
+
init_xml_document();
|
104
|
+
init_html_document();
|
105
|
+
init_xml_node();
|
106
|
+
init_xml_document_fragment();
|
107
|
+
init_xml_text();
|
108
|
+
init_xml_cdata();
|
109
|
+
init_xml_processing_instruction();
|
110
|
+
init_xml_attr();
|
111
|
+
init_xml_entity_reference();
|
112
|
+
init_xml_comment();
|
113
|
+
init_xml_node_set();
|
114
|
+
init_xml_xpath_context();
|
115
|
+
init_xml_sax_parser_context();
|
116
|
+
init_xml_sax_parser();
|
117
|
+
init_xml_sax_push_parser();
|
118
|
+
init_xml_reader();
|
119
|
+
init_xml_dtd();
|
120
|
+
init_xml_element_content();
|
121
|
+
init_xml_attribute_decl();
|
122
|
+
init_xml_element_decl();
|
123
|
+
init_xml_entity_decl();
|
124
|
+
init_xml_namespace();
|
125
|
+
init_html_sax_parser_context();
|
126
|
+
init_html_sax_push_parser();
|
127
|
+
init_xslt_stylesheet();
|
128
|
+
init_xml_syntax_error();
|
129
|
+
init_html_entity_lookup();
|
130
|
+
init_html_element_description();
|
131
|
+
init_xml_schema();
|
132
|
+
init_xml_relax_ng();
|
133
|
+
init_nokogiri_io();
|
134
|
+
init_xml_encoding_handler();
|
135
|
+
}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#ifndef NOKOGIRI_NATIVE
|
2
|
+
#define NOKOGIRI_NATIVE
|
3
|
+
|
4
|
+
#if _MSC_VER
|
5
|
+
# ifndef WIN32_LEAN_AND_MEAN
|
6
|
+
# define WIN32_LEAN_AND_MEAN
|
7
|
+
# endif /* WIN32_LEAN_AND_MEAN */
|
8
|
+
|
9
|
+
# ifndef WIN32
|
10
|
+
# define WIN32
|
11
|
+
# endif /* WIN32 */
|
12
|
+
|
13
|
+
# include <winsock2.h>
|
14
|
+
# include <ws2tcpip.h>
|
15
|
+
# include <windows.h>
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#include <stdlib.h>
|
19
|
+
#include <string.h>
|
20
|
+
#include <assert.h>
|
21
|
+
#include <stdarg.h>
|
22
|
+
#include <stdio.h>
|
23
|
+
|
24
|
+
#include <libxml/parser.h>
|
25
|
+
#include <libxml/entities.h>
|
26
|
+
#include <libxml/parserInternals.h>
|
27
|
+
#include <libxml/xpath.h>
|
28
|
+
#include <libxml/xpathInternals.h>
|
29
|
+
#include <libxml/xmlreader.h>
|
30
|
+
#include <libxml/xmlsave.h>
|
31
|
+
#include <libxml/xmlschemas.h>
|
32
|
+
#include <libxml/HTMLparser.h>
|
33
|
+
#include <libxml/HTMLtree.h>
|
34
|
+
#include <libxml/relaxng.h>
|
35
|
+
#include <libxml/xinclude.h>
|
36
|
+
#include <libxslt/extensions.h>
|
37
|
+
#include <libxslt/xsltconfig.h>
|
38
|
+
#include <libxml/c14n.h>
|
39
|
+
|
40
|
+
#include <ruby.h>
|
41
|
+
#include <ruby/st.h>
|
42
|
+
#include <ruby/encoding.h>
|
43
|
+
|
44
|
+
#ifndef NORETURN
|
45
|
+
# if defined(__GNUC__)
|
46
|
+
# define NORETURN(name) __attribute__((noreturn)) name
|
47
|
+
# else
|
48
|
+
# define NORETURN(name) name
|
49
|
+
# endif
|
50
|
+
#endif
|
51
|
+
|
52
|
+
#define NOKOGIRI_STR_NEW2(str) \
|
53
|
+
NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
|
54
|
+
|
55
|
+
#define NOKOGIRI_STR_NEW(str, len) \
|
56
|
+
rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
|
57
|
+
|
58
|
+
#define RBSTR_OR_QNIL(_str) \
|
59
|
+
(_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
60
|
+
|
61
|
+
#include <xml_libxml2_hacks.h>
|
62
|
+
|
63
|
+
#include <xml_io.h>
|
64
|
+
#include <xml_document.h>
|
65
|
+
#include <html_entity_lookup.h>
|
66
|
+
#include <html_document.h>
|
67
|
+
#include <xml_node.h>
|
68
|
+
#include <xml_text.h>
|
69
|
+
#include <xml_cdata.h>
|
70
|
+
#include <xml_attr.h>
|
71
|
+
#include <xml_processing_instruction.h>
|
72
|
+
#include <xml_entity_reference.h>
|
73
|
+
#include <xml_document_fragment.h>
|
74
|
+
#include <xml_comment.h>
|
75
|
+
#include <xml_node_set.h>
|
76
|
+
#include <xml_dtd.h>
|
77
|
+
#include <xml_attribute_decl.h>
|
78
|
+
#include <xml_element_decl.h>
|
79
|
+
#include <xml_entity_decl.h>
|
80
|
+
#include <xml_xpath_context.h>
|
81
|
+
#include <xml_element_content.h>
|
82
|
+
#include <xml_sax_parser_context.h>
|
83
|
+
#include <xml_sax_parser.h>
|
84
|
+
#include <xml_sax_push_parser.h>
|
85
|
+
#include <xml_reader.h>
|
86
|
+
#include <html_sax_parser_context.h>
|
87
|
+
#include <html_sax_push_parser.h>
|
88
|
+
#include <xslt_stylesheet.h>
|
89
|
+
#include <xml_syntax_error.h>
|
90
|
+
#include <xml_schema.h>
|
91
|
+
#include <xml_relax_ng.h>
|
92
|
+
#include <html_element_description.h>
|
93
|
+
#include <xml_namespace.h>
|
94
|
+
#include <xml_encoding_handler.h>
|
95
|
+
|
96
|
+
extern VALUE mNokogiri ;
|
97
|
+
extern VALUE mNokogiriXml ;
|
98
|
+
extern VALUE mNokogiriXmlSax ;
|
99
|
+
extern VALUE mNokogiriHtml ;
|
100
|
+
extern VALUE mNokogiriHtmlSax ;
|
101
|
+
extern VALUE mNokogiriXslt ;
|
102
|
+
|
103
|
+
int vasprintf(char **strp, const char *fmt, va_list ap);
|
104
|
+
|
105
|
+
void nokogiri_root_node(xmlNodePtr);
|
106
|
+
void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr);
|
107
|
+
|
108
|
+
#ifdef DEBUG
|
109
|
+
|
110
|
+
# define NOKOGIRI_DEBUG_START(p) if (getenv("NOKOGIRI_NO_FREE")) return ; if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p start\n", __FILE__, __LINE__, p);
|
111
|
+
# define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p);
|
112
|
+
|
113
|
+
#else
|
114
|
+
|
115
|
+
# define NOKOGIRI_DEBUG_START(p)
|
116
|
+
# define NOKOGIRI_DEBUG_END(p)
|
117
|
+
|
118
|
+
#endif
|
119
|
+
|
120
|
+
#ifndef __builtin_expect
|
121
|
+
# if defined(__GNUC__)
|
122
|
+
# define __builtin_expect(expr, c) __builtin_expect((long)(expr), (long)(c))
|
123
|
+
# endif
|
124
|
+
#endif
|
125
|
+
|
126
|
+
#define XMLNS_PREFIX "xmlns"
|
127
|
+
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
|
128
|
+
#define XMLNS_BUFFER_LEN 128
|
129
|
+
|
130
|
+
#endif
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#include <xml_attr.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* value=(content)
|
6
|
+
*
|
7
|
+
* Set the value for this Attr to +content+. Use `nil` to remove the value
|
8
|
+
* (e.g., a HTML boolean attribute).
|
9
|
+
*/
|
10
|
+
static VALUE set_value(VALUE self, VALUE content)
|
11
|
+
{
|
12
|
+
xmlAttrPtr attr;
|
13
|
+
xmlChar *value;
|
14
|
+
xmlNode *cur;
|
15
|
+
|
16
|
+
Data_Get_Struct(self, xmlAttr, attr);
|
17
|
+
|
18
|
+
if (attr->children) {
|
19
|
+
xmlFreeNodeList(attr->children);
|
20
|
+
}
|
21
|
+
attr->children = attr->last = NULL;
|
22
|
+
|
23
|
+
if (content == Qnil) {
|
24
|
+
return content;
|
25
|
+
}
|
26
|
+
|
27
|
+
value = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
28
|
+
if (xmlStrlen(value) == 0) {
|
29
|
+
attr->children = xmlNewDocText(attr->doc, value);
|
30
|
+
} else {
|
31
|
+
attr->children = xmlStringGetNodeList(attr->doc, value);
|
32
|
+
}
|
33
|
+
xmlFree(value);
|
34
|
+
|
35
|
+
for (cur = attr->children; cur; cur = cur->next) {
|
36
|
+
cur->parent = (xmlNode *)attr;
|
37
|
+
cur->doc = attr->doc;
|
38
|
+
if (cur->next == NULL) {
|
39
|
+
attr->last = cur;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
return content;
|
44
|
+
}
|
45
|
+
|
46
|
+
/*
|
47
|
+
* call-seq:
|
48
|
+
* new(document, name)
|
49
|
+
*
|
50
|
+
* Create a new Attr element on the +document+ with +name+
|
51
|
+
*/
|
52
|
+
static VALUE new(int argc, VALUE *argv, VALUE klass)
|
53
|
+
{
|
54
|
+
xmlDocPtr xml_doc;
|
55
|
+
VALUE document;
|
56
|
+
VALUE name;
|
57
|
+
VALUE rest;
|
58
|
+
xmlAttrPtr node;
|
59
|
+
VALUE rb_node;
|
60
|
+
|
61
|
+
rb_scan_args(argc, argv, "2*", &document, &name, &rest);
|
62
|
+
|
63
|
+
if (! rb_obj_is_kind_of(document, cNokogiriXmlDocument)) {
|
64
|
+
rb_raise(rb_eArgError, "parameter must be a Nokogiri::XML::Document");
|
65
|
+
}
|
66
|
+
|
67
|
+
Data_Get_Struct(document, xmlDoc, xml_doc);
|
68
|
+
|
69
|
+
node = xmlNewDocProp(
|
70
|
+
xml_doc,
|
71
|
+
(const xmlChar *)StringValueCStr(name),
|
72
|
+
NULL
|
73
|
+
);
|
74
|
+
|
75
|
+
nokogiri_root_node((xmlNodePtr)node);
|
76
|
+
|
77
|
+
rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
|
78
|
+
rb_obj_call_init(rb_node, argc, argv);
|
79
|
+
|
80
|
+
if (rb_block_given_p()) {
|
81
|
+
rb_yield(rb_node);
|
82
|
+
}
|
83
|
+
|
84
|
+
return rb_node;
|
85
|
+
}
|
86
|
+
|
87
|
+
VALUE cNokogiriXmlAttr;
|
88
|
+
void init_xml_attr()
|
89
|
+
{
|
90
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
91
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
92
|
+
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
93
|
+
|
94
|
+
/*
|
95
|
+
* Attr represents a Attr node in an xml document.
|
96
|
+
*/
|
97
|
+
VALUE klass = rb_define_class_under(xml, "Attr", node);
|
98
|
+
|
99
|
+
cNokogiriXmlAttr = klass;
|
100
|
+
|
101
|
+
rb_define_singleton_method(klass, "new", new, -1);
|
102
|
+
rb_define_method(klass, "value=", set_value, 1);
|
103
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#include <xml_attribute_decl.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* attribute_type
|
6
|
+
*
|
7
|
+
* The attribute_type for this AttributeDecl
|
8
|
+
*/
|
9
|
+
static VALUE attribute_type(VALUE self)
|
10
|
+
{
|
11
|
+
xmlAttributePtr node;
|
12
|
+
Data_Get_Struct(self, xmlAttribute, node);
|
13
|
+
return INT2NUM((long)node->atype);
|
14
|
+
}
|
15
|
+
|
16
|
+
/*
|
17
|
+
* call-seq:
|
18
|
+
* default
|
19
|
+
*
|
20
|
+
* The default value
|
21
|
+
*/
|
22
|
+
static VALUE default_value(VALUE self)
|
23
|
+
{
|
24
|
+
xmlAttributePtr node;
|
25
|
+
Data_Get_Struct(self, xmlAttribute, node);
|
26
|
+
|
27
|
+
if(node->defaultValue) return NOKOGIRI_STR_NEW2(node->defaultValue);
|
28
|
+
return Qnil;
|
29
|
+
}
|
30
|
+
|
31
|
+
/*
|
32
|
+
* call-seq:
|
33
|
+
* enumeration
|
34
|
+
*
|
35
|
+
* An enumeration of possible values
|
36
|
+
*/
|
37
|
+
static VALUE enumeration(VALUE self)
|
38
|
+
{
|
39
|
+
xmlAttributePtr node;
|
40
|
+
xmlEnumerationPtr enm;
|
41
|
+
VALUE list;
|
42
|
+
|
43
|
+
Data_Get_Struct(self, xmlAttribute, node);
|
44
|
+
|
45
|
+
list = rb_ary_new();
|
46
|
+
enm = node->tree;
|
47
|
+
|
48
|
+
while(enm) {
|
49
|
+
rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
|
50
|
+
enm = enm->next;
|
51
|
+
}
|
52
|
+
|
53
|
+
return list;
|
54
|
+
}
|
55
|
+
|
56
|
+
VALUE cNokogiriXmlAttributeDecl;
|
57
|
+
|
58
|
+
void init_xml_attribute_decl()
|
59
|
+
{
|
60
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
61
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
62
|
+
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
63
|
+
VALUE klass = rb_define_class_under(xml, "AttributeDecl", node);
|
64
|
+
|
65
|
+
cNokogiriXmlAttributeDecl = klass;
|
66
|
+
|
67
|
+
rb_define_method(klass, "attribute_type", attribute_type, 0);
|
68
|
+
rb_define_method(klass, "default", default_value, 0);
|
69
|
+
rb_define_method(klass, "enumeration", enumeration, 0);
|
70
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#include <xml_cdata.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* new(document, content)
|
6
|
+
*
|
7
|
+
* Create a new CDATA element on the +document+ with +content+
|
8
|
+
*
|
9
|
+
* If +content+ cannot be implicitly converted to a string, this method will
|
10
|
+
* raise a TypeError exception.
|
11
|
+
*/
|
12
|
+
static VALUE new(int argc, VALUE *argv, VALUE klass)
|
13
|
+
{
|
14
|
+
xmlDocPtr xml_doc;
|
15
|
+
xmlNodePtr node;
|
16
|
+
VALUE doc;
|
17
|
+
VALUE content;
|
18
|
+
VALUE rest;
|
19
|
+
VALUE rb_node;
|
20
|
+
xmlChar *content_str = NULL;
|
21
|
+
int content_str_len = 0;
|
22
|
+
|
23
|
+
rb_scan_args(argc, argv, "2*", &doc, &content, &rest);
|
24
|
+
|
25
|
+
Data_Get_Struct(doc, xmlDoc, xml_doc);
|
26
|
+
|
27
|
+
if (!NIL_P(content)) {
|
28
|
+
content_str = (xmlChar *)StringValuePtr(content);
|
29
|
+
content_str_len = RSTRING_LEN(content);
|
30
|
+
}
|
31
|
+
|
32
|
+
node = xmlNewCDataBlock(xml_doc->doc, content_str, content_str_len);
|
33
|
+
|
34
|
+
nokogiri_root_node(node);
|
35
|
+
|
36
|
+
rb_node = Nokogiri_wrap_xml_node(klass, node);
|
37
|
+
rb_obj_call_init(rb_node, argc, argv);
|
38
|
+
|
39
|
+
if(rb_block_given_p()) { rb_yield(rb_node); }
|
40
|
+
|
41
|
+
return rb_node;
|
42
|
+
}
|
43
|
+
|
44
|
+
VALUE cNokogiriXmlCData;
|
45
|
+
void init_xml_cdata()
|
46
|
+
{
|
47
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
48
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
49
|
+
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
50
|
+
VALUE char_data = rb_define_class_under(xml, "CharacterData", node);
|
51
|
+
VALUE text = rb_define_class_under(xml, "Text", char_data);
|
52
|
+
|
53
|
+
/*
|
54
|
+
* CData represents a CData node in an xml document.
|
55
|
+
*/
|
56
|
+
VALUE klass = rb_define_class_under(xml, "CDATA", text);
|
57
|
+
|
58
|
+
|
59
|
+
cNokogiriXmlCData = klass;
|
60
|
+
|
61
|
+
rb_define_singleton_method(klass, "new", new, -1);
|
62
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#include <xml_comment.h>
|
2
|
+
|
3
|
+
static ID document_id ;
|
4
|
+
|
5
|
+
/*
|
6
|
+
* call-seq:
|
7
|
+
* new(document_or_node, content)
|
8
|
+
*
|
9
|
+
* Create a new Comment element on the +document+ with +content+.
|
10
|
+
* Alternatively, if a +node+ is passed, the +node+'s document is used.
|
11
|
+
*/
|
12
|
+
static VALUE new(int argc, VALUE *argv, VALUE klass)
|
13
|
+
{
|
14
|
+
xmlDocPtr xml_doc;
|
15
|
+
xmlNodePtr node;
|
16
|
+
VALUE document;
|
17
|
+
VALUE content;
|
18
|
+
VALUE rest;
|
19
|
+
VALUE rb_node;
|
20
|
+
|
21
|
+
rb_scan_args(argc, argv, "2*", &document, &content, &rest);
|
22
|
+
|
23
|
+
if (rb_obj_is_kind_of(document, cNokogiriXmlNode))
|
24
|
+
{
|
25
|
+
document = rb_funcall(document, document_id, 0);
|
26
|
+
}
|
27
|
+
else if ( !rb_obj_is_kind_of(document, cNokogiriXmlDocument)
|
28
|
+
&& !rb_obj_is_kind_of(document, cNokogiriXmlDocumentFragment))
|
29
|
+
{
|
30
|
+
rb_raise(rb_eArgError, "first argument must be a XML::Document or XML::Node");
|
31
|
+
}
|
32
|
+
|
33
|
+
Data_Get_Struct(document, xmlDoc, xml_doc);
|
34
|
+
|
35
|
+
node = xmlNewDocComment(
|
36
|
+
xml_doc,
|
37
|
+
(const xmlChar *)StringValueCStr(content)
|
38
|
+
);
|
39
|
+
|
40
|
+
rb_node = Nokogiri_wrap_xml_node(klass, node);
|
41
|
+
rb_obj_call_init(rb_node, argc, argv);
|
42
|
+
|
43
|
+
nokogiri_root_node(node);
|
44
|
+
|
45
|
+
if(rb_block_given_p()) rb_yield(rb_node);
|
46
|
+
|
47
|
+
return rb_node;
|
48
|
+
}
|
49
|
+
|
50
|
+
VALUE cNokogiriXmlComment;
|
51
|
+
void init_xml_comment()
|
52
|
+
{
|
53
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
54
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
55
|
+
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
56
|
+
VALUE char_data = rb_define_class_under(xml, "CharacterData", node);
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Comment represents a comment node in an xml document.
|
60
|
+
*/
|
61
|
+
VALUE klass = rb_define_class_under(xml, "Comment", char_data);
|
62
|
+
|
63
|
+
|
64
|
+
cNokogiriXmlComment = klass;
|
65
|
+
|
66
|
+
rb_define_singleton_method(klass, "new", new, -1);
|
67
|
+
|
68
|
+
document_id = rb_intern("document");
|
69
|
+
}
|