nokogiri 1.11.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- 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/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/include/libexslt/exslt.h +102 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
- data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX.h +173 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +126 -0
- data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
- data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
- data/ext/nokogiri/include/libxml2/libxml/dict.h +79 -0
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
- data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -0
- data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
- data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
- data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +163 -0
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +1241 -0
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -0
- data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
- data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
- data/ext/nokogiri/include/libxml2/libxml/threads.h +89 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
- data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -0
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
- data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +366 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +945 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +153 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +151 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +485 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +566 -0
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -0
- data/ext/nokogiri/include/libxslt/attributes.h +38 -0
- data/ext/nokogiri/include/libxslt/documents.h +93 -0
- data/ext/nokogiri/include/libxslt/extensions.h +262 -0
- data/ext/nokogiri/include/libxslt/extra.h +72 -0
- data/ext/nokogiri/include/libxslt/functions.h +78 -0
- data/ext/nokogiri/include/libxslt/imports.h +75 -0
- data/ext/nokogiri/include/libxslt/keys.h +53 -0
- data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
- data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
- data/ext/nokogiri/include/libxslt/pattern.h +84 -0
- data/ext/nokogiri/include/libxslt/preproc.h +43 -0
- data/ext/nokogiri/include/libxslt/security.h +104 -0
- data/ext/nokogiri/include/libxslt/templates.h +77 -0
- data/ext/nokogiri/include/libxslt/transform.h +207 -0
- data/ext/nokogiri/include/libxslt/variables.h +118 -0
- data/ext/nokogiri/include/libxslt/xslt.h +110 -0
- data/ext/nokogiri/include/libxslt/xsltInternals.h +1978 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
- data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
- data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
- data/ext/nokogiri/include/libxslt/xsltutils.h +313 -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/nokogiri.rb +144 -0
- data/lib/nokogiri/2.5/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
- data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
- data/lib/nokogiri/css.rb +28 -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/decorators/slop.rb +43 -0
- data/lib/nokogiri/html.rb +38 -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/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +5 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/xml.rb +76 -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.rb +1240 -0
- data/lib/nokogiri/xml/node/save_options.rb +62 -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.rb +3 -0
- data/lib/nokogiri/xml/pp/character_data.rb +19 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -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.rb +5 -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/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.rb +11 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
- data/lib/nokogiri/xml/xpath_context.rb +17 -0
- data/lib/nokogiri/xslt.rb +57 -0
- data/lib/nokogiri/xslt/stylesheet.rb +26 -0
- data/lib/xsd/xmlparser/nokogiri.rb +103 -0
- metadata +499 -0
@@ -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
|
+
}
|