nokogiri 1.4.7-java → 1.5.0.beta.1-java
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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.ja.rdoc +8 -83
- data/CHANGELOG.rdoc +6 -80
- data/Manifest.txt +4 -74
- data/README.ja.rdoc +5 -1
- data/README.rdoc +8 -22
- data/Rakefile +79 -60
- data/bin/nokogiri +1 -6
- data/deps.rip +5 -0
- data/ext/nokogiri/extconf.rb +32 -53
- data/ext/nokogiri/nokogiri.c +0 -2
- data/ext/nokogiri/nokogiri.h +0 -9
- data/ext/nokogiri/xml_document.c +0 -14
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_io.c +7 -32
- data/ext/nokogiri/xml_node.c +31 -103
- data/ext/nokogiri/xml_node_set.c +8 -8
- data/ext/nokogiri/xml_reader.c +1 -20
- data/ext/nokogiri/xml_sax_parser.c +3 -5
- data/ext/nokogiri/xml_sax_parser_context.c +0 -40
- data/ext/nokogiri/xml_xpath_context.c +2 -35
- data/ext/nokogiri/xslt_stylesheet.c +6 -124
- 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.rb +7 -3
- data/lib/nokogiri/css.rb +3 -6
- data/lib/nokogiri/css/generated_parser.rb +669 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +145 -0
- data/lib/nokogiri/css/parser.rb +70 -665
- data/lib/nokogiri/css/parser.y +1 -6
- data/lib/nokogiri/css/tokenizer.rb +3 -148
- data/lib/nokogiri/css/tokenizer.rex +1 -1
- data/lib/nokogiri/css/xpath_visitor.rb +14 -16
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/html.rb +3 -2
- data/lib/nokogiri/html/document.rb +18 -134
- data/lib/nokogiri/html/document_fragment.rb +21 -26
- data/lib/nokogiri/html/element_description_defaults.rb +671 -0
- data/lib/nokogiri/html/sax/parser.rb +2 -6
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +4 -9
- data/lib/nokogiri/xml/attribute_decl.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +3 -27
- data/lib/nokogiri/xml/document_fragment.rb +2 -9
- data/lib/nokogiri/xml/dtd.rb +1 -12
- data/lib/nokogiri/xml/element_decl.rb +1 -1
- data/lib/nokogiri/xml/entity_decl.rb +1 -1
- data/lib/nokogiri/xml/node.rb +75 -172
- data/lib/nokogiri/xml/node/save_options.rb +0 -10
- data/lib/nokogiri/xml/node_set.rb +3 -28
- data/lib/nokogiri/xml/parse_options.rb +0 -8
- data/lib/nokogiri/xml/reader.rb +6 -44
- data/lib/nokogiri/xml/sax/document.rb +5 -9
- data/lib/nokogiri/xml/schema.rb +1 -7
- data/lib/nokogiri/xslt.rb +5 -9
- data/lib/xercesImpl.jar +0 -0
- data/tasks/cross_compile.rb +12 -27
- data/tasks/test.rb +0 -0
- data/test/css/test_parser.rb +19 -40
- data/test/css/test_tokenizer.rb +0 -8
- data/test/helper.rb +1 -4
- data/test/html/sax/test_parser.rb +21 -47
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +3 -58
- data/test/html/test_document_encoding.rb +0 -53
- data/test/html/test_document_fragment.rb +13 -82
- data/test/html/test_element_description.rb +4 -2
- data/test/html/test_node.rb +0 -9
- data/test/test_memory_leak.rb +2 -57
- data/test/test_nokogiri.rb +14 -20
- data/test/test_reader.rb +7 -47
- data/test/test_xslt_transforms.rb +5 -8
- data/test/xml/sax/test_parser.rb +17 -34
- data/test/xml/sax/test_parser_context.rb +0 -50
- data/test/xml/sax/test_push_parser.rb +1 -18
- data/test/xml/test_attr.rb +4 -31
- data/test/xml/test_attribute_decl.rb +7 -3
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +18 -15
- data/test/xml/test_document_fragment.rb +20 -19
- data/test/xml/test_dtd.rb +13 -18
- data/test/xml/test_element_content.rb +1 -1
- data/test/xml/test_element_decl.rb +1 -1
- data/test/xml/test_entity_decl.rb +12 -10
- data/test/xml/test_namespace.rb +7 -5
- data/test/xml/test_node.rb +15 -54
- data/test/xml/test_node_reparenting.rb +42 -85
- data/test/xml/test_node_set.rb +2 -61
- data/test/xml/test_schema.rb +0 -5
- data/test/xml/test_text.rb +2 -11
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +7 -43
- metadata +442 -473
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
- data/ext/nokogiri/depend +0 -358
- data/ext/nokogiri/libcharset-1.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libiconv-2.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/nokogiri/css/parser_extras.rb +0 -91
- data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
- data/lib/nokogiri/ffi/html/document.rb +0 -28
- data/lib/nokogiri/ffi/html/element_description.rb +0 -81
- data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
- data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
- data/lib/nokogiri/ffi/libxml.rb +0 -420
- data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
- data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
- data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
- data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
- data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -20
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
- data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
- data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
- data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
- data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
- data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
- data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
- data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
- data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
- data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -20
- data/lib/nokogiri/ffi/structs/xml_parser_input.rb +0 -19
- data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
- data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
- data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
- data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
- data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
- data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
- data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
- data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
- data/lib/nokogiri/ffi/xml/attr.rb +0 -41
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
- data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
- data/lib/nokogiri/ffi/xml/comment.rb +0 -18
- data/lib/nokogiri/ffi/xml/document.rb +0 -174
- data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
- data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
- data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
- data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
- data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
- data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
- data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
- data/lib/nokogiri/ffi/xml/node.rb +0 -559
- data/lib/nokogiri/ffi/xml/node_set.rb +0 -150
- data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
- data/lib/nokogiri/ffi/xml/reader.rb +0 -236
- data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
- data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -143
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -79
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
- data/lib/nokogiri/ffi/xml/schema.rb +0 -109
- data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
- data/lib/nokogiri/ffi/xml/text.rb +0 -18
- data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
- data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -153
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -77
- data/test/decorators/test_slop.rb +0 -16
- data/test/ffi/test_document.rb +0 -35
- data/test/files/encoding.html +0 -82
- data/test/files/encoding.xhtml +0 -84
- data/test/xslt/test_custom_functions.rb +0 -94
data/ext/nokogiri/xml_node_set.c
CHANGED
@@ -49,8 +49,8 @@ static VALUE push(VALUE self, VALUE rb_node)
|
|
49
49
|
xmlNodeSetPtr node_set;
|
50
50
|
xmlNodePtr node;
|
51
51
|
|
52
|
-
if(!
|
53
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node
|
52
|
+
if(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
53
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
54
54
|
|
55
55
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
56
56
|
Data_Get_Struct(rb_node, xmlNode, node);
|
@@ -70,9 +70,9 @@ static VALUE delete(VALUE self, VALUE rb_node)
|
|
70
70
|
xmlNodeSetPtr node_set ;
|
71
71
|
xmlNodePtr node ;
|
72
72
|
|
73
|
-
if(!
|
74
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node
|
75
|
-
|
73
|
+
if(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
74
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
75
|
+
|
76
76
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
77
77
|
Data_Get_Struct(rb_node, xmlNode, node);
|
78
78
|
|
@@ -117,8 +117,8 @@ static VALUE include_eh(VALUE self, VALUE rb_node)
|
|
117
117
|
xmlNodeSetPtr node_set;
|
118
118
|
xmlNodePtr node;
|
119
119
|
|
120
|
-
if(!
|
121
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node
|
120
|
+
if(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
121
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
122
122
|
|
123
123
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
124
124
|
Data_Get_Struct(rb_node, xmlNode, node);
|
@@ -257,7 +257,7 @@ static VALUE slice(int argc, VALUE *argv, VALUE self)
|
|
257
257
|
}
|
258
258
|
|
259
259
|
/* if arg is Range */
|
260
|
-
switch (rb_range_beg_len(arg, &beg, &len,
|
260
|
+
switch (rb_range_beg_len(arg, &beg, &len, node_set->nodeNr, 0)) {
|
261
261
|
case Qfalse:
|
262
262
|
break;
|
263
263
|
case Qnil:
|
data/ext/nokogiri/xml_reader.c
CHANGED
@@ -523,7 +523,7 @@ static VALUE outer_xml(VALUE self)
|
|
523
523
|
Data_Get_Struct(self, xmlTextReader, reader);
|
524
524
|
|
525
525
|
value = xmlTextReaderReadOuterXml(reader);
|
526
|
-
|
526
|
+
|
527
527
|
if(value) {
|
528
528
|
str = NOKOGIRI_STR_NEW2((char*)value);
|
529
529
|
xmlFree(value);
|
@@ -620,24 +620,6 @@ static VALUE from_io(int argc, VALUE *argv, VALUE klass)
|
|
620
620
|
return rb_reader;
|
621
621
|
}
|
622
622
|
|
623
|
-
/*
|
624
|
-
* call-seq:
|
625
|
-
* reader.empty_element? # => true or false
|
626
|
-
*
|
627
|
-
* Returns true if the current node is empty, otherwise false.
|
628
|
-
*/
|
629
|
-
static VALUE empty_element_p(VALUE self)
|
630
|
-
{
|
631
|
-
xmlTextReaderPtr reader;
|
632
|
-
|
633
|
-
Data_Get_Struct(self, xmlTextReader, reader);
|
634
|
-
|
635
|
-
if(xmlTextReaderIsEmptyElement(reader))
|
636
|
-
return Qtrue;
|
637
|
-
|
638
|
-
return Qfalse;
|
639
|
-
}
|
640
|
-
|
641
623
|
VALUE cNokogiriXmlReader;
|
642
624
|
|
643
625
|
void init_xml_reader()
|
@@ -674,7 +656,6 @@ void init_xml_reader()
|
|
674
656
|
rb_define_method(klass, "attribute", reader_attribute, 1);
|
675
657
|
rb_define_method(klass, "namespaces", namespaces, 0);
|
676
658
|
rb_define_method(klass, "attribute_at", attribute_at, 1);
|
677
|
-
rb_define_method(klass, "empty_element?", empty_element_p, 0);
|
678
659
|
rb_define_method(klass, "attributes?", attributes_eh, 0);
|
679
660
|
rb_define_method(klass, "value?", value_eh, 0);
|
680
661
|
rb_define_method(klass, "default?", default_eh, 0);
|
@@ -62,10 +62,8 @@ static void start_element(void * ctx, const xmlChar *name, const xmlChar **atts)
|
|
62
62
|
int i = 0;
|
63
63
|
if(atts) {
|
64
64
|
while((attr = atts[i]) != NULL) {
|
65
|
-
|
66
|
-
|
67
|
-
rb_ary_push(attributes, rb_ary_new3(2, NOKOGIRI_STR_NEW2(attr), value));
|
68
|
-
i+=2;
|
65
|
+
rb_ary_push(attributes, NOKOGIRI_STR_NEW2(attr));
|
66
|
+
i++;
|
69
67
|
}
|
70
68
|
}
|
71
69
|
|
@@ -240,7 +238,7 @@ static void deallocate(xmlSAXHandlerPtr handler)
|
|
240
238
|
|
241
239
|
static VALUE allocate(VALUE klass)
|
242
240
|
{
|
243
|
-
xmlSAXHandlerPtr handler = calloc(
|
241
|
+
xmlSAXHandlerPtr handler = calloc(1, sizeof(xmlSAXHandler));
|
244
242
|
|
245
243
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
246
244
|
|
@@ -140,44 +140,6 @@ static VALUE get_replace_entities(VALUE self)
|
|
140
140
|
return Qtrue;
|
141
141
|
}
|
142
142
|
|
143
|
-
/*
|
144
|
-
* call-seq: line
|
145
|
-
*
|
146
|
-
* Get the current line the parser context is processing.
|
147
|
-
*/
|
148
|
-
static VALUE line(VALUE self)
|
149
|
-
{
|
150
|
-
xmlParserCtxtPtr ctxt;
|
151
|
-
xmlParserInputPtr io;
|
152
|
-
|
153
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
154
|
-
|
155
|
-
io = ctxt->input;
|
156
|
-
if(io)
|
157
|
-
return INT2NUM(io->line);
|
158
|
-
|
159
|
-
return Qnil;
|
160
|
-
}
|
161
|
-
|
162
|
-
/*
|
163
|
-
* call-seq: column
|
164
|
-
*
|
165
|
-
* Get the current column the parser context is processing.
|
166
|
-
*/
|
167
|
-
static VALUE column(VALUE self)
|
168
|
-
{
|
169
|
-
xmlParserCtxtPtr ctxt;
|
170
|
-
xmlParserInputPtr io;
|
171
|
-
|
172
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
173
|
-
|
174
|
-
io = ctxt->input;
|
175
|
-
if(io)
|
176
|
-
return INT2NUM(io->col);
|
177
|
-
|
178
|
-
return Qnil;
|
179
|
-
}
|
180
|
-
|
181
143
|
void init_xml_sax_parser_context()
|
182
144
|
{
|
183
145
|
VALUE nokogiri = rb_define_module("Nokogiri");
|
@@ -194,6 +156,4 @@ void init_xml_sax_parser_context()
|
|
194
156
|
rb_define_method(klass, "parse_with", parse_with, 1);
|
195
157
|
rb_define_method(klass, "replace_entities=", set_replace_entities, 1);
|
196
158
|
rb_define_method(klass, "replace_entities", get_replace_entities, 0);
|
197
|
-
rb_define_method(klass, "line", line, 0);
|
198
|
-
rb_define_method(klass, "column", column, 0);
|
199
159
|
}
|
@@ -27,28 +27,6 @@ static VALUE register_ns(VALUE self, VALUE prefix, VALUE uri)
|
|
27
27
|
return self;
|
28
28
|
}
|
29
29
|
|
30
|
-
/*
|
31
|
-
* call-seq:
|
32
|
-
* register_variable(name, value)
|
33
|
-
*
|
34
|
-
* Register the variable +name+ with +value+.
|
35
|
-
*/
|
36
|
-
static VALUE register_variable(VALUE self, VALUE name, VALUE value)
|
37
|
-
{
|
38
|
-
xmlXPathContextPtr ctx;
|
39
|
-
xmlXPathObjectPtr xmlValue;
|
40
|
-
Data_Get_Struct(self, xmlXPathContext, ctx);
|
41
|
-
|
42
|
-
xmlValue = xmlXPathNewCString(StringValuePtr(value));
|
43
|
-
|
44
|
-
xmlXPathRegisterVariable( ctx,
|
45
|
-
(const xmlChar *)StringValuePtr(name),
|
46
|
-
xmlValue
|
47
|
-
);
|
48
|
-
|
49
|
-
return self;
|
50
|
-
}
|
51
|
-
|
52
30
|
static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
|
53
31
|
{
|
54
32
|
VALUE xpath_handler = Qnil;
|
@@ -68,11 +46,7 @@ static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
|
|
68
46
|
|
69
47
|
xpath_handler = (VALUE)(ctx->context->userData);
|
70
48
|
|
71
|
-
argv = (VALUE *)calloc((
|
72
|
-
for (i = 0 ; i < nargs ; ++i) {
|
73
|
-
rb_gc_register_address(&argv[i]);
|
74
|
-
}
|
75
|
-
|
49
|
+
argv = (VALUE *)calloc((unsigned int)nargs, sizeof(VALUE));
|
76
50
|
doc = DOC_RUBY_OBJECT(ctx->context->doc);
|
77
51
|
|
78
52
|
i = nargs - 1;
|
@@ -103,10 +77,6 @@ static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
|
|
103
77
|
nargs,
|
104
78
|
argv
|
105
79
|
);
|
106
|
-
|
107
|
-
for (i = 0 ; i < nargs ; ++i) {
|
108
|
-
rb_gc_unregister_address(&argv[i]);
|
109
|
-
}
|
110
80
|
free(argv);
|
111
81
|
|
112
82
|
switch(TYPE(result)) {
|
@@ -186,7 +156,7 @@ static void xpath_generic_exception_handler(void * ctx, const char *msg, ...)
|
|
186
156
|
|
187
157
|
/*
|
188
158
|
* call-seq:
|
189
|
-
* evaluate(search_path
|
159
|
+
* evaluate(search_path)
|
190
160
|
*
|
191
161
|
* Evaluate the +search_path+ returning an XML::XPath object.
|
192
162
|
*/
|
@@ -257,8 +227,6 @@ static VALUE evaluate(int argc, VALUE *argv, VALUE self)
|
|
257
227
|
DOC_RUBY_OBJECT(ctx->doc));
|
258
228
|
}
|
259
229
|
|
260
|
-
xmlXPathFreeNodeSetList(xpath);
|
261
|
-
|
262
230
|
return thing;
|
263
231
|
}
|
264
232
|
|
@@ -304,6 +272,5 @@ void init_xml_xpath_context(void)
|
|
304
272
|
|
305
273
|
rb_define_singleton_method(klass, "new", new, 1);
|
306
274
|
rb_define_method(klass, "evaluate", evaluate, -1);
|
307
|
-
rb_define_method(klass, "register_variable", register_variable, 2);
|
308
275
|
rb_define_method(klass, "register_ns", register_ns, 2);
|
309
276
|
}
|
@@ -5,8 +5,6 @@
|
|
5
5
|
#include <libxslt/transform.h>
|
6
6
|
#include <libexslt/exslt.h>
|
7
7
|
|
8
|
-
VALUE xslt;
|
9
|
-
|
10
8
|
int vasprintf (char **strp, const char *fmt, va_list ap);
|
11
9
|
|
12
10
|
static void dealloc(xsltStylesheetPtr doc)
|
@@ -26,7 +24,7 @@ static void xslt_generic_error_handler(void * ctx, const char *msg, ...)
|
|
26
24
|
vasprintf(&message, msg, args);
|
27
25
|
va_end(args);
|
28
26
|
|
29
|
-
|
27
|
+
rb_raise(rb_eRuntimeError, message);
|
30
28
|
}
|
31
29
|
|
32
30
|
/*
|
@@ -99,9 +97,7 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
|
|
99
97
|
long param_len, j ;
|
100
98
|
|
101
99
|
rb_scan_args(argc, argv, "11", &xmldoc, ¶mobj);
|
102
|
-
if (NIL_P(paramobj)) { paramobj = rb_ary_new2(
|
103
|
-
if (!rb_obj_is_kind_of(xmldoc, cNokogiriXmlDocument))
|
104
|
-
rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::Document");
|
100
|
+
if (NIL_P(paramobj)) { paramobj = rb_ary_new2(0) ; }
|
105
101
|
|
106
102
|
/* handle hashes as arguments. */
|
107
103
|
if(T_HASH == TYPE(paramobj)) {
|
@@ -128,133 +124,19 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
|
|
128
124
|
|
129
125
|
if (!result) rb_raise(rb_eRuntimeError, "could not perform xslt transform on document");
|
130
126
|
|
131
|
-
return Nokogiri_wrap_xml_document(
|
132
|
-
}
|
133
|
-
|
134
|
-
static void method_caller(xmlXPathParserContextPtr ctxt, int nargs)
|
135
|
-
{
|
136
|
-
const xmlChar * function;
|
137
|
-
const xmlChar * functionURI;
|
138
|
-
size_t i, count;
|
139
|
-
|
140
|
-
xsltTransformContextPtr transform;
|
141
|
-
xmlXPathObjectPtr xpath;
|
142
|
-
VALUE obj;
|
143
|
-
VALUE *args;
|
144
|
-
VALUE result;
|
145
|
-
|
146
|
-
transform = xsltXPathGetTransformContext(ctxt);
|
147
|
-
|
148
|
-
function = ctxt->context->function;
|
149
|
-
functionURI = ctxt->context->functionURI;
|
150
|
-
obj = (VALUE)xsltGetExtData(transform, functionURI);
|
151
|
-
|
152
|
-
count = (size_t)ctxt->valueNr;
|
153
|
-
args = calloc(count, sizeof(VALUE *));
|
154
|
-
|
155
|
-
for(i = 0; i < count; i++) {
|
156
|
-
VALUE thing;
|
157
|
-
|
158
|
-
xpath = valuePop(ctxt);
|
159
|
-
switch(xpath->type) {
|
160
|
-
case XPATH_STRING:
|
161
|
-
thing = NOKOGIRI_STR_NEW2(xpath->stringval);
|
162
|
-
break;
|
163
|
-
case XPATH_NODESET:
|
164
|
-
if(NULL == xpath->nodesetval) {
|
165
|
-
thing = Nokogiri_wrap_xml_node_set(
|
166
|
-
xmlXPathNodeSetCreate(NULL),
|
167
|
-
DOC_RUBY_OBJECT(ctxt->context->doc));
|
168
|
-
} else {
|
169
|
-
thing = Nokogiri_wrap_xml_node_set(xpath->nodesetval,
|
170
|
-
DOC_RUBY_OBJECT(ctxt->context->doc));
|
171
|
-
}
|
172
|
-
break;
|
173
|
-
default:
|
174
|
-
rb_raise(rb_eRuntimeError, "do not handle type: %d", xpath->type);
|
175
|
-
}
|
176
|
-
args[i] = thing;
|
177
|
-
}
|
178
|
-
result = rb_funcall3(obj, rb_intern((const char *)function), (int)count, args);
|
179
|
-
switch(TYPE(result)) {
|
180
|
-
case T_FLOAT:
|
181
|
-
case T_BIGNUM:
|
182
|
-
case T_FIXNUM:
|
183
|
-
xmlXPathReturnNumber(ctxt, NUM2DBL(result));
|
184
|
-
break;
|
185
|
-
case T_STRING:
|
186
|
-
xmlXPathReturnString(
|
187
|
-
ctxt,
|
188
|
-
xmlStrdup((xmlChar *)StringValuePtr(result))
|
189
|
-
);
|
190
|
-
break;
|
191
|
-
case T_TRUE:
|
192
|
-
xmlXPathReturnTrue(ctxt);
|
193
|
-
break;
|
194
|
-
case T_FALSE:
|
195
|
-
xmlXPathReturnFalse(ctxt);
|
196
|
-
break;
|
197
|
-
case T_NIL:
|
198
|
-
break;
|
199
|
-
default:
|
200
|
-
rb_raise(rb_eRuntimeError, "Invalid return type");
|
201
|
-
}
|
202
|
-
}
|
203
|
-
|
204
|
-
static void * initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
|
205
|
-
{
|
206
|
-
VALUE modules = rb_iv_get(xslt, "@modules");
|
207
|
-
VALUE obj = rb_hash_aref(modules, rb_str_new2((const char *)uri));
|
208
|
-
VALUE args = { Qfalse };
|
209
|
-
VALUE methods = rb_funcall(obj, rb_intern("instance_methods"), 1, args);
|
210
|
-
int i;
|
211
|
-
|
212
|
-
for(i = 0; i < RARRAY_LEN(methods); i++) {
|
213
|
-
VALUE method_name = rb_obj_as_string(RARRAY_PTR(methods)[i]);
|
214
|
-
xsltRegisterExtFunction(ctxt,
|
215
|
-
(unsigned char *)StringValuePtr(method_name), uri, method_caller);
|
216
|
-
}
|
217
|
-
|
218
|
-
return (void *)rb_class_new_instance(0, NULL, obj);
|
219
|
-
}
|
220
|
-
|
221
|
-
static void shutdownFunc(xsltTransformContextPtr ctxt,
|
222
|
-
const xmlChar *uri, void *data)
|
223
|
-
{
|
224
|
-
}
|
225
|
-
|
226
|
-
/*
|
227
|
-
* call-seq:
|
228
|
-
* register(uri, custom_handler_class)
|
229
|
-
*
|
230
|
-
* Register a class that implements custom XLST transformation functions.
|
231
|
-
*/
|
232
|
-
static VALUE registr(VALUE self, VALUE uri, VALUE obj)
|
233
|
-
{
|
234
|
-
VALUE modules = rb_iv_get(self, "@modules");
|
235
|
-
if(NIL_P(modules)) rb_raise(rb_eRuntimeError, "wtf! @modules isn't set");
|
236
|
-
|
237
|
-
rb_hash_aset(modules, uri, obj);
|
238
|
-
xsltRegisterExtModule((unsigned char *)StringValuePtr(uri), initFunc, shutdownFunc);
|
239
|
-
return self;
|
127
|
+
return Nokogiri_wrap_xml_document(0, result) ;
|
240
128
|
}
|
241
129
|
|
242
130
|
VALUE cNokogiriXsltStylesheet ;
|
243
131
|
void init_xslt_stylesheet()
|
244
132
|
{
|
245
|
-
VALUE nokogiri;
|
246
|
-
VALUE
|
247
|
-
|
248
|
-
nokogiri = rb_define_module("Nokogiri");
|
249
|
-
xslt = rb_define_module_under(nokogiri, "XSLT");
|
250
|
-
klass = rb_define_class_under(xslt, "Stylesheet", rb_cObject);
|
251
|
-
|
252
|
-
rb_iv_set(xslt, "@modules", rb_hash_new());
|
133
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
134
|
+
VALUE xslt = rb_define_module_under(nokogiri, "XSLT");
|
135
|
+
VALUE klass = rb_define_class_under(xslt, "Stylesheet", rb_cObject);
|
253
136
|
|
254
137
|
cNokogiriXsltStylesheet = klass;
|
255
138
|
|
256
139
|
rb_define_singleton_method(klass, "parse_stylesheet_doc", parse_stylesheet_doc, 1);
|
257
|
-
rb_define_singleton_method(xslt, "register", registr, 2);
|
258
140
|
rb_define_method(klass, "serialize", serialize, 1);
|
259
141
|
rb_define_method(klass, "transform", transform, -1);
|
260
142
|
}
|
data/lib/isorelax.jar
ADDED
Binary file
|
data/lib/jing.jar
ADDED
Binary file
|
data/lib/nekodtd.jar
ADDED
Binary file
|
data/lib/nekohtml.jar
ADDED
Binary file
|
data/lib/nokogiri.rb
CHANGED
@@ -6,9 +6,13 @@ ENV['PATH'] = [File.expand_path(
|
|
6
6
|
File.join(File.dirname(__FILE__), "..", "ext", "nokogiri")
|
7
7
|
), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw)/i
|
8
8
|
|
9
|
-
if
|
10
|
-
require '
|
11
|
-
require '
|
9
|
+
if defined? RUBY_ENGINE && RUBY_ENGINE == "jruby"
|
10
|
+
require 'isorelax.jar'
|
11
|
+
require 'jing.jar'
|
12
|
+
require 'nekohtml.jar'
|
13
|
+
require 'nekodtd.jar'
|
14
|
+
require 'xercesImpl.jar'
|
15
|
+
require 'nokogiri/nokogiri'
|
12
16
|
else
|
13
17
|
require 'nokogiri/nokogiri'
|
14
18
|
end
|
data/lib/nokogiri/css.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'nokogiri/css/node'
|
2
2
|
require 'nokogiri/css/xpath_visitor'
|
3
|
-
|
4
|
-
|
5
|
-
$-w = false
|
6
|
-
require 'nokogiri/css/parser'
|
7
|
-
$-w = x
|
8
|
-
|
3
|
+
require 'nokogiri/css/generated_parser'
|
4
|
+
require 'nokogiri/css/generated_tokenizer'
|
9
5
|
require 'nokogiri/css/tokenizer'
|
6
|
+
require 'nokogiri/css/parser'
|
10
7
|
require 'nokogiri/css/syntax_error'
|
11
8
|
|
12
9
|
module Nokogiri
|
@@ -0,0 +1,669 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.6
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
|
10
|
+
module Nokogiri
|
11
|
+
module CSS
|
12
|
+
class GeneratedParser < Racc::Parser
|
13
|
+
##### State transition tables begin ###
|
14
|
+
|
15
|
+
racc_action_table = [
|
16
|
+
3, 55, 26, 21, 12, 24, 56, 3, 81, 1,
|
17
|
+
41, 12, 41, 56, 3, 23, 1, 80, 12, 18,
|
18
|
+
92, 91, 4, 1, 9, 10, 18, 13, 16, 4,
|
19
|
+
12, 9, 10, 18, 13, 16, 4, 12, 9, 10,
|
20
|
+
3, 13, 16, 73, 12, 12, 60, 61, 4, 1,
|
21
|
+
57, 10, 12, 44, 16, 4, 61, 1, 10, 18,
|
22
|
+
41, 16, 4, 4, 9, 10, 10, 13, 16, 16,
|
23
|
+
4, 3, 58, 10, 3, 13, 16, 57, 12, 12,
|
24
|
+
27, 82, 28, 48, 26, 51, 12, 53, 26, 51,
|
25
|
+
18, 53, 83, 18, 4, 9, 4, 4, 9, 10,
|
26
|
+
10, 63, 16, 16, 4, 66, 68, 10, 26, 51,
|
27
|
+
16, 53, 86, 87, 66, 68, 67, 69, 70, 62,
|
28
|
+
72, 59, 90, 54, 64, 67, 69, 70, 93, 72,
|
29
|
+
32, 34, 36, 64, 26, 51, -22, 53, 95, 96,
|
30
|
+
31, nil, 33, 35 ]
|
31
|
+
|
32
|
+
racc_action_check = [
|
33
|
+
0, 20, 3, 3, 0, 3, 43, 30, 52, 0,
|
34
|
+
39, 30, 11, 20, 56, 3, 30, 43, 56, 0,
|
35
|
+
71, 71, 0, 56, 0, 0, 30, 0, 0, 30,
|
36
|
+
8, 30, 30, 56, 30, 30, 56, 6, 56, 56,
|
37
|
+
9, 56, 56, 28, 9, 7, 24, 24, 8, 9,
|
38
|
+
51, 8, 41, 10, 8, 6, 53, 41, 6, 9,
|
39
|
+
7, 6, 9, 7, 9, 9, 7, 9, 9, 7,
|
40
|
+
41, 4, 21, 41, 16, 41, 41, 21, 15, 17,
|
41
|
+
4, 54, 4, 16, 63, 63, 77, 63, 61, 61,
|
42
|
+
4, 61, 55, 16, 14, 4, 15, 17, 16, 15,
|
43
|
+
17, 26, 15, 17, 77, 29, 29, 77, 57, 57,
|
44
|
+
77, 57, 58, 60, 27, 27, 29, 29, 29, 25,
|
45
|
+
29, 22, 65, 19, 29, 27, 27, 27, 74, 27,
|
46
|
+
5, 5, 5, 27, 18, 18, 1, 18, 79, 87,
|
47
|
+
5, nil, 5, 5 ]
|
48
|
+
|
49
|
+
racc_action_pointer = [
|
50
|
+
-2, 108, nil, -8, 69, 123, 31, 39, 24, 38,
|
51
|
+
42, -9, nil, nil, 70, 72, 72, 73, 124, 95,
|
52
|
+
1, 65, 98, nil, 35, 96, 89, 111, 18, 102,
|
53
|
+
5, nil, nil, nil, nil, nil, nil, nil, nil, -11,
|
54
|
+
nil, 46, nil, -6, nil, nil, nil, nil, nil, nil,
|
55
|
+
nil, 38, -15, 44, 70, 92, 12, 98, 99, nil,
|
56
|
+
106, 78, nil, 74, nil, 97, nil, nil, nil, nil,
|
57
|
+
nil, 10, nil, nil, 103, nil, nil, 80, nil, 115,
|
58
|
+
nil, nil, nil, nil, nil, nil, nil, 126, nil, nil,
|
59
|
+
nil, nil, nil, nil, nil, nil, nil ]
|
60
|
+
|
61
|
+
racc_action_default = [
|
62
|
+
-23, -20, -2, -68, -68, -17, -52, -44, -49, -23,
|
63
|
+
-68, -15, -53, -21, -12, -51, -68, -50, -68, -68,
|
64
|
+
-68, -37, -68, -27, -35, -68, -36, -56, -68, -56,
|
65
|
+
-23, -5, -3, -8, -4, -7, -6, -48, -9, -43,
|
66
|
+
-11, -23, -45, -68, -18, -14, -13, -47, -42, -41,
|
67
|
+
-46, -37, -68, -35, -68, -68, -23, -68, -68, -28,
|
68
|
+
-40, -68, -29, -68, -57, -68, -62, -58, -63, -59,
|
69
|
+
-60, -68, -61, -26, -68, -16, -10, -65, -67, -68,
|
70
|
+
-31, -30, -19, 97, -1, -34, -39, -68, -32, -33,
|
71
|
+
-24, -54, -55, -25, -66, -64, -38 ]
|
72
|
+
|
73
|
+
racc_goto_table = [
|
74
|
+
37, 39, 42, 22, 40, 75, 20, 29, 45, 47,
|
75
|
+
65, 50, 74, 38, 46, 43, 77, 30, 52, 49,
|
76
|
+
25, 79, nil, nil, nil, nil, nil, nil, nil, nil,
|
77
|
+
nil, 84, nil, nil, nil, 78, 76, nil, nil, nil,
|
78
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
79
|
+
nil, nil, nil, nil, nil, nil, nil, 85, nil, nil,
|
80
|
+
nil, 88, nil, 89, nil, nil, nil, nil, nil, nil,
|
81
|
+
nil, 94 ]
|
82
|
+
|
83
|
+
racc_goto_check = [
|
84
|
+
7, 7, 7, 14, 8, 2, 1, 9, 8, 7,
|
85
|
+
13, 7, 13, 6, 10, 1, 5, 3, 14, 9,
|
86
|
+
15, 19, nil, nil, nil, nil, nil, nil, nil, nil,
|
87
|
+
nil, 2, nil, nil, nil, 7, 8, nil, nil, nil,
|
88
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
89
|
+
nil, nil, nil, nil, nil, nil, nil, 14, nil, nil,
|
90
|
+
nil, 14, nil, 14, nil, nil, nil, nil, nil, nil,
|
91
|
+
nil, 7 ]
|
92
|
+
|
93
|
+
racc_goto_pointer = [
|
94
|
+
nil, 6, -25, 12, nil, -25, 6, -6, -3, 3,
|
95
|
+
0, nil, nil, -17, 0, 17, nil, nil, nil, -20 ]
|
96
|
+
|
97
|
+
racc_goto_default = [
|
98
|
+
nil, nil, 2, nil, 5, 7, nil, 11, nil, 14,
|
99
|
+
15, 17, 19, nil, nil, nil, 6, 8, 71, nil ]
|
100
|
+
|
101
|
+
racc_reduce_table = [
|
102
|
+
0, 0, :racc_error,
|
103
|
+
3, 32, :_reduce_1,
|
104
|
+
1, 32, :_reduce_2,
|
105
|
+
1, 34, :_reduce_3,
|
106
|
+
1, 34, :_reduce_4,
|
107
|
+
1, 34, :_reduce_5,
|
108
|
+
1, 34, :_reduce_6,
|
109
|
+
1, 34, :_reduce_7,
|
110
|
+
1, 34, :_reduce_8,
|
111
|
+
2, 35, :_reduce_9,
|
112
|
+
3, 35, :_reduce_10,
|
113
|
+
2, 35, :_reduce_11,
|
114
|
+
1, 35, :_reduce_none,
|
115
|
+
2, 35, :_reduce_13,
|
116
|
+
2, 35, :_reduce_14,
|
117
|
+
1, 35, :_reduce_15,
|
118
|
+
3, 33, :_reduce_16,
|
119
|
+
1, 33, :_reduce_none,
|
120
|
+
2, 42, :_reduce_18,
|
121
|
+
3, 36, :_reduce_19,
|
122
|
+
1, 36, :_reduce_20,
|
123
|
+
1, 36, :_reduce_21,
|
124
|
+
1, 43, :_reduce_22,
|
125
|
+
0, 43, :_reduce_none,
|
126
|
+
4, 41, :_reduce_24,
|
127
|
+
4, 41, :_reduce_25,
|
128
|
+
3, 41, :_reduce_26,
|
129
|
+
2, 40, :_reduce_27,
|
130
|
+
3, 40, :_reduce_28,
|
131
|
+
3, 40, :_reduce_29,
|
132
|
+
3, 40, :_reduce_30,
|
133
|
+
3, 40, :_reduce_31,
|
134
|
+
3, 45, :_reduce_32,
|
135
|
+
3, 45, :_reduce_33,
|
136
|
+
3, 45, :_reduce_34,
|
137
|
+
1, 45, :_reduce_none,
|
138
|
+
1, 45, :_reduce_none,
|
139
|
+
1, 45, :_reduce_37,
|
140
|
+
4, 46, :_reduce_38,
|
141
|
+
3, 46, :_reduce_39,
|
142
|
+
2, 46, :_reduce_40,
|
143
|
+
2, 47, :_reduce_41,
|
144
|
+
2, 47, :_reduce_42,
|
145
|
+
1, 37, :_reduce_none,
|
146
|
+
0, 37, :_reduce_none,
|
147
|
+
2, 38, :_reduce_45,
|
148
|
+
2, 38, :_reduce_46,
|
149
|
+
2, 38, :_reduce_47,
|
150
|
+
2, 38, :_reduce_48,
|
151
|
+
1, 38, :_reduce_none,
|
152
|
+
1, 38, :_reduce_none,
|
153
|
+
1, 38, :_reduce_none,
|
154
|
+
1, 38, :_reduce_none,
|
155
|
+
1, 48, :_reduce_53,
|
156
|
+
2, 44, :_reduce_54,
|
157
|
+
2, 44, :_reduce_55,
|
158
|
+
0, 44, :_reduce_none,
|
159
|
+
1, 49, :_reduce_57,
|
160
|
+
1, 49, :_reduce_58,
|
161
|
+
1, 49, :_reduce_59,
|
162
|
+
1, 49, :_reduce_60,
|
163
|
+
1, 49, :_reduce_61,
|
164
|
+
1, 49, :_reduce_62,
|
165
|
+
1, 49, :_reduce_63,
|
166
|
+
3, 39, :_reduce_64,
|
167
|
+
1, 50, :_reduce_none,
|
168
|
+
2, 50, :_reduce_none,
|
169
|
+
1, 50, :_reduce_none ]
|
170
|
+
|
171
|
+
racc_reduce_n = 68
|
172
|
+
|
173
|
+
racc_shift_n = 97
|
174
|
+
|
175
|
+
racc_token_table = {
|
176
|
+
false => 0,
|
177
|
+
:error => 1,
|
178
|
+
:FUNCTION => 2,
|
179
|
+
:INCLUDES => 3,
|
180
|
+
:DASHMATCH => 4,
|
181
|
+
:LBRACE => 5,
|
182
|
+
:HASH => 6,
|
183
|
+
:PLUS => 7,
|
184
|
+
:GREATER => 8,
|
185
|
+
:S => 9,
|
186
|
+
:STRING => 10,
|
187
|
+
:IDENT => 11,
|
188
|
+
:COMMA => 12,
|
189
|
+
:NUMBER => 13,
|
190
|
+
:PREFIXMATCH => 14,
|
191
|
+
:SUFFIXMATCH => 15,
|
192
|
+
:SUBSTRINGMATCH => 16,
|
193
|
+
:TILDE => 17,
|
194
|
+
:NOT_EQUAL => 18,
|
195
|
+
:SLASH => 19,
|
196
|
+
:DOUBLESLASH => 20,
|
197
|
+
:NOT => 21,
|
198
|
+
:EQUAL => 22,
|
199
|
+
:RPAREN => 23,
|
200
|
+
:LSQUARE => 24,
|
201
|
+
:RSQUARE => 25,
|
202
|
+
:HAS => 26,
|
203
|
+
"." => 27,
|
204
|
+
"|" => 28,
|
205
|
+
"*" => 29,
|
206
|
+
":" => 30 }
|
207
|
+
|
208
|
+
racc_nt_base = 31
|
209
|
+
|
210
|
+
racc_use_result_var = true
|
211
|
+
|
212
|
+
Racc_arg = [
|
213
|
+
racc_action_table,
|
214
|
+
racc_action_check,
|
215
|
+
racc_action_default,
|
216
|
+
racc_action_pointer,
|
217
|
+
racc_goto_table,
|
218
|
+
racc_goto_check,
|
219
|
+
racc_goto_default,
|
220
|
+
racc_goto_pointer,
|
221
|
+
racc_nt_base,
|
222
|
+
racc_reduce_table,
|
223
|
+
racc_token_table,
|
224
|
+
racc_shift_n,
|
225
|
+
racc_reduce_n,
|
226
|
+
racc_use_result_var ]
|
227
|
+
|
228
|
+
Racc_token_to_s_table = [
|
229
|
+
"$end",
|
230
|
+
"error",
|
231
|
+
"FUNCTION",
|
232
|
+
"INCLUDES",
|
233
|
+
"DASHMATCH",
|
234
|
+
"LBRACE",
|
235
|
+
"HASH",
|
236
|
+
"PLUS",
|
237
|
+
"GREATER",
|
238
|
+
"S",
|
239
|
+
"STRING",
|
240
|
+
"IDENT",
|
241
|
+
"COMMA",
|
242
|
+
"NUMBER",
|
243
|
+
"PREFIXMATCH",
|
244
|
+
"SUFFIXMATCH",
|
245
|
+
"SUBSTRINGMATCH",
|
246
|
+
"TILDE",
|
247
|
+
"NOT_EQUAL",
|
248
|
+
"SLASH",
|
249
|
+
"DOUBLESLASH",
|
250
|
+
"NOT",
|
251
|
+
"EQUAL",
|
252
|
+
"RPAREN",
|
253
|
+
"LSQUARE",
|
254
|
+
"RSQUARE",
|
255
|
+
"HAS",
|
256
|
+
"\".\"",
|
257
|
+
"\"|\"",
|
258
|
+
"\"*\"",
|
259
|
+
"\":\"",
|
260
|
+
"$start",
|
261
|
+
"selector",
|
262
|
+
"simple_selector_1toN",
|
263
|
+
"combinator",
|
264
|
+
"simple_selector",
|
265
|
+
"element_name",
|
266
|
+
"hcap_0toN",
|
267
|
+
"hcap_1toN",
|
268
|
+
"negation",
|
269
|
+
"function",
|
270
|
+
"attrib",
|
271
|
+
"class",
|
272
|
+
"namespace",
|
273
|
+
"attrib_val_0or1",
|
274
|
+
"expr",
|
275
|
+
"an_plus_b",
|
276
|
+
"pseudo",
|
277
|
+
"attribute_id",
|
278
|
+
"eql_incl_dash",
|
279
|
+
"negation_arg" ]
|
280
|
+
|
281
|
+
Racc_debug_parser = false
|
282
|
+
|
283
|
+
##### State transition tables end #####
|
284
|
+
|
285
|
+
# reduce 0 omitted
|
286
|
+
|
287
|
+
def _reduce_1(val, _values, result)
|
288
|
+
result = [val.first, val.last].flatten
|
289
|
+
|
290
|
+
result
|
291
|
+
end
|
292
|
+
|
293
|
+
def _reduce_2(val, _values, result)
|
294
|
+
result = val.flatten
|
295
|
+
result
|
296
|
+
end
|
297
|
+
|
298
|
+
def _reduce_3(val, _values, result)
|
299
|
+
result = :DIRECT_ADJACENT_SELECTOR
|
300
|
+
result
|
301
|
+
end
|
302
|
+
|
303
|
+
def _reduce_4(val, _values, result)
|
304
|
+
result = :CHILD_SELECTOR
|
305
|
+
result
|
306
|
+
end
|
307
|
+
|
308
|
+
def _reduce_5(val, _values, result)
|
309
|
+
result = :PRECEDING_SELECTOR
|
310
|
+
result
|
311
|
+
end
|
312
|
+
|
313
|
+
def _reduce_6(val, _values, result)
|
314
|
+
result = :DESCENDANT_SELECTOR
|
315
|
+
result
|
316
|
+
end
|
317
|
+
|
318
|
+
def _reduce_7(val, _values, result)
|
319
|
+
result = :DESCENDANT_SELECTOR
|
320
|
+
result
|
321
|
+
end
|
322
|
+
|
323
|
+
def _reduce_8(val, _values, result)
|
324
|
+
result = :CHILD_SELECTOR
|
325
|
+
result
|
326
|
+
end
|
327
|
+
|
328
|
+
def _reduce_9(val, _values, result)
|
329
|
+
result = if val[1].nil?
|
330
|
+
val.first
|
331
|
+
else
|
332
|
+
Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
|
333
|
+
end
|
334
|
+
|
335
|
+
result
|
336
|
+
end
|
337
|
+
|
338
|
+
def _reduce_10(val, _values, result)
|
339
|
+
result = Node.new(:CONDITIONAL_SELECTOR,
|
340
|
+
[
|
341
|
+
val.first,
|
342
|
+
Node.new(:COMBINATOR, [val[1], val.last])
|
343
|
+
]
|
344
|
+
)
|
345
|
+
|
346
|
+
result
|
347
|
+
end
|
348
|
+
|
349
|
+
def _reduce_11(val, _values, result)
|
350
|
+
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
351
|
+
|
352
|
+
result
|
353
|
+
end
|
354
|
+
|
355
|
+
# reduce 12 omitted
|
356
|
+
|
357
|
+
def _reduce_13(val, _values, result)
|
358
|
+
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
359
|
+
|
360
|
+
result
|
361
|
+
end
|
362
|
+
|
363
|
+
def _reduce_14(val, _values, result)
|
364
|
+
result = Node.new(:CONDITIONAL_SELECTOR,
|
365
|
+
[
|
366
|
+
Node.new(:ELEMENT_NAME, ['*']),
|
367
|
+
Node.new(:COMBINATOR, val)
|
368
|
+
]
|
369
|
+
)
|
370
|
+
|
371
|
+
result
|
372
|
+
end
|
373
|
+
|
374
|
+
def _reduce_15(val, _values, result)
|
375
|
+
result = Node.new(:CONDITIONAL_SELECTOR,
|
376
|
+
[Node.new(:ELEMENT_NAME, ['*']), val.first]
|
377
|
+
)
|
378
|
+
|
379
|
+
result
|
380
|
+
end
|
381
|
+
|
382
|
+
def _reduce_16(val, _values, result)
|
383
|
+
result = Node.new(val[1], [val.first, val.last])
|
384
|
+
|
385
|
+
result
|
386
|
+
end
|
387
|
+
|
388
|
+
# reduce 17 omitted
|
389
|
+
|
390
|
+
def _reduce_18(val, _values, result)
|
391
|
+
result = Node.new(:CLASS_CONDITION, [val[1]])
|
392
|
+
result
|
393
|
+
end
|
394
|
+
|
395
|
+
def _reduce_19(val, _values, result)
|
396
|
+
result = Node.new(:ELEMENT_NAME,
|
397
|
+
[[val.first, val.last].compact.join(':')]
|
398
|
+
)
|
399
|
+
|
400
|
+
result
|
401
|
+
end
|
402
|
+
|
403
|
+
def _reduce_20(val, _values, result)
|
404
|
+
name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
|
405
|
+
result = Node.new(:ELEMENT_NAME, [name])
|
406
|
+
|
407
|
+
result
|
408
|
+
end
|
409
|
+
|
410
|
+
def _reduce_21(val, _values, result)
|
411
|
+
result = Node.new(:ELEMENT_NAME, val)
|
412
|
+
result
|
413
|
+
end
|
414
|
+
|
415
|
+
def _reduce_22(val, _values, result)
|
416
|
+
result = val[0]
|
417
|
+
result
|
418
|
+
end
|
419
|
+
|
420
|
+
# reduce 23 omitted
|
421
|
+
|
422
|
+
def _reduce_24(val, _values, result)
|
423
|
+
result = Node.new(:ATTRIBUTE_CONDITION,
|
424
|
+
[Node.new(:ELEMENT_NAME, [val[1]])] + (val[2] || [])
|
425
|
+
)
|
426
|
+
|
427
|
+
result
|
428
|
+
end
|
429
|
+
|
430
|
+
def _reduce_25(val, _values, result)
|
431
|
+
result = Node.new(:ATTRIBUTE_CONDITION,
|
432
|
+
[val[1]] + (val[2] || [])
|
433
|
+
)
|
434
|
+
|
435
|
+
result
|
436
|
+
end
|
437
|
+
|
438
|
+
def _reduce_26(val, _values, result)
|
439
|
+
# Non standard, but hpricot supports it.
|
440
|
+
result = Node.new(:PSEUDO_CLASS,
|
441
|
+
[Node.new(:FUNCTION, ['nth-child(', val[1]])]
|
442
|
+
)
|
443
|
+
|
444
|
+
result
|
445
|
+
end
|
446
|
+
|
447
|
+
def _reduce_27(val, _values, result)
|
448
|
+
result = Node.new(:FUNCTION, [val.first.strip])
|
449
|
+
|
450
|
+
result
|
451
|
+
end
|
452
|
+
|
453
|
+
def _reduce_28(val, _values, result)
|
454
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
455
|
+
|
456
|
+
result
|
457
|
+
end
|
458
|
+
|
459
|
+
def _reduce_29(val, _values, result)
|
460
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
461
|
+
|
462
|
+
result
|
463
|
+
end
|
464
|
+
|
465
|
+
def _reduce_30(val, _values, result)
|
466
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
467
|
+
|
468
|
+
result
|
469
|
+
end
|
470
|
+
|
471
|
+
def _reduce_31(val, _values, result)
|
472
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
473
|
+
|
474
|
+
result
|
475
|
+
end
|
476
|
+
|
477
|
+
def _reduce_32(val, _values, result)
|
478
|
+
result = [val.first, val.last]
|
479
|
+
result
|
480
|
+
end
|
481
|
+
|
482
|
+
def _reduce_33(val, _values, result)
|
483
|
+
result = [val.first, val.last]
|
484
|
+
result
|
485
|
+
end
|
486
|
+
|
487
|
+
def _reduce_34(val, _values, result)
|
488
|
+
result = [val.first, val.last]
|
489
|
+
result
|
490
|
+
end
|
491
|
+
|
492
|
+
# reduce 35 omitted
|
493
|
+
|
494
|
+
# reduce 36 omitted
|
495
|
+
|
496
|
+
def _reduce_37(val, _values, result)
|
497
|
+
if val[0] == 'even'
|
498
|
+
val = ["2","n","+","0"]
|
499
|
+
result = Node.new(:AN_PLUS_B, val)
|
500
|
+
elsif val[0] == 'odd'
|
501
|
+
val = ["2","n","+","1"]
|
502
|
+
result = Node.new(:AN_PLUS_B, val)
|
503
|
+
else
|
504
|
+
# This is not CSS standard. It allows us to support this:
|
505
|
+
# assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
|
506
|
+
# assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
|
507
|
+
# assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
|
508
|
+
result = val
|
509
|
+
end
|
510
|
+
|
511
|
+
result
|
512
|
+
end
|
513
|
+
|
514
|
+
def _reduce_38(val, _values, result)
|
515
|
+
if val[1] == 'n'
|
516
|
+
result = Node.new(:AN_PLUS_B, val)
|
517
|
+
else
|
518
|
+
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
519
|
+
end
|
520
|
+
|
521
|
+
result
|
522
|
+
end
|
523
|
+
|
524
|
+
def _reduce_39(val, _values, result)
|
525
|
+
# n+3, -n+3
|
526
|
+
if val[0] == 'n'
|
527
|
+
val.unshift("1")
|
528
|
+
result = Node.new(:AN_PLUS_B, val)
|
529
|
+
elsif val[0] == '-n'
|
530
|
+
val[0] = 'n'
|
531
|
+
val.unshift("-1")
|
532
|
+
result = Node.new(:AN_PLUS_B, val)
|
533
|
+
else
|
534
|
+
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
535
|
+
end
|
536
|
+
|
537
|
+
result
|
538
|
+
end
|
539
|
+
|
540
|
+
def _reduce_40(val, _values, result)
|
541
|
+
if val[1] == 'n'
|
542
|
+
val << "+"
|
543
|
+
val << "0"
|
544
|
+
result = Node.new(:AN_PLUS_B, val)
|
545
|
+
else
|
546
|
+
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
547
|
+
end
|
548
|
+
|
549
|
+
result
|
550
|
+
end
|
551
|
+
|
552
|
+
def _reduce_41(val, _values, result)
|
553
|
+
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
554
|
+
|
555
|
+
result
|
556
|
+
end
|
557
|
+
|
558
|
+
def _reduce_42(val, _values, result)
|
559
|
+
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
560
|
+
result
|
561
|
+
end
|
562
|
+
|
563
|
+
# reduce 43 omitted
|
564
|
+
|
565
|
+
# reduce 44 omitted
|
566
|
+
|
567
|
+
def _reduce_45(val, _values, result)
|
568
|
+
result = Node.new(:COMBINATOR, val)
|
569
|
+
|
570
|
+
result
|
571
|
+
end
|
572
|
+
|
573
|
+
def _reduce_46(val, _values, result)
|
574
|
+
result = Node.new(:COMBINATOR, val)
|
575
|
+
|
576
|
+
result
|
577
|
+
end
|
578
|
+
|
579
|
+
def _reduce_47(val, _values, result)
|
580
|
+
result = Node.new(:COMBINATOR, val)
|
581
|
+
|
582
|
+
result
|
583
|
+
end
|
584
|
+
|
585
|
+
def _reduce_48(val, _values, result)
|
586
|
+
result = Node.new(:COMBINATOR, val)
|
587
|
+
|
588
|
+
result
|
589
|
+
end
|
590
|
+
|
591
|
+
# reduce 49 omitted
|
592
|
+
|
593
|
+
# reduce 50 omitted
|
594
|
+
|
595
|
+
# reduce 51 omitted
|
596
|
+
|
597
|
+
# reduce 52 omitted
|
598
|
+
|
599
|
+
def _reduce_53(val, _values, result)
|
600
|
+
result = Node.new(:ID, val)
|
601
|
+
result
|
602
|
+
end
|
603
|
+
|
604
|
+
def _reduce_54(val, _values, result)
|
605
|
+
result = [val.first, val[1]]
|
606
|
+
result
|
607
|
+
end
|
608
|
+
|
609
|
+
def _reduce_55(val, _values, result)
|
610
|
+
result = [val.first, val[1]]
|
611
|
+
result
|
612
|
+
end
|
613
|
+
|
614
|
+
# reduce 56 omitted
|
615
|
+
|
616
|
+
def _reduce_57(val, _values, result)
|
617
|
+
result = :equal
|
618
|
+
result
|
619
|
+
end
|
620
|
+
|
621
|
+
def _reduce_58(val, _values, result)
|
622
|
+
result = :prefix_match
|
623
|
+
result
|
624
|
+
end
|
625
|
+
|
626
|
+
def _reduce_59(val, _values, result)
|
627
|
+
result = :suffix_match
|
628
|
+
result
|
629
|
+
end
|
630
|
+
|
631
|
+
def _reduce_60(val, _values, result)
|
632
|
+
result = :substring_match
|
633
|
+
result
|
634
|
+
end
|
635
|
+
|
636
|
+
def _reduce_61(val, _values, result)
|
637
|
+
result = :not_equal
|
638
|
+
result
|
639
|
+
end
|
640
|
+
|
641
|
+
def _reduce_62(val, _values, result)
|
642
|
+
result = :includes
|
643
|
+
result
|
644
|
+
end
|
645
|
+
|
646
|
+
def _reduce_63(val, _values, result)
|
647
|
+
result = :dash_match
|
648
|
+
result
|
649
|
+
end
|
650
|
+
|
651
|
+
def _reduce_64(val, _values, result)
|
652
|
+
result = Node.new(:NOT, [val[1]])
|
653
|
+
|
654
|
+
result
|
655
|
+
end
|
656
|
+
|
657
|
+
# reduce 65 omitted
|
658
|
+
|
659
|
+
# reduce 66 omitted
|
660
|
+
|
661
|
+
# reduce 67 omitted
|
662
|
+
|
663
|
+
def _reduce_none(val, _values, result)
|
664
|
+
val[0]
|
665
|
+
end
|
666
|
+
|
667
|
+
end # class GeneratedParser
|
668
|
+
end # module CSS
|
669
|
+
end # module Nokogiri
|