nokogiri 1.13.0-x64-mingw-ucrt

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.

Files changed (195) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/LICENSE-DEPENDENCIES.md +1903 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +280 -0
  6. data/bin/nokogiri +131 -0
  7. data/dependencies.yml +73 -0
  8. data/ext/nokogiri/depend +38 -0
  9. data/ext/nokogiri/extconf.rb +1000 -0
  10. data/ext/nokogiri/gumbo.c +584 -0
  11. data/ext/nokogiri/html4_document.c +166 -0
  12. data/ext/nokogiri/html4_element_description.c +294 -0
  13. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  14. data/ext/nokogiri/html4_sax_parser_context.c +120 -0
  15. data/ext/nokogiri/html4_sax_push_parser.c +95 -0
  16. data/ext/nokogiri/include/libexslt/exslt.h +102 -0
  17. data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
  18. data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
  19. data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -0
  20. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
  21. data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
  22. data/ext/nokogiri/include/libxml2/libxml/SAX.h +173 -0
  23. data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
  24. data/ext/nokogiri/include/libxml2/libxml/c14n.h +128 -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 +79 -0
  29. data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
  30. data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
  31. data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -0
  32. data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
  33. data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
  34. data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +163 -0
  35. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
  36. data/ext/nokogiri/include/libxml2/libxml/parser.h +1243 -0
  37. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
  38. data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
  39. data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -0
  40. data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
  41. data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
  42. data/ext/nokogiri/include/libxml2/libxml/threads.h +89 -0
  43. data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
  44. data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
  45. data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -0
  46. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
  47. data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
  48. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +368 -0
  49. data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
  50. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +946 -0
  51. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +77 -0
  52. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -0
  53. data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
  54. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
  55. data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
  56. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
  57. data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
  58. data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +151 -0
  59. data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
  60. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
  61. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +485 -0
  62. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
  63. data/ext/nokogiri/include/libxml2/libxml/xpath.h +564 -0
  64. data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
  65. data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -0
  66. data/ext/nokogiri/include/libxslt/attributes.h +38 -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 +1978 -0
  83. data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
  84. data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
  85. data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
  86. data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
  87. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  88. data/ext/nokogiri/nokogiri.c +278 -0
  89. data/ext/nokogiri/nokogiri.h +223 -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 +57 -0
  94. data/ext/nokogiri/xml_comment.c +62 -0
  95. data/ext/nokogiri/xml_document.c +680 -0
  96. data/ext/nokogiri/xml_document_fragment.c +44 -0
  97. data/ext/nokogiri/xml_dtd.c +208 -0
  98. data/ext/nokogiri/xml_element_content.c +128 -0
  99. data/ext/nokogiri/xml_element_decl.c +69 -0
  100. data/ext/nokogiri/xml_encoding_handler.c +104 -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 +120 -0
  104. data/ext/nokogiri/xml_node.c +2144 -0
  105. data/ext/nokogiri/xml_node_set.c +498 -0
  106. data/ext/nokogiri/xml_processing_instruction.c +54 -0
  107. data/ext/nokogiri/xml_reader.c +719 -0
  108. data/ext/nokogiri/xml_relax_ng.c +185 -0
  109. data/ext/nokogiri/xml_sax_parser.c +310 -0
  110. data/ext/nokogiri/xml_sax_parser_context.c +281 -0
  111. data/ext/nokogiri/xml_sax_push_parser.c +168 -0
  112. data/ext/nokogiri/xml_schema.c +284 -0
  113. data/ext/nokogiri/xml_syntax_error.c +85 -0
  114. data/ext/nokogiri/xml_text.c +48 -0
  115. data/ext/nokogiri/xml_xpath_context.c +406 -0
  116. data/ext/nokogiri/xslt_stylesheet.c +264 -0
  117. data/gumbo-parser/CHANGES.md +63 -0
  118. data/gumbo-parser/Makefile +101 -0
  119. data/gumbo-parser/THANKS +27 -0
  120. data/lib/nokogiri/3.1/nokogiri.so +0 -0
  121. data/lib/nokogiri/class_resolver.rb +67 -0
  122. data/lib/nokogiri/css/node.rb +54 -0
  123. data/lib/nokogiri/css/parser.rb +759 -0
  124. data/lib/nokogiri/css/parser.y +280 -0
  125. data/lib/nokogiri/css/parser_extras.rb +94 -0
  126. data/lib/nokogiri/css/syntax_error.rb +9 -0
  127. data/lib/nokogiri/css/tokenizer.rb +155 -0
  128. data/lib/nokogiri/css/tokenizer.rex +56 -0
  129. data/lib/nokogiri/css/xpath_visitor.rb +359 -0
  130. data/lib/nokogiri/css.rb +60 -0
  131. data/lib/nokogiri/decorators/slop.rb +44 -0
  132. data/lib/nokogiri/extension.rb +31 -0
  133. data/lib/nokogiri/gumbo.rb +15 -0
  134. data/lib/nokogiri/html.rb +48 -0
  135. data/lib/nokogiri/html4/builder.rb +37 -0
  136. data/lib/nokogiri/html4/document.rb +331 -0
  137. data/lib/nokogiri/html4/document_fragment.rb +54 -0
  138. data/lib/nokogiri/html4/element_description.rb +25 -0
  139. data/lib/nokogiri/html4/element_description_defaults.rb +578 -0
  140. data/lib/nokogiri/html4/entity_lookup.rb +15 -0
  141. data/lib/nokogiri/html4/sax/parser.rb +61 -0
  142. data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
  143. data/lib/nokogiri/html4/sax/push_parser.rb +37 -0
  144. data/lib/nokogiri/html4.rb +46 -0
  145. data/lib/nokogiri/html5/document.rb +88 -0
  146. data/lib/nokogiri/html5/document_fragment.rb +83 -0
  147. data/lib/nokogiri/html5/node.rb +96 -0
  148. data/lib/nokogiri/html5.rb +477 -0
  149. data/lib/nokogiri/jruby/dependencies.rb +21 -0
  150. data/lib/nokogiri/syntax_error.rb +6 -0
  151. data/lib/nokogiri/version/constant.rb +6 -0
  152. data/lib/nokogiri/version/info.rb +221 -0
  153. data/lib/nokogiri/version.rb +4 -0
  154. data/lib/nokogiri/xml/attr.rb +17 -0
  155. data/lib/nokogiri/xml/attribute_decl.rb +20 -0
  156. data/lib/nokogiri/xml/builder.rb +485 -0
  157. data/lib/nokogiri/xml/cdata.rb +13 -0
  158. data/lib/nokogiri/xml/character_data.rb +9 -0
  159. data/lib/nokogiri/xml/document.rb +418 -0
  160. data/lib/nokogiri/xml/document_fragment.rb +162 -0
  161. data/lib/nokogiri/xml/dtd.rb +34 -0
  162. data/lib/nokogiri/xml/element_content.rb +38 -0
  163. data/lib/nokogiri/xml/element_decl.rb +15 -0
  164. data/lib/nokogiri/xml/entity_decl.rb +21 -0
  165. data/lib/nokogiri/xml/entity_reference.rb +20 -0
  166. data/lib/nokogiri/xml/namespace.rb +16 -0
  167. data/lib/nokogiri/xml/node/save_options.rb +65 -0
  168. data/lib/nokogiri/xml/node.rb +1402 -0
  169. data/lib/nokogiri/xml/node_set.rb +364 -0
  170. data/lib/nokogiri/xml/notation.rb +19 -0
  171. data/lib/nokogiri/xml/parse_options.rb +133 -0
  172. data/lib/nokogiri/xml/pp/character_data.rb +21 -0
  173. data/lib/nokogiri/xml/pp/node.rb +55 -0
  174. data/lib/nokogiri/xml/pp.rb +4 -0
  175. data/lib/nokogiri/xml/processing_instruction.rb +10 -0
  176. data/lib/nokogiri/xml/reader.rb +107 -0
  177. data/lib/nokogiri/xml/relax_ng.rb +38 -0
  178. data/lib/nokogiri/xml/sax/document.rb +167 -0
  179. data/lib/nokogiri/xml/sax/parser.rb +125 -0
  180. data/lib/nokogiri/xml/sax/parser_context.rb +21 -0
  181. data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
  182. data/lib/nokogiri/xml/sax.rb +6 -0
  183. data/lib/nokogiri/xml/schema.rb +73 -0
  184. data/lib/nokogiri/xml/searchable.rb +259 -0
  185. data/lib/nokogiri/xml/syntax_error.rb +71 -0
  186. data/lib/nokogiri/xml/text.rb +11 -0
  187. data/lib/nokogiri/xml/xpath/syntax_error.rb +13 -0
  188. data/lib/nokogiri/xml/xpath.rb +21 -0
  189. data/lib/nokogiri/xml/xpath_context.rb +16 -0
  190. data/lib/nokogiri/xml.rb +75 -0
  191. data/lib/nokogiri/xslt/stylesheet.rb +27 -0
  192. data/lib/nokogiri/xslt.rb +58 -0
  193. data/lib/nokogiri.rb +128 -0
  194. data/lib/xsd/xmlparser/nokogiri.rb +104 -0
  195. metadata +536 -0
@@ -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
+ Data_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
+ Data_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
+ Data_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
+ Data_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
+ Data_Get_Struct(self, xmlDtd, dtd);
142
+ Data_Get_Struct(document, xmlDoc, doc);
143
+ error_list = rb_ary_new();
144
+
145
+ ctxt = xmlNewValidCtxt();
146
+
147
+ xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_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
+ Data_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
+ Data_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()
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,128 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlElementContent;
4
+
5
+ /*
6
+ * call-seq:
7
+ * name
8
+ *
9
+ * Get the require element +name+
10
+ */
11
+ static VALUE
12
+ get_name(VALUE self)
13
+ {
14
+ xmlElementContentPtr elem;
15
+ Data_Get_Struct(self, xmlElementContent, elem);
16
+
17
+ if (!elem->name) { return Qnil; }
18
+ return NOKOGIRI_STR_NEW2(elem->name);
19
+ }
20
+
21
+ /*
22
+ * call-seq:
23
+ * type
24
+ *
25
+ * Get the element content +type+. Possible values are PCDATA, ELEMENT, SEQ,
26
+ * or OR.
27
+ */
28
+ static VALUE
29
+ get_type(VALUE self)
30
+ {
31
+ xmlElementContentPtr elem;
32
+ Data_Get_Struct(self, xmlElementContent, elem);
33
+
34
+ return INT2NUM((long)elem->type);
35
+ }
36
+
37
+ /*
38
+ * call-seq:
39
+ * c1
40
+ *
41
+ * Get the first child.
42
+ */
43
+ static VALUE
44
+ get_c1(VALUE self)
45
+ {
46
+ xmlElementContentPtr elem;
47
+ Data_Get_Struct(self, xmlElementContent, elem);
48
+
49
+ if (!elem->c1) { return Qnil; }
50
+ return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c1);
51
+ }
52
+
53
+ /*
54
+ * call-seq:
55
+ * c2
56
+ *
57
+ * Get the first child.
58
+ */
59
+ static VALUE
60
+ get_c2(VALUE self)
61
+ {
62
+ xmlElementContentPtr elem;
63
+ Data_Get_Struct(self, xmlElementContent, elem);
64
+
65
+ if (!elem->c2) { return Qnil; }
66
+ return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c2);
67
+ }
68
+
69
+ /*
70
+ * call-seq:
71
+ * occur
72
+ *
73
+ * Get the element content +occur+ flag. Possible values are ONCE, OPT, MULT
74
+ * or PLUS.
75
+ */
76
+ static VALUE
77
+ get_occur(VALUE self)
78
+ {
79
+ xmlElementContentPtr elem;
80
+ Data_Get_Struct(self, xmlElementContent, elem);
81
+
82
+ return INT2NUM((long)elem->ocur);
83
+ }
84
+
85
+ /*
86
+ * call-seq:
87
+ * prefix
88
+ *
89
+ * Get the element content namespace +prefix+.
90
+ */
91
+ static VALUE
92
+ get_prefix(VALUE self)
93
+ {
94
+ xmlElementContentPtr elem;
95
+ Data_Get_Struct(self, xmlElementContent, elem);
96
+
97
+ if (!elem->prefix) { return Qnil; }
98
+
99
+ return NOKOGIRI_STR_NEW2(elem->prefix);
100
+ }
101
+
102
+ VALUE
103
+ noko_xml_element_content_wrap(VALUE doc, xmlElementContentPtr element)
104
+ {
105
+ VALUE elem = Data_Wrap_Struct(cNokogiriXmlElementContent, 0, 0, element);
106
+
107
+ /* Setting the document is necessary so that this does not get GC'd until */
108
+ /* the document is GC'd */
109
+ rb_iv_set(elem, "@document", doc);
110
+
111
+ return elem;
112
+ }
113
+
114
+ void
115
+ noko_init_xml_element_content()
116
+ {
117
+ cNokogiriXmlElementContent = rb_define_class_under(mNokogiriXml, "ElementContent", rb_cObject);
118
+
119
+ rb_undef_alloc_func(cNokogiriXmlElementContent);
120
+
121
+ rb_define_method(cNokogiriXmlElementContent, "name", get_name, 0);
122
+ rb_define_method(cNokogiriXmlElementContent, "type", get_type, 0);
123
+ rb_define_method(cNokogiriXmlElementContent, "occur", get_occur, 0);
124
+ rb_define_method(cNokogiriXmlElementContent, "prefix", get_prefix, 0);
125
+
126
+ rb_define_private_method(cNokogiriXmlElementContent, "c1", get_c1, 0);
127
+ rb_define_private_method(cNokogiriXmlElementContent, "c2", get_c2, 0);
128
+ }
@@ -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
10
+ *
11
+ * The element_type
12
+ */
13
+ static VALUE
14
+ element_type(VALUE self)
15
+ {
16
+ xmlElementPtr node;
17
+ Data_Get_Struct(self, xmlElement, node);
18
+ return INT2NUM((long)node->etype);
19
+ }
20
+
21
+ /*
22
+ * call-seq:
23
+ * content
24
+ *
25
+ * The allowed content for this ElementDecl
26
+ */
27
+ static VALUE
28
+ content(VALUE self)
29
+ {
30
+ xmlElementPtr node;
31
+ Data_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
44
+ *
45
+ * The namespace prefix for this ElementDecl
46
+ */
47
+ static VALUE
48
+ prefix(VALUE self)
49
+ {
50
+ xmlElementPtr node;
51
+ Data_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()
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,104 @@
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriEncodingHandler;
4
+
5
+
6
+ static void
7
+ _xml_encoding_handler_dealloc(xmlCharEncodingHandlerPtr c_handler)
8
+ {
9
+ /* make sure iconv handlers are cleaned up and freed */
10
+ xmlCharEncCloseFunc(c_handler);
11
+ }
12
+
13
+
14
+ /*
15
+ * call-seq: Nokogiri::EncodingHandler.[](name)
16
+ *
17
+ * Get the encoding handler for +name+
18
+ */
19
+ static VALUE
20
+ rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
21
+ {
22
+ xmlCharEncodingHandlerPtr handler;
23
+
24
+ handler = xmlFindCharEncodingHandler(StringValueCStr(key));
25
+ if (handler) {
26
+ return Data_Wrap_Struct(klass, NULL, _xml_encoding_handler_dealloc, handler);
27
+ }
28
+
29
+ return Qnil;
30
+ }
31
+
32
+
33
+ /*
34
+ * call-seq: Nokogiri::EncodingHandler.delete(name)
35
+ *
36
+ * Delete the encoding alias named +name+
37
+ */
38
+ static VALUE
39
+ rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
40
+ {
41
+ if (xmlDelEncodingAlias(StringValueCStr(name))) { return Qnil; }
42
+
43
+ return Qtrue;
44
+ }
45
+
46
+
47
+ /*
48
+ * call-seq: Nokogiri::EncodingHandler.alias(from, to)
49
+ *
50
+ * Alias encoding handler with name +from+ to name +to+
51
+ */
52
+ static VALUE
53
+ rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
54
+ {
55
+ xmlAddEncodingAlias(StringValueCStr(from), StringValueCStr(to));
56
+
57
+ return to;
58
+ }
59
+
60
+
61
+ /*
62
+ * call-seq: Nokogiri::EncodingHandler.clear_aliases!
63
+ *
64
+ * Remove all encoding aliases.
65
+ */
66
+ static VALUE
67
+ rb_xml_encoding_handler_s_clear_aliases(VALUE klass)
68
+ {
69
+ xmlCleanupEncodingAliases();
70
+
71
+ return klass;
72
+ }
73
+
74
+
75
+ /*
76
+ * call-seq: name
77
+ *
78
+ * Get the name of this EncodingHandler
79
+ */
80
+ static VALUE
81
+ rb_xml_encoding_handler_name(VALUE self)
82
+ {
83
+ xmlCharEncodingHandlerPtr handler;
84
+
85
+ Data_Get_Struct(self, xmlCharEncodingHandler, handler);
86
+
87
+ return NOKOGIRI_STR_NEW2(handler->name);
88
+ }
89
+
90
+
91
+ void
92
+ noko_init_xml_encoding_handler()
93
+ {
94
+ cNokogiriEncodingHandler = rb_define_class_under(mNokogiri, "EncodingHandler", rb_cObject);
95
+
96
+ rb_undef_alloc_func(cNokogiriEncodingHandler);
97
+
98
+ rb_define_singleton_method(cNokogiriEncodingHandler, "[]", rb_xml_encoding_handler_s_get, 1);
99
+ rb_define_singleton_method(cNokogiriEncodingHandler, "delete", rb_xml_encoding_handler_s_delete, 1);
100
+ rb_define_singleton_method(cNokogiriEncodingHandler, "alias", rb_xml_encoding_handler_s_alias, 2);
101
+ rb_define_singleton_method(cNokogiriEncodingHandler, "clear_aliases!", rb_xml_encoding_handler_s_clear_aliases, 0);
102
+
103
+ rb_define_method(cNokogiriEncodingHandler, "name", rb_xml_encoding_handler_name, 0);
104
+ }
@@ -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
+ Data_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
+ Data_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
+ Data_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
+ Data_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
+ Data_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()
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
+ Data_Get_Struct(document, xmlDoc, xml_doc);
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()
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
+ }