nokogiri 1.18.0.rc1-x86_64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +38 -0
  3. data/LICENSE-DEPENDENCIES.md +2224 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +293 -0
  6. data/bin/nokogiri +131 -0
  7. data/dependencies.yml +42 -0
  8. data/ext/nokogiri/depend +38 -0
  9. data/ext/nokogiri/extconf.rb +1173 -0
  10. data/ext/nokogiri/gumbo.c +610 -0
  11. data/ext/nokogiri/html4_document.c +171 -0
  12. data/ext/nokogiri/html4_element_description.c +299 -0
  13. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  14. data/ext/nokogiri/html4_sax_parser.c +40 -0
  15. data/ext/nokogiri/html4_sax_parser_context.c +98 -0
  16. data/ext/nokogiri/html4_sax_push_parser.c +96 -0
  17. data/ext/nokogiri/include/libexslt/exslt.h +108 -0
  18. data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
  19. data/ext/nokogiri/include/libexslt/exsltexports.h +63 -0
  20. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +336 -0
  21. data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
  22. data/ext/nokogiri/include/libxml2/libxml/SAX.h +202 -0
  23. data/ext/nokogiri/include/libxml2/libxml/SAX2.h +171 -0
  24. data/ext/nokogiri/include/libxml2/libxml/c14n.h +115 -0
  25. data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
  26. data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
  27. data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
  28. data/ext/nokogiri/include/libxml2/libxml/dict.h +82 -0
  29. data/ext/nokogiri/include/libxml2/libxml/encoding.h +244 -0
  30. data/ext/nokogiri/include/libxml2/libxml/entities.h +166 -0
  31. data/ext/nokogiri/include/libxml2/libxml/globals.h +41 -0
  32. data/ext/nokogiri/include/libxml2/libxml/hash.h +251 -0
  33. data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
  34. data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +186 -0
  35. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +98 -0
  36. data/ext/nokogiri/include/libxml2/libxml/parser.h +1390 -0
  37. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +671 -0
  38. data/ext/nokogiri/include/libxml2/libxml/pattern.h +106 -0
  39. data/ext/nokogiri/include/libxml2/libxml/relaxng.h +219 -0
  40. data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +959 -0
  41. data/ext/nokogiri/include/libxml2/libxml/schematron.h +143 -0
  42. data/ext/nokogiri/include/libxml2/libxml/threads.h +87 -0
  43. data/ext/nokogiri/include/libxml2/libxml/tree.h +1382 -0
  44. data/ext/nokogiri/include/libxml2/libxml/uri.h +106 -0
  45. data/ext/nokogiri/include/libxml2/libxml/valid.h +477 -0
  46. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +136 -0
  47. data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
  48. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +438 -0
  49. data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
  50. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +962 -0
  51. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +146 -0
  52. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +188 -0
  53. data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
  54. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +436 -0
  55. data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +215 -0
  56. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +102 -0
  57. data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +249 -0
  58. data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +152 -0
  59. data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
  60. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +366 -0
  61. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +347 -0
  62. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +489 -0
  63. data/ext/nokogiri/include/libxml2/libxml/xpath.h +579 -0
  64. data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +633 -0
  65. data/ext/nokogiri/include/libxml2/libxml/xpointer.h +138 -0
  66. data/ext/nokogiri/include/libxslt/attributes.h +39 -0
  67. data/ext/nokogiri/include/libxslt/documents.h +93 -0
  68. data/ext/nokogiri/include/libxslt/extensions.h +262 -0
  69. data/ext/nokogiri/include/libxslt/extra.h +72 -0
  70. data/ext/nokogiri/include/libxslt/functions.h +78 -0
  71. data/ext/nokogiri/include/libxslt/imports.h +75 -0
  72. data/ext/nokogiri/include/libxslt/keys.h +53 -0
  73. data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
  74. data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
  75. data/ext/nokogiri/include/libxslt/pattern.h +84 -0
  76. data/ext/nokogiri/include/libxslt/preproc.h +43 -0
  77. data/ext/nokogiri/include/libxslt/security.h +104 -0
  78. data/ext/nokogiri/include/libxslt/templates.h +77 -0
  79. data/ext/nokogiri/include/libxslt/transform.h +207 -0
  80. data/ext/nokogiri/include/libxslt/variables.h +118 -0
  81. data/ext/nokogiri/include/libxslt/xslt.h +110 -0
  82. data/ext/nokogiri/include/libxslt/xsltInternals.h +1995 -0
  83. data/ext/nokogiri/include/libxslt/xsltconfig.h +146 -0
  84. data/ext/nokogiri/include/libxslt/xsltexports.h +64 -0
  85. data/ext/nokogiri/include/libxslt/xsltlocale.h +44 -0
  86. data/ext/nokogiri/include/libxslt/xsltutils.h +343 -0
  87. data/ext/nokogiri/libxml2_polyfill.c +114 -0
  88. data/ext/nokogiri/nokogiri.c +294 -0
  89. data/ext/nokogiri/nokogiri.h +238 -0
  90. data/ext/nokogiri/test_global_handlers.c +40 -0
  91. data/ext/nokogiri/xml_attr.c +103 -0
  92. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  93. data/ext/nokogiri/xml_cdata.c +62 -0
  94. data/ext/nokogiri/xml_comment.c +57 -0
  95. data/ext/nokogiri/xml_document.c +784 -0
  96. data/ext/nokogiri/xml_document_fragment.c +29 -0
  97. data/ext/nokogiri/xml_dtd.c +208 -0
  98. data/ext/nokogiri/xml_element_content.c +131 -0
  99. data/ext/nokogiri/xml_element_decl.c +69 -0
  100. data/ext/nokogiri/xml_encoding_handler.c +112 -0
  101. data/ext/nokogiri/xml_entity_decl.c +112 -0
  102. data/ext/nokogiri/xml_entity_reference.c +50 -0
  103. data/ext/nokogiri/xml_namespace.c +181 -0
  104. data/ext/nokogiri/xml_node.c +2459 -0
  105. data/ext/nokogiri/xml_node_set.c +518 -0
  106. data/ext/nokogiri/xml_processing_instruction.c +54 -0
  107. data/ext/nokogiri/xml_reader.c +777 -0
  108. data/ext/nokogiri/xml_relax_ng.c +149 -0
  109. data/ext/nokogiri/xml_sax_parser.c +403 -0
  110. data/ext/nokogiri/xml_sax_parser_context.c +390 -0
  111. data/ext/nokogiri/xml_sax_push_parser.c +206 -0
  112. data/ext/nokogiri/xml_schema.c +226 -0
  113. data/ext/nokogiri/xml_syntax_error.c +93 -0
  114. data/ext/nokogiri/xml_text.c +59 -0
  115. data/ext/nokogiri/xml_xpath_context.c +502 -0
  116. data/ext/nokogiri/xslt_stylesheet.c +421 -0
  117. data/gumbo-parser/CHANGES.md +63 -0
  118. data/gumbo-parser/Makefile +129 -0
  119. data/gumbo-parser/THANKS +27 -0
  120. data/lib/nokogiri/3.1/nokogiri.so +0 -0
  121. data/lib/nokogiri/3.2/nokogiri.so +0 -0
  122. data/lib/nokogiri/3.3/nokogiri.so +0 -0
  123. data/lib/nokogiri/3.4/nokogiri.so +0 -0
  124. data/lib/nokogiri/class_resolver.rb +67 -0
  125. data/lib/nokogiri/css/node.rb +58 -0
  126. data/lib/nokogiri/css/parser.rb +772 -0
  127. data/lib/nokogiri/css/parser.y +277 -0
  128. data/lib/nokogiri/css/parser_extras.rb +36 -0
  129. data/lib/nokogiri/css/selector_cache.rb +38 -0
  130. data/lib/nokogiri/css/syntax_error.rb +9 -0
  131. data/lib/nokogiri/css/tokenizer.rb +155 -0
  132. data/lib/nokogiri/css/tokenizer.rex +57 -0
  133. data/lib/nokogiri/css/xpath_visitor.rb +375 -0
  134. data/lib/nokogiri/css.rb +132 -0
  135. data/lib/nokogiri/decorators/slop.rb +42 -0
  136. data/lib/nokogiri/encoding_handler.rb +57 -0
  137. data/lib/nokogiri/extension.rb +32 -0
  138. data/lib/nokogiri/gumbo.rb +15 -0
  139. data/lib/nokogiri/html.rb +48 -0
  140. data/lib/nokogiri/html4/builder.rb +37 -0
  141. data/lib/nokogiri/html4/document.rb +235 -0
  142. data/lib/nokogiri/html4/document_fragment.rb +166 -0
  143. data/lib/nokogiri/html4/element_description.rb +25 -0
  144. data/lib/nokogiri/html4/element_description_defaults.rb +2040 -0
  145. data/lib/nokogiri/html4/encoding_reader.rb +121 -0
  146. data/lib/nokogiri/html4/entity_lookup.rb +15 -0
  147. data/lib/nokogiri/html4/sax/parser.rb +48 -0
  148. data/lib/nokogiri/html4/sax/parser_context.rb +15 -0
  149. data/lib/nokogiri/html4/sax/push_parser.rb +37 -0
  150. data/lib/nokogiri/html4.rb +42 -0
  151. data/lib/nokogiri/html5/builder.rb +40 -0
  152. data/lib/nokogiri/html5/document.rb +199 -0
  153. data/lib/nokogiri/html5/document_fragment.rb +200 -0
  154. data/lib/nokogiri/html5/node.rb +103 -0
  155. data/lib/nokogiri/html5.rb +368 -0
  156. data/lib/nokogiri/jruby/dependencies.rb +3 -0
  157. data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
  158. data/lib/nokogiri/syntax_error.rb +6 -0
  159. data/lib/nokogiri/version/constant.rb +6 -0
  160. data/lib/nokogiri/version/info.rb +224 -0
  161. data/lib/nokogiri/version.rb +4 -0
  162. data/lib/nokogiri/xml/attr.rb +66 -0
  163. data/lib/nokogiri/xml/attribute_decl.rb +22 -0
  164. data/lib/nokogiri/xml/builder.rb +494 -0
  165. data/lib/nokogiri/xml/cdata.rb +13 -0
  166. data/lib/nokogiri/xml/character_data.rb +9 -0
  167. data/lib/nokogiri/xml/document.rb +514 -0
  168. data/lib/nokogiri/xml/document_fragment.rb +276 -0
  169. data/lib/nokogiri/xml/dtd.rb +34 -0
  170. data/lib/nokogiri/xml/element_content.rb +46 -0
  171. data/lib/nokogiri/xml/element_decl.rb +17 -0
  172. data/lib/nokogiri/xml/entity_decl.rb +23 -0
  173. data/lib/nokogiri/xml/entity_reference.rb +20 -0
  174. data/lib/nokogiri/xml/namespace.rb +57 -0
  175. data/lib/nokogiri/xml/node/save_options.rb +76 -0
  176. data/lib/nokogiri/xml/node.rb +1650 -0
  177. data/lib/nokogiri/xml/node_set.rb +449 -0
  178. data/lib/nokogiri/xml/notation.rb +19 -0
  179. data/lib/nokogiri/xml/parse_options.rb +213 -0
  180. data/lib/nokogiri/xml/pp/character_data.rb +21 -0
  181. data/lib/nokogiri/xml/pp/node.rb +73 -0
  182. data/lib/nokogiri/xml/pp.rb +4 -0
  183. data/lib/nokogiri/xml/processing_instruction.rb +11 -0
  184. data/lib/nokogiri/xml/reader.rb +139 -0
  185. data/lib/nokogiri/xml/relax_ng.rb +75 -0
  186. data/lib/nokogiri/xml/sax/document.rb +258 -0
  187. data/lib/nokogiri/xml/sax/parser.rb +199 -0
  188. data/lib/nokogiri/xml/sax/parser_context.rb +129 -0
  189. data/lib/nokogiri/xml/sax/push_parser.rb +64 -0
  190. data/lib/nokogiri/xml/sax.rb +54 -0
  191. data/lib/nokogiri/xml/schema.rb +140 -0
  192. data/lib/nokogiri/xml/searchable.rb +297 -0
  193. data/lib/nokogiri/xml/syntax_error.rb +94 -0
  194. data/lib/nokogiri/xml/text.rb +11 -0
  195. data/lib/nokogiri/xml/xpath/syntax_error.rb +13 -0
  196. data/lib/nokogiri/xml/xpath.rb +21 -0
  197. data/lib/nokogiri/xml/xpath_context.rb +49 -0
  198. data/lib/nokogiri/xml.rb +65 -0
  199. data/lib/nokogiri/xslt/stylesheet.rb +49 -0
  200. data/lib/nokogiri/xslt.rb +129 -0
  201. data/lib/nokogiri.rb +128 -0
  202. data/lib/xsd/xmlparser/nokogiri.rb +105 -0
  203. metadata +324 -0
@@ -0,0 +1,29 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlDocumentFragment;
4
+
5
+ /* :nodoc: */
6
+ static VALUE
7
+ noko_xml_document_fragment_s_native_new(VALUE klass, VALUE rb_doc)
8
+ {
9
+ xmlDocPtr c_doc;
10
+ xmlNodePtr c_node;
11
+ VALUE rb_node;
12
+
13
+ c_doc = noko_xml_document_unwrap(rb_doc);
14
+ c_node = xmlNewDocFragment(c_doc->doc);
15
+ noko_xml_document_pin_node(c_node);
16
+ rb_node = noko_xml_node_wrap(klass, c_node);
17
+
18
+ return rb_node;
19
+ }
20
+
21
+ void
22
+ noko_init_xml_document_fragment(void)
23
+ {
24
+ assert(cNokogiriXmlNode);
25
+
26
+ cNokogiriXmlDocumentFragment = rb_define_class_under(mNokogiriXml, "DocumentFragment", cNokogiriXmlNode);
27
+
28
+ rb_define_singleton_method(cNokogiriXmlDocumentFragment, "native_new", noko_xml_document_fragment_s_native_new, 1);
29
+ }
@@ -0,0 +1,208 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlDtd;
4
+
5
+ static void
6
+ notation_copier(void *c_notation_ptr, void *rb_hash_ptr, const xmlChar *name)
7
+ {
8
+ VALUE rb_hash = (VALUE)rb_hash_ptr;
9
+ xmlNotationPtr c_notation = (xmlNotationPtr)c_notation_ptr;
10
+ VALUE rb_notation;
11
+ VALUE cNokogiriXmlNotation;
12
+ VALUE rb_constructor_args[3];
13
+
14
+ rb_constructor_args[0] = (c_notation->name ? NOKOGIRI_STR_NEW2(c_notation->name) : Qnil);
15
+ rb_constructor_args[1] = (c_notation->PublicID ? NOKOGIRI_STR_NEW2(c_notation->PublicID) : Qnil);
16
+ rb_constructor_args[2] = (c_notation->SystemID ? NOKOGIRI_STR_NEW2(c_notation->SystemID) : Qnil);
17
+
18
+ cNokogiriXmlNotation = rb_const_get_at(mNokogiriXml, rb_intern("Notation"));
19
+ rb_notation = rb_class_new_instance(3, rb_constructor_args, cNokogiriXmlNotation);
20
+
21
+ rb_hash_aset(rb_hash, NOKOGIRI_STR_NEW2(name), rb_notation);
22
+ }
23
+
24
+ static void
25
+ element_copier(void *c_node_ptr, void *rb_hash_ptr, const xmlChar *c_name)
26
+ {
27
+ VALUE rb_hash = (VALUE)rb_hash_ptr;
28
+ xmlNodePtr c_node = (xmlNodePtr)c_node_ptr;
29
+
30
+ VALUE rb_node = noko_xml_node_wrap(Qnil, c_node);
31
+
32
+ rb_hash_aset(rb_hash, NOKOGIRI_STR_NEW2(c_name), rb_node);
33
+ }
34
+
35
+ /*
36
+ * call-seq:
37
+ * entities
38
+ *
39
+ * Get a hash of the elements for this DTD.
40
+ */
41
+ static VALUE
42
+ entities(VALUE self)
43
+ {
44
+ xmlDtdPtr dtd;
45
+ VALUE hash;
46
+
47
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
48
+
49
+ if (!dtd->entities) { return Qnil; }
50
+
51
+ hash = rb_hash_new();
52
+
53
+ xmlHashScan((xmlHashTablePtr)dtd->entities, element_copier, (void *)hash);
54
+
55
+ return hash;
56
+ }
57
+
58
+ /*
59
+ * call-seq:
60
+ * notations() → Hash<name(String)⇒Notation>
61
+ *
62
+ * [Returns] All the notations for this DTD in a Hash of Notation +name+ to Notation.
63
+ */
64
+ static VALUE
65
+ notations(VALUE self)
66
+ {
67
+ xmlDtdPtr dtd;
68
+ VALUE hash;
69
+
70
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
71
+
72
+ if (!dtd->notations) { return Qnil; }
73
+
74
+ hash = rb_hash_new();
75
+
76
+ xmlHashScan((xmlHashTablePtr)dtd->notations, notation_copier, (void *)hash);
77
+
78
+ return hash;
79
+ }
80
+
81
+ /*
82
+ * call-seq:
83
+ * attributes
84
+ *
85
+ * Get a hash of the attributes for this DTD.
86
+ */
87
+ static VALUE
88
+ attributes(VALUE self)
89
+ {
90
+ xmlDtdPtr dtd;
91
+ VALUE hash;
92
+
93
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
94
+
95
+ hash = rb_hash_new();
96
+
97
+ if (!dtd->attributes) { return hash; }
98
+
99
+ xmlHashScan((xmlHashTablePtr)dtd->attributes, element_copier, (void *)hash);
100
+
101
+ return hash;
102
+ }
103
+
104
+ /*
105
+ * call-seq:
106
+ * elements
107
+ *
108
+ * Get a hash of the elements for this DTD.
109
+ */
110
+ static VALUE
111
+ elements(VALUE self)
112
+ {
113
+ xmlDtdPtr dtd;
114
+ VALUE hash;
115
+
116
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
117
+
118
+ if (!dtd->elements) { return Qnil; }
119
+
120
+ hash = rb_hash_new();
121
+
122
+ xmlHashScan((xmlHashTablePtr)dtd->elements, element_copier, (void *)hash);
123
+
124
+ return hash;
125
+ }
126
+
127
+ /*
128
+ * call-seq:
129
+ * validate(document)
130
+ *
131
+ * Validate +document+ returning a list of errors
132
+ */
133
+ static VALUE
134
+ validate(VALUE self, VALUE document)
135
+ {
136
+ xmlDocPtr doc;
137
+ xmlDtdPtr dtd;
138
+ xmlValidCtxtPtr ctxt;
139
+ VALUE error_list;
140
+
141
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
142
+ doc = noko_xml_document_unwrap(document);
143
+ error_list = rb_ary_new();
144
+
145
+ ctxt = xmlNewValidCtxt();
146
+
147
+ xmlSetStructuredErrorFunc((void *)error_list, noko__error_array_pusher);
148
+
149
+ xmlValidateDtd(ctxt, doc, dtd);
150
+
151
+ xmlSetStructuredErrorFunc(NULL, NULL);
152
+
153
+ xmlFreeValidCtxt(ctxt);
154
+
155
+ return error_list;
156
+ }
157
+
158
+ /*
159
+ * call-seq:
160
+ * system_id
161
+ *
162
+ * Get the System ID for this DTD
163
+ */
164
+ static VALUE
165
+ system_id(VALUE self)
166
+ {
167
+ xmlDtdPtr dtd;
168
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
169
+
170
+ if (!dtd->SystemID) { return Qnil; }
171
+
172
+ return NOKOGIRI_STR_NEW2(dtd->SystemID);
173
+ }
174
+
175
+ /*
176
+ * call-seq:
177
+ * external_id
178
+ *
179
+ * Get the External ID for this DTD
180
+ */
181
+ static VALUE
182
+ external_id(VALUE self)
183
+ {
184
+ xmlDtdPtr dtd;
185
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
186
+
187
+ if (!dtd->ExternalID) { return Qnil; }
188
+
189
+ return NOKOGIRI_STR_NEW2(dtd->ExternalID);
190
+ }
191
+
192
+ void
193
+ noko_init_xml_dtd(void)
194
+ {
195
+ assert(cNokogiriXmlNode);
196
+ /*
197
+ * Nokogiri::XML::DTD wraps DTD nodes in an XML document
198
+ */
199
+ cNokogiriXmlDtd = rb_define_class_under(mNokogiriXml, "DTD", cNokogiriXmlNode);
200
+
201
+ rb_define_method(cNokogiriXmlDtd, "notations", notations, 0);
202
+ rb_define_method(cNokogiriXmlDtd, "elements", elements, 0);
203
+ rb_define_method(cNokogiriXmlDtd, "entities", entities, 0);
204
+ rb_define_method(cNokogiriXmlDtd, "validate", validate, 1);
205
+ rb_define_method(cNokogiriXmlDtd, "attributes", attributes, 0);
206
+ rb_define_method(cNokogiriXmlDtd, "system_id", system_id, 0);
207
+ rb_define_method(cNokogiriXmlDtd, "external_id", external_id, 0);
208
+ }
@@ -0,0 +1,131 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlElementContent;
4
+
5
+ static const rb_data_type_t xml_element_content_type = {
6
+ .wrap_struct_name = "xmlElementContent",
7
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
8
+ };
9
+
10
+ /*
11
+ * call-seq:
12
+ * name → String
13
+ *
14
+ * [Returns] The content element's +name+
15
+ */
16
+ static VALUE
17
+ get_name(VALUE self)
18
+ {
19
+ xmlElementContentPtr elem;
20
+ TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
21
+
22
+ if (!elem->name) { return Qnil; }
23
+ return NOKOGIRI_STR_NEW2(elem->name);
24
+ }
25
+
26
+ /*
27
+ * call-seq:
28
+ * type → Integer
29
+ *
30
+ * [Returns] The content element's +type+. Possible values are +PCDATA+, +ELEMENT+, +SEQ+, or +OR+.
31
+ */
32
+ static VALUE
33
+ get_type(VALUE self)
34
+ {
35
+ xmlElementContentPtr elem;
36
+ TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
37
+
38
+ return INT2NUM(elem->type);
39
+ }
40
+
41
+ /*
42
+ * Get the first child.
43
+ */
44
+ static VALUE
45
+ get_c1(VALUE self)
46
+ {
47
+ xmlElementContentPtr elem;
48
+ TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
49
+
50
+ if (!elem->c1) { return Qnil; }
51
+ return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c1);
52
+ }
53
+
54
+ /*
55
+ * Get the second child.
56
+ */
57
+ static VALUE
58
+ get_c2(VALUE self)
59
+ {
60
+ xmlElementContentPtr elem;
61
+ TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
62
+
63
+ if (!elem->c2) { return Qnil; }
64
+ return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c2);
65
+ }
66
+
67
+ /*
68
+ * call-seq:
69
+ * occur → Integer
70
+ *
71
+ * [Returns] The content element's +occur+ flag. Possible values are +ONCE+, +OPT+, +MULT+ or +PLUS+.
72
+ */
73
+ static VALUE
74
+ get_occur(VALUE self)
75
+ {
76
+ xmlElementContentPtr elem;
77
+ TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
78
+
79
+ return INT2NUM(elem->ocur);
80
+ }
81
+
82
+ /*
83
+ * call-seq:
84
+ * prefix → String
85
+ *
86
+ * [Returns] The content element's namespace +prefix+.
87
+ */
88
+ static VALUE
89
+ get_prefix(VALUE self)
90
+ {
91
+ xmlElementContentPtr elem;
92
+ TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
93
+
94
+ if (!elem->prefix) { return Qnil; }
95
+
96
+ return NOKOGIRI_STR_NEW2(elem->prefix);
97
+ }
98
+
99
+ /*
100
+ * create a Nokogiri::XML::ElementContent object around an +element+.
101
+ */
102
+ VALUE
103
+ noko_xml_element_content_wrap(VALUE rb_document, xmlElementContentPtr c_element_content)
104
+ {
105
+ VALUE elem = TypedData_Wrap_Struct(
106
+ cNokogiriXmlElementContent,
107
+ &xml_element_content_type,
108
+ c_element_content
109
+ );
110
+
111
+ /* keep a handle on the document for GC marking */
112
+ rb_iv_set(elem, "@document", rb_document);
113
+
114
+ return elem;
115
+ }
116
+
117
+ void
118
+ noko_init_xml_element_content(void)
119
+ {
120
+ cNokogiriXmlElementContent = rb_define_class_under(mNokogiriXml, "ElementContent", rb_cObject);
121
+
122
+ rb_undef_alloc_func(cNokogiriXmlElementContent);
123
+
124
+ rb_define_method(cNokogiriXmlElementContent, "name", get_name, 0);
125
+ rb_define_method(cNokogiriXmlElementContent, "type", get_type, 0);
126
+ rb_define_method(cNokogiriXmlElementContent, "occur", get_occur, 0);
127
+ rb_define_method(cNokogiriXmlElementContent, "prefix", get_prefix, 0);
128
+
129
+ rb_define_private_method(cNokogiriXmlElementContent, "c1", get_c1, 0);
130
+ rb_define_private_method(cNokogiriXmlElementContent, "c2", get_c2, 0);
131
+ }
@@ -0,0 +1,69 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlElementDecl;
4
+
5
+ static ID id_document;
6
+
7
+ /*
8
+ * call-seq:
9
+ * element_type → Integer
10
+ *
11
+ * The element_type
12
+ */
13
+ static VALUE
14
+ element_type(VALUE self)
15
+ {
16
+ xmlElementPtr node;
17
+ Noko_Node_Get_Struct(self, xmlElement, node);
18
+ return INT2NUM(node->etype);
19
+ }
20
+
21
+ /*
22
+ * call-seq:
23
+ * content → Nokogiri::XML::ElementContent
24
+ *
25
+ * [Returns] The root of this element declaration's content tree.
26
+ */
27
+ static VALUE
28
+ content(VALUE self)
29
+ {
30
+ xmlElementPtr node;
31
+ Noko_Node_Get_Struct(self, xmlElement, node);
32
+
33
+ if (!node->content) { return Qnil; }
34
+
35
+ return noko_xml_element_content_wrap(
36
+ rb_funcall(self, id_document, 0),
37
+ node->content
38
+ );
39
+ }
40
+
41
+ /*
42
+ * call-seq:
43
+ * prefix → String
44
+ *
45
+ * [Returns] The namespace +prefix+ for this element declaration.
46
+ */
47
+ static VALUE
48
+ prefix(VALUE self)
49
+ {
50
+ xmlElementPtr node;
51
+ Noko_Node_Get_Struct(self, xmlElement, node);
52
+
53
+ if (!node->prefix) { return Qnil; }
54
+
55
+ return NOKOGIRI_STR_NEW2(node->prefix);
56
+ }
57
+
58
+ void
59
+ noko_init_xml_element_decl(void)
60
+ {
61
+ assert(cNokogiriXmlNode);
62
+ cNokogiriXmlElementDecl = rb_define_class_under(mNokogiriXml, "ElementDecl", cNokogiriXmlNode);
63
+
64
+ rb_define_method(cNokogiriXmlElementDecl, "element_type", element_type, 0);
65
+ rb_define_method(cNokogiriXmlElementDecl, "content", content, 0);
66
+ rb_define_method(cNokogiriXmlElementDecl, "prefix", prefix, 0);
67
+
68
+ id_document = rb_intern("document");
69
+ }
@@ -0,0 +1,112 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriEncodingHandler;
4
+
5
+ static void
6
+ xml_encoding_handler_dealloc(void *data)
7
+ {
8
+ /* make sure iconv handlers are cleaned up and freed */
9
+ xmlCharEncodingHandlerPtr c_handler = data;
10
+ xmlCharEncCloseFunc(c_handler);
11
+ }
12
+
13
+ static const rb_data_type_t xml_char_encoding_handler_type = {
14
+ .wrap_struct_name = "xmlCharEncodingHandler",
15
+ .function = {
16
+ .dfree = xml_encoding_handler_dealloc,
17
+ },
18
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
19
+ };
20
+
21
+
22
+ /*
23
+ * call-seq: Nokogiri::EncodingHandler.[](name)
24
+ *
25
+ * Get the encoding handler for +name+
26
+ */
27
+ static VALUE
28
+ rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
29
+ {
30
+ xmlCharEncodingHandlerPtr handler;
31
+
32
+ handler = xmlFindCharEncodingHandler(StringValueCStr(key));
33
+ if (handler) {
34
+ return TypedData_Wrap_Struct(klass, &xml_char_encoding_handler_type, handler);
35
+ }
36
+
37
+ return Qnil;
38
+ }
39
+
40
+
41
+ /*
42
+ * call-seq: Nokogiri::EncodingHandler.delete(name)
43
+ *
44
+ * Delete the encoding alias named +name+
45
+ */
46
+ static VALUE
47
+ rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
48
+ {
49
+ if (xmlDelEncodingAlias(StringValueCStr(name))) { return Qnil; }
50
+
51
+ return Qtrue;
52
+ }
53
+
54
+
55
+ /*
56
+ * call-seq: Nokogiri::EncodingHandler.alias(real_name, alias_name)
57
+ *
58
+ * Alias encoding handler with name +real_name+ to name +alias_name+
59
+ */
60
+ static VALUE
61
+ rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
62
+ {
63
+ xmlAddEncodingAlias(StringValueCStr(from), StringValueCStr(to));
64
+
65
+ return to;
66
+ }
67
+
68
+
69
+ /*
70
+ * call-seq: Nokogiri::EncodingHandler.clear_aliases!
71
+ *
72
+ * Remove all encoding aliases.
73
+ */
74
+ static VALUE
75
+ rb_xml_encoding_handler_s_clear_aliases(VALUE klass)
76
+ {
77
+ xmlCleanupEncodingAliases();
78
+
79
+ return klass;
80
+ }
81
+
82
+
83
+ /*
84
+ * call-seq: name
85
+ *
86
+ * Get the name of this EncodingHandler
87
+ */
88
+ static VALUE
89
+ rb_xml_encoding_handler_name(VALUE self)
90
+ {
91
+ xmlCharEncodingHandlerPtr handler;
92
+
93
+ TypedData_Get_Struct(self, xmlCharEncodingHandler, &xml_char_encoding_handler_type, handler);
94
+
95
+ return NOKOGIRI_STR_NEW2(handler->name);
96
+ }
97
+
98
+
99
+ void
100
+ noko_init_xml_encoding_handler(void)
101
+ {
102
+ cNokogiriEncodingHandler = rb_define_class_under(mNokogiri, "EncodingHandler", rb_cObject);
103
+
104
+ rb_undef_alloc_func(cNokogiriEncodingHandler);
105
+
106
+ rb_define_singleton_method(cNokogiriEncodingHandler, "[]", rb_xml_encoding_handler_s_get, 1);
107
+ rb_define_singleton_method(cNokogiriEncodingHandler, "delete", rb_xml_encoding_handler_s_delete, 1);
108
+ rb_define_singleton_method(cNokogiriEncodingHandler, "alias", rb_xml_encoding_handler_s_alias, 2);
109
+ rb_define_singleton_method(cNokogiriEncodingHandler, "clear_aliases!", rb_xml_encoding_handler_s_clear_aliases, 0);
110
+
111
+ rb_define_method(cNokogiriEncodingHandler, "name", rb_xml_encoding_handler_name, 0);
112
+ }
@@ -0,0 +1,112 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlEntityDecl;
4
+
5
+ /*
6
+ * call-seq:
7
+ * original_content
8
+ *
9
+ * Get the original_content before ref substitution
10
+ */
11
+ static VALUE
12
+ original_content(VALUE self)
13
+ {
14
+ xmlEntityPtr node;
15
+ Noko_Node_Get_Struct(self, xmlEntity, node);
16
+
17
+ if (!node->orig) { return Qnil; }
18
+
19
+ return NOKOGIRI_STR_NEW2(node->orig);
20
+ }
21
+
22
+ /*
23
+ * call-seq:
24
+ * content
25
+ *
26
+ * Get the content
27
+ */
28
+ static VALUE
29
+ get_content(VALUE self)
30
+ {
31
+ xmlEntityPtr node;
32
+ Noko_Node_Get_Struct(self, xmlEntity, node);
33
+
34
+ if (!node->content) { return Qnil; }
35
+
36
+ return NOKOGIRI_STR_NEW(node->content, node->length);
37
+ }
38
+
39
+ /*
40
+ * call-seq:
41
+ * entity_type
42
+ *
43
+ * Get the entity type
44
+ */
45
+ static VALUE
46
+ entity_type(VALUE self)
47
+ {
48
+ xmlEntityPtr node;
49
+ Noko_Node_Get_Struct(self, xmlEntity, node);
50
+
51
+ return INT2NUM((int)node->etype);
52
+ }
53
+
54
+ /*
55
+ * call-seq:
56
+ * external_id
57
+ *
58
+ * Get the external identifier for PUBLIC
59
+ */
60
+ static VALUE
61
+ external_id(VALUE self)
62
+ {
63
+ xmlEntityPtr node;
64
+ Noko_Node_Get_Struct(self, xmlEntity, node);
65
+
66
+ if (!node->ExternalID) { return Qnil; }
67
+
68
+ return NOKOGIRI_STR_NEW2(node->ExternalID);
69
+ }
70
+
71
+ /*
72
+ * call-seq:
73
+ * system_id
74
+ *
75
+ * Get the URI for a SYSTEM or PUBLIC Entity
76
+ */
77
+ static VALUE
78
+ system_id(VALUE self)
79
+ {
80
+ xmlEntityPtr node;
81
+ Noko_Node_Get_Struct(self, xmlEntity, node);
82
+
83
+ if (!node->SystemID) { return Qnil; }
84
+
85
+ return NOKOGIRI_STR_NEW2(node->SystemID);
86
+ }
87
+
88
+ void
89
+ noko_init_xml_entity_decl(void)
90
+ {
91
+ assert(cNokogiriXmlNode);
92
+ cNokogiriXmlEntityDecl = rb_define_class_under(mNokogiriXml, "EntityDecl", cNokogiriXmlNode);
93
+
94
+ rb_define_method(cNokogiriXmlEntityDecl, "original_content", original_content, 0);
95
+ rb_define_method(cNokogiriXmlEntityDecl, "content", get_content, 0);
96
+ rb_define_method(cNokogiriXmlEntityDecl, "entity_type", entity_type, 0);
97
+ rb_define_method(cNokogiriXmlEntityDecl, "external_id", external_id, 0);
98
+ rb_define_method(cNokogiriXmlEntityDecl, "system_id", system_id, 0);
99
+
100
+ rb_const_set(cNokogiriXmlEntityDecl, rb_intern("INTERNAL_GENERAL"),
101
+ INT2NUM(XML_INTERNAL_GENERAL_ENTITY));
102
+ rb_const_set(cNokogiriXmlEntityDecl, rb_intern("EXTERNAL_GENERAL_PARSED"),
103
+ INT2NUM(XML_EXTERNAL_GENERAL_PARSED_ENTITY));
104
+ rb_const_set(cNokogiriXmlEntityDecl, rb_intern("EXTERNAL_GENERAL_UNPARSED"),
105
+ INT2NUM(XML_EXTERNAL_GENERAL_UNPARSED_ENTITY));
106
+ rb_const_set(cNokogiriXmlEntityDecl, rb_intern("INTERNAL_PARAMETER"),
107
+ INT2NUM(XML_INTERNAL_PARAMETER_ENTITY));
108
+ rb_const_set(cNokogiriXmlEntityDecl, rb_intern("EXTERNAL_PARAMETER"),
109
+ INT2NUM(XML_EXTERNAL_PARAMETER_ENTITY));
110
+ rb_const_set(cNokogiriXmlEntityDecl, rb_intern("INTERNAL_PREDEFINED"),
111
+ INT2NUM(XML_INTERNAL_PREDEFINED_ENTITY));
112
+ }
@@ -0,0 +1,50 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlEntityReference;
4
+
5
+ /*
6
+ * call-seq:
7
+ * new(document, content)
8
+ *
9
+ * Create a new EntityReference element on the +document+ with +name+
10
+ */
11
+ static VALUE
12
+ new (int argc, VALUE *argv, VALUE klass)
13
+ {
14
+ xmlDocPtr xml_doc;
15
+ xmlNodePtr node;
16
+ VALUE document;
17
+ VALUE name;
18
+ VALUE rest;
19
+ VALUE rb_node;
20
+
21
+ rb_scan_args(argc, argv, "2*", &document, &name, &rest);
22
+
23
+ xml_doc = noko_xml_document_unwrap(document);
24
+
25
+ node = xmlNewReference(
26
+ xml_doc,
27
+ (const xmlChar *)StringValueCStr(name)
28
+ );
29
+
30
+ noko_xml_document_pin_node(node);
31
+
32
+ rb_node = noko_xml_node_wrap(klass, node);
33
+ rb_obj_call_init(rb_node, argc, argv);
34
+
35
+ if (rb_block_given_p()) { rb_yield(rb_node); }
36
+
37
+ return rb_node;
38
+ }
39
+
40
+ void
41
+ noko_init_xml_entity_reference(void)
42
+ {
43
+ assert(cNokogiriXmlNode);
44
+ /*
45
+ * EntityReference represents an EntityReference node in an xml document.
46
+ */
47
+ cNokogiriXmlEntityReference = rb_define_class_under(mNokogiriXml, "EntityReference", cNokogiriXmlNode);
48
+
49
+ rb_define_singleton_method(cNokogiriXmlEntityReference, "new", new, -1);
50
+ }