nokogiri 1.5.0.beta.1 → 1.5.0.beta.2
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/CHANGELOG.ja.rdoc +28 -8
- data/CHANGELOG.rdoc +23 -0
- data/Manifest.txt +63 -1
- data/README.ja.rdoc +1 -1
- data/README.rdoc +22 -4
- data/Rakefile +6 -2
- data/ext/java/nokogiri/EncodingHandler.java +92 -0
- data/ext/java/nokogiri/HtmlDocument.java +116 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +111 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +45 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -0
- data/ext/java/nokogiri/NokogiriService.java +370 -0
- data/ext/java/nokogiri/XmlAttr.java +147 -0
- data/ext/java/nokogiri/XmlAttributeDecl.java +98 -0
- data/ext/java/nokogiri/XmlCdata.java +50 -0
- data/ext/java/nokogiri/XmlComment.java +47 -0
- data/ext/java/nokogiri/XmlDocument.java +463 -0
- data/ext/java/nokogiri/XmlDocumentFragment.java +207 -0
- data/ext/java/nokogiri/XmlDtd.java +427 -0
- data/ext/java/nokogiri/XmlElement.java +172 -0
- data/ext/java/nokogiri/XmlElementContent.java +350 -0
- data/ext/java/nokogiri/XmlElementDecl.java +115 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +129 -0
- data/ext/java/nokogiri/XmlEntityReference.java +42 -0
- data/ext/java/nokogiri/XmlNamespace.java +77 -0
- data/ext/java/nokogiri/XmlNode.java +1399 -0
- data/ext/java/nokogiri/XmlNodeSet.java +248 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +70 -0
- data/ext/java/nokogiri/XmlReader.java +373 -0
- data/ext/java/nokogiri/XmlRelaxng.java +166 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +308 -0
- data/ext/java/nokogiri/XmlSaxPushParser.java +146 -0
- data/ext/java/nokogiri/XmlSchema.java +142 -0
- data/ext/java/nokogiri/XmlSyntaxError.java +84 -0
- data/ext/java/nokogiri/XmlText.java +96 -0
- data/ext/java/nokogiri/XmlXpathContext.java +130 -0
- data/ext/java/nokogiri/XsltStylesheet.java +126 -0
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +181 -0
- data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +39 -0
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +42 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +251 -0
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +526 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +136 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +80 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +37 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +54 -0
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +49 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +88 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +23 -0
- data/ext/java/nokogiri/internals/ParserContext.java +235 -0
- data/ext/java/nokogiri/internals/PushInputStream.java +381 -0
- data/ext/java/nokogiri/internals/ReaderNode.java +431 -0
- data/ext/java/nokogiri/internals/SaveContext.java +249 -0
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +35 -0
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +10 -0
- data/ext/java/nokogiri/internals/XmlDomParser.java +45 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +201 -0
- data/ext/java/nokogiri/internals/XmlSaxParser.java +33 -0
- data/ext/nokogiri/depend +32 -0
- data/ext/nokogiri/extconf.rb +61 -32
- data/ext/nokogiri/nokogiri.c +0 -5
- data/ext/nokogiri/nokogiri.h +2 -2
- data/ext/nokogiri/xml_document.c +5 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_node.c +56 -16
- data/ext/nokogiri/xml_node_set.c +7 -7
- data/ext/nokogiri/xml_reader.c +20 -1
- data/ext/nokogiri/xml_relax_ng.c +0 -7
- data/ext/nokogiri/xml_xpath_context.c +2 -0
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/nokogiri.rb +1 -2
- data/lib/nokogiri/css/generated_parser.rb +155 -148
- data/lib/nokogiri/css/generated_tokenizer.rb +2 -1
- data/lib/nokogiri/css/parser.y +3 -0
- data/lib/nokogiri/css/xpath_visitor.rb +1 -7
- data/lib/nokogiri/html.rb +2 -2
- data/lib/nokogiri/html/document_fragment.rb +7 -4
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +3 -6
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +1 -2
- data/lib/nokogiri/xml/document_fragment.rb +7 -0
- data/lib/nokogiri/xml/node.rb +5 -3
- data/lib/nokogiri/xml/node_set.rb +25 -0
- data/lib/nokogiri/xml/reader.rb +2 -0
- data/lib/nokogiri/xml/sax/document.rb +3 -1
- data/lib/xercesImpl.jar +0 -0
- data/spec/helper.rb +3 -0
- data/spec/xml/reader_spec.rb +307 -0
- data/tasks/test.rb +1 -1
- data/test/css/test_parser.rb +11 -1
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +2 -2
- data/test/html/test_document_fragment.rb +34 -6
- data/test/test_memory_leak.rb +2 -2
- data/test/test_reader.rb +28 -6
- data/test/test_xslt_transforms.rb +2 -3
- data/test/xml/test_attr.rb +31 -4
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +8 -8
- data/test/xml/test_document_fragment.rb +4 -12
- data/test/xml/test_node.rb +1 -1
- data/test/xml/test_node_reparenting.rb +26 -11
- data/test/xml/test_node_set.rb +38 -2
- data/test/xml/test_text.rb +11 -2
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +11 -7
- metadata +68 -5
- data/lib/nokogiri/version_warning.rb +0 -14
data/ext/nokogiri/nokogiri.c
CHANGED
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -35,8 +35,6 @@ int vasprintf (char **strp, const char *fmt, va_list ap);
|
|
35
35
|
#include <st.h>
|
36
36
|
#endif
|
37
37
|
|
38
|
-
int is_2_6_16(void) ;
|
39
|
-
|
40
38
|
#ifndef UNUSED
|
41
39
|
# if defined(__GNUC__)
|
42
40
|
# define MAYBE_UNUSED(name) name __attribute__((unused))
|
@@ -77,6 +75,8 @@ int is_2_6_16(void) ;
|
|
77
75
|
#define RBSTR_OR_QNIL(_str) \
|
78
76
|
(_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
79
77
|
|
78
|
+
#include <xml_libxml2_hacks.h>
|
79
|
+
|
80
80
|
#include <xml_io.h>
|
81
81
|
#include <xml_document.h>
|
82
82
|
#include <html_entity_lookup.h>
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -46,6 +46,11 @@ static void recursively_remove_namespaces_from_node(xmlNodePtr node)
|
|
46
46
|
|
47
47
|
for (child = node->children ; child ; child = child->next)
|
48
48
|
recursively_remove_namespaces_from_node(child);
|
49
|
+
|
50
|
+
if (node->nsDef) {
|
51
|
+
xmlFreeNsList(node->nsDef);
|
52
|
+
node->nsDef = NULL;
|
53
|
+
}
|
49
54
|
}
|
50
55
|
|
51
56
|
/*
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#ifndef HAVE_XMLFIRSTELEMENTCHILD
|
2
|
+
#include <libxml/tree.h>
|
3
|
+
/**
|
4
|
+
* xmlFirstElementChild:
|
5
|
+
* @parent: the parent node
|
6
|
+
*
|
7
|
+
* Finds the first child node of that element which is a Element node
|
8
|
+
* Note the handling of entities references is different than in
|
9
|
+
* the W3C DOM element traversal spec since we don't have back reference
|
10
|
+
* from entities content to entities references.
|
11
|
+
*
|
12
|
+
* Returns the first element child or NULL if not available
|
13
|
+
*/
|
14
|
+
xmlNodePtr
|
15
|
+
xmlFirstElementChild(xmlNodePtr parent) {
|
16
|
+
xmlNodePtr cur = NULL;
|
17
|
+
|
18
|
+
if (parent == NULL)
|
19
|
+
return(NULL);
|
20
|
+
switch (parent->type) {
|
21
|
+
case XML_ELEMENT_NODE:
|
22
|
+
case XML_ENTITY_NODE:
|
23
|
+
case XML_DOCUMENT_NODE:
|
24
|
+
case XML_HTML_DOCUMENT_NODE:
|
25
|
+
cur = parent->children;
|
26
|
+
break;
|
27
|
+
default:
|
28
|
+
return(NULL);
|
29
|
+
}
|
30
|
+
while (cur != NULL) {
|
31
|
+
if (cur->type == XML_ELEMENT_NODE)
|
32
|
+
return(cur);
|
33
|
+
cur = cur->next;
|
34
|
+
}
|
35
|
+
return(NULL);
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* xmlNextElementSibling:
|
40
|
+
* @node: the current node
|
41
|
+
*
|
42
|
+
* Finds the first closest next sibling of the node which is an
|
43
|
+
* element node.
|
44
|
+
* Note the handling of entities references is different than in
|
45
|
+
* the W3C DOM element traversal spec since we don't have back reference
|
46
|
+
* from entities content to entities references.
|
47
|
+
*
|
48
|
+
* Returns the next element sibling or NULL if not available
|
49
|
+
*/
|
50
|
+
xmlNodePtr
|
51
|
+
xmlNextElementSibling(xmlNodePtr node) {
|
52
|
+
if (node == NULL)
|
53
|
+
return(NULL);
|
54
|
+
switch (node->type) {
|
55
|
+
case XML_ELEMENT_NODE:
|
56
|
+
case XML_TEXT_NODE:
|
57
|
+
case XML_CDATA_SECTION_NODE:
|
58
|
+
case XML_ENTITY_REF_NODE:
|
59
|
+
case XML_ENTITY_NODE:
|
60
|
+
case XML_PI_NODE:
|
61
|
+
case XML_COMMENT_NODE:
|
62
|
+
case XML_DTD_NODE:
|
63
|
+
case XML_XINCLUDE_START:
|
64
|
+
case XML_XINCLUDE_END:
|
65
|
+
node = node->next;
|
66
|
+
break;
|
67
|
+
default:
|
68
|
+
return(NULL);
|
69
|
+
}
|
70
|
+
while (node != NULL) {
|
71
|
+
if (node->type == XML_ELEMENT_NODE)
|
72
|
+
return(node);
|
73
|
+
node = node->next;
|
74
|
+
}
|
75
|
+
return(NULL);
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* xmlLastElementChild:
|
80
|
+
* @parent: the parent node
|
81
|
+
*
|
82
|
+
* Finds the last child node of that element which is a Element node
|
83
|
+
* Note the handling of entities references is different than in
|
84
|
+
* the W3C DOM element traversal spec since we don't have back reference
|
85
|
+
* from entities content to entities references.
|
86
|
+
*
|
87
|
+
* Returns the last element child or NULL if not available
|
88
|
+
*/
|
89
|
+
xmlNodePtr
|
90
|
+
xmlLastElementChild(xmlNodePtr parent) {
|
91
|
+
xmlNodePtr cur = NULL;
|
92
|
+
|
93
|
+
if (parent == NULL)
|
94
|
+
return(NULL);
|
95
|
+
switch (parent->type) {
|
96
|
+
case XML_ELEMENT_NODE:
|
97
|
+
case XML_ENTITY_NODE:
|
98
|
+
case XML_DOCUMENT_NODE:
|
99
|
+
case XML_HTML_DOCUMENT_NODE:
|
100
|
+
cur = parent->last;
|
101
|
+
break;
|
102
|
+
default:
|
103
|
+
return(NULL);
|
104
|
+
}
|
105
|
+
while (cur != NULL) {
|
106
|
+
if (cur->type == XML_ELEMENT_NODE)
|
107
|
+
return(cur);
|
108
|
+
cur = cur->prev;
|
109
|
+
}
|
110
|
+
return(NULL);
|
111
|
+
}
|
112
|
+
#endif
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#ifndef HAVE_XMLFIRSTELEMENTCHILD
|
2
|
+
|
3
|
+
#ifndef XML_LIBXML2_HACKS
|
4
|
+
#define XML_LIBXML2_HACKS
|
5
|
+
|
6
|
+
xmlNodePtr xmlFirstElementChild(xmlNodePtr parent);
|
7
|
+
xmlNodePtr xmlNextElementSibling(xmlNodePtr node);
|
8
|
+
xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
|
9
|
+
|
10
|
+
#endif
|
11
|
+
|
12
|
+
#endif
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -103,7 +103,7 @@ static xmlNodePtr xmlReplaceNodeWrapper(xmlNodePtr pivot, xmlNodePtr new_node)
|
|
103
103
|
static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_reparentee_func prf)
|
104
104
|
{
|
105
105
|
VALUE reparented_obj ;
|
106
|
-
xmlNodePtr reparentee, pivot, reparented ;
|
106
|
+
xmlNodePtr reparentee, pivot, reparented, next_text, new_next_text ;
|
107
107
|
|
108
108
|
if(!rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlNode))
|
109
109
|
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
@@ -141,10 +141,32 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
|
|
141
141
|
}
|
142
142
|
}
|
143
143
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
144
|
+
if (reparentee->type == XML_TEXT_NODE && pivot->next && pivot->next->type == XML_TEXT_NODE) {
|
145
|
+
/*
|
146
|
+
* libxml merges text nodes in a right-to-left fashion, meaning that if
|
147
|
+
* there are two text nodes who would be adjacent, the right (or following,
|
148
|
+
* or next) node will be merged into the left (or preceding, or previous)
|
149
|
+
* node.
|
150
|
+
*
|
151
|
+
* and by "merged" I mean the string contents will be concatenated onto the
|
152
|
+
* left node's contents, and then the node will be freed.
|
153
|
+
*
|
154
|
+
* which means that if we have a ruby object wrapped around the right node,
|
155
|
+
* its memory would be freed out from under it.
|
156
|
+
*
|
157
|
+
* so, we detect this edge case and unlink-and-root the text node before it gets
|
158
|
+
* merged. then we dup the node and insert that duplicate back into the
|
159
|
+
* document where the real node was.
|
160
|
+
*
|
161
|
+
* yes, this is totally lame.
|
162
|
+
*/
|
163
|
+
next_text = pivot->next ;
|
164
|
+
new_next_text = xmlDocCopyNode(next_text, pivot->doc, 1) ;
|
165
|
+
|
166
|
+
xmlUnlinkNode(next_text);
|
167
|
+
NOKOGIRI_ROOT_NODE(next_text);
|
168
|
+
|
169
|
+
xmlAddNextSibling(pivot, new_next_text);
|
148
170
|
}
|
149
171
|
|
150
172
|
if(!(reparented = (*prf)(pivot, reparentee))) {
|
@@ -1021,26 +1043,32 @@ static VALUE line(VALUE self)
|
|
1021
1043
|
*/
|
1022
1044
|
static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href)
|
1023
1045
|
{
|
1024
|
-
xmlNodePtr node;
|
1046
|
+
xmlNodePtr node, namespacee;
|
1025
1047
|
xmlNsPtr ns;
|
1026
1048
|
|
1027
1049
|
Data_Get_Struct(self, xmlNode, node);
|
1050
|
+
namespacee = node ;
|
1028
1051
|
|
1029
|
-
ns =
|
1052
|
+
ns = xmlSearchNs(
|
1053
|
+
node->doc,
|
1030
1054
|
node,
|
1031
|
-
(const xmlChar *)StringValuePtr(href),
|
1032
1055
|
(const xmlChar *)(NIL_P(prefix) ? NULL : StringValuePtr(prefix))
|
1033
1056
|
);
|
1034
1057
|
|
1035
1058
|
if(!ns) {
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1059
|
+
if (node->type != XML_ELEMENT_NODE) {
|
1060
|
+
namespacee = node->parent;
|
1061
|
+
}
|
1062
|
+
ns = xmlNewNs(
|
1063
|
+
namespacee,
|
1064
|
+
(const xmlChar *)StringValuePtr(href),
|
1039
1065
|
(const xmlChar *)(NIL_P(prefix) ? NULL : StringValuePtr(prefix))
|
1040
1066
|
);
|
1041
1067
|
}
|
1042
1068
|
|
1043
|
-
if(
|
1069
|
+
if (!ns) return Qnil ;
|
1070
|
+
|
1071
|
+
if(NIL_P(prefix) || node != namespacee) xmlSetNs(node, ns);
|
1044
1072
|
|
1045
1073
|
return Nokogiri_wrap_xml_namespace(node->doc, ns);
|
1046
1074
|
}
|
@@ -1122,13 +1150,11 @@ static VALUE in_context(VALUE self, VALUE _str, VALUE _options)
|
|
1122
1150
|
xmlNodePtr node;
|
1123
1151
|
xmlNodePtr list;
|
1124
1152
|
xmlNodeSetPtr set;
|
1153
|
+
xmlParserErrors error;
|
1125
1154
|
VALUE doc, err;
|
1126
1155
|
|
1127
1156
|
Data_Get_Struct(self, xmlNode, node);
|
1128
1157
|
|
1129
|
-
if(!node->parent)
|
1130
|
-
rb_raise(rb_eRuntimeError, "no contextual parsing on unlinked nodes");
|
1131
|
-
|
1132
1158
|
doc = DOC_RUBY_OBJECT(node->doc);
|
1133
1159
|
err = rb_iv_get(doc, "@errors");
|
1134
1160
|
|
@@ -1141,7 +1167,7 @@ static VALUE in_context(VALUE self, VALUE _str, VALUE _options)
|
|
1141
1167
|
htmlHandleOmittedElem(0);
|
1142
1168
|
#endif
|
1143
1169
|
|
1144
|
-
xmlParseInNodeContext(
|
1170
|
+
error = xmlParseInNodeContext(
|
1145
1171
|
node,
|
1146
1172
|
StringValuePtr(_str),
|
1147
1173
|
(int)RSTRING_LEN(_str),
|
@@ -1154,6 +1180,20 @@ static VALUE in_context(VALUE self, VALUE _str, VALUE _options)
|
|
1154
1180
|
|
1155
1181
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
1156
1182
|
|
1183
|
+
/* FIXME: This probably needs to handle more constants... */
|
1184
|
+
switch(error) {
|
1185
|
+
case XML_ERR_OK:
|
1186
|
+
break;
|
1187
|
+
|
1188
|
+
case XML_ERR_INTERNAL_ERROR:
|
1189
|
+
case XML_ERR_NO_MEMORY:
|
1190
|
+
rb_raise(rb_eRuntimeError, "error parsing fragment (%d)", error);
|
1191
|
+
break;
|
1192
|
+
|
1193
|
+
default:
|
1194
|
+
break;
|
1195
|
+
}
|
1196
|
+
|
1157
1197
|
set = xmlXPathNodeSetCreate(NULL);
|
1158
1198
|
|
1159
1199
|
while(list) {
|
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(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
53
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
52
|
+
if(!(rb_obj_is_kind_of(rb_node, cNokogiriXmlNode) || rb_obj_is_kind_of(rb_node, cNokogiriXmlNamespace)))
|
53
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node or Nokogiri::XML::Namespace");
|
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(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
74
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
75
|
-
|
73
|
+
if(!(rb_obj_is_kind_of(rb_node, cNokogiriXmlNode) || rb_obj_is_kind_of(rb_node, cNokogiriXmlNamespace)))
|
74
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node or Nokogiri::XML::Namespace");
|
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(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
121
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
120
|
+
if(!(rb_obj_is_kind_of(rb_node, cNokogiriXmlNode) || rb_obj_is_kind_of(rb_node, cNokogiriXmlNamespace)))
|
121
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node or Nokogiri::XML::Namespace");
|
122
122
|
|
123
123
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
124
124
|
Data_Get_Struct(rb_node, xmlNode, node);
|
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,6 +620,24 @@ 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
|
+
|
623
641
|
VALUE cNokogiriXmlReader;
|
624
642
|
|
625
643
|
void init_xml_reader()
|
@@ -656,6 +674,7 @@ void init_xml_reader()
|
|
656
674
|
rb_define_method(klass, "attribute", reader_attribute, 1);
|
657
675
|
rb_define_method(klass, "namespaces", namespaces, 0);
|
658
676
|
rb_define_method(klass, "attribute_at", attribute_at, 1);
|
677
|
+
rb_define_method(klass, "empty_element?", empty_element_p, 0);
|
659
678
|
rb_define_method(klass, "attributes?", attributes_eh, 0);
|
660
679
|
rb_define_method(klass, "value?", value_eh, 0);
|
661
680
|
rb_define_method(klass, "default?", default_eh, 0);
|
data/ext/nokogiri/xml_relax_ng.c
CHANGED
@@ -129,9 +129,6 @@ static VALUE from_document(VALUE klass, VALUE document)
|
|
129
129
|
schema = xmlRelaxNGParse(ctx);
|
130
130
|
|
131
131
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
132
|
-
if (! is_2_6_16()) {
|
133
|
-
xmlRelaxNGFreeParserCtxt(ctx);
|
134
|
-
}
|
135
132
|
|
136
133
|
if(NULL == schema) {
|
137
134
|
xmlErrorPtr error = xmlGetLastError();
|
@@ -143,10 +140,6 @@ static VALUE from_document(VALUE klass, VALUE document)
|
|
143
140
|
return Qnil;
|
144
141
|
}
|
145
142
|
|
146
|
-
if (is_2_6_16()) {
|
147
|
-
xmlRelaxNGFreeParserCtxt(ctx);
|
148
|
-
}
|
149
|
-
|
150
143
|
rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
|
151
144
|
rb_iv_set(rb_schema, "@errors", errors);
|
152
145
|
|
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,7 +6,7 @@ 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 defined?
|
9
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
10
10
|
require 'isorelax.jar'
|
11
11
|
require 'jing.jar'
|
12
12
|
require 'nekohtml.jar'
|
@@ -35,7 +35,6 @@ Thanks,
|
|
35
35
|
eowarn
|
36
36
|
|
37
37
|
require 'nokogiri/version'
|
38
|
-
require 'nokogiri/version_warning'
|
39
38
|
require 'nokogiri/syntax_error'
|
40
39
|
require 'nokogiri/xml'
|
41
40
|
require 'nokogiri/xslt'
|
@@ -13,90 +13,90 @@ module Nokogiri
|
|
13
13
|
##### State transition tables begin ###
|
14
14
|
|
15
15
|
racc_action_table = [
|
16
|
-
|
17
|
-
41, 12,
|
18
|
-
|
19
|
-
12, 9, 10,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
4, 56, 27, 22, 12, 24, 57, 4, 65, 1,
|
17
|
+
41, 12, 75, 57, 4, 23, 1, 82, 12, 19,
|
18
|
+
93, 92, 5, 1, 9, 10, 19, 13, 16, 5,
|
19
|
+
12, 9, 10, 19, 13, 16, 5, 5, 9, 10,
|
20
|
+
4, 13, 16, 16, 12, 41, 64, 4, 5, 1,
|
21
|
+
60, 10, 12, 59, 16, 59, 28, 1, 29, 19,
|
22
|
+
12, 12, 5, 62, 9, 10, 19, 13, 16, 12,
|
23
|
+
5, 9, 83, 10, 12, 13, 16, 84, 5, 5,
|
24
|
+
63, 10, 10, 12, 16, 16, 58, 5, 61, 62,
|
25
|
+
10, 4, 5, 16, 87, 10, 27, 53, 16, 54,
|
26
|
+
49, 5, 88, 41, 10, 68, 70, 16, 27, 53,
|
27
|
+
19, 54, 44, 91, 21, 9, 69, 71, 72, 94,
|
28
|
+
74, 68, 70, -23, 66, 33, 35, 37, 27, 53,
|
29
|
+
96, 54, 69, 71, 72, 32, 74, 34, 36, 97,
|
30
|
+
66, 27, 53, nil, 54 ]
|
31
31
|
|
32
32
|
racc_action_check = [
|
33
|
-
0, 20,
|
34
|
-
39,
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
41,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
0, 20, 4, 4, 0, 4, 43, 9, 27, 0,
|
34
|
+
39, 9, 29, 20, 31, 4, 9, 43, 31, 0,
|
35
|
+
73, 73, 0, 31, 0, 0, 9, 0, 0, 9,
|
36
|
+
7, 9, 9, 31, 9, 9, 31, 14, 31, 31,
|
37
|
+
57, 31, 31, 14, 57, 7, 26, 5, 7, 57,
|
38
|
+
22, 7, 41, 53, 7, 22, 5, 41, 5, 57,
|
39
|
+
8, 79, 57, 54, 57, 57, 5, 57, 57, 18,
|
40
|
+
41, 5, 55, 41, 17, 41, 41, 56, 8, 79,
|
41
|
+
25, 8, 79, 15, 8, 79, 21, 18, 24, 24,
|
42
|
+
18, 16, 17, 18, 60, 17, 59, 59, 17, 59,
|
43
|
+
16, 15, 61, 11, 15, 30, 30, 15, 19, 19,
|
44
|
+
16, 19, 10, 67, 2, 16, 30, 30, 30, 76,
|
45
|
+
30, 28, 28, 1, 30, 6, 6, 6, 62, 62,
|
46
|
+
81, 62, 28, 28, 28, 6, 28, 6, 6, 88,
|
47
|
+
28, 65, 65, nil, 65 ]
|
48
48
|
|
49
49
|
racc_action_pointer = [
|
50
|
-
-2,
|
51
|
-
|
52
|
-
1,
|
53
|
-
|
50
|
+
-2, 95, 86, nil, -8, 45, 118, 24, 54, 5,
|
51
|
+
101, 82, nil, nil, 13, 77, 89, 68, 63, 98,
|
52
|
+
1, 75, 43, nil, 77, 57, 23, -4, 118, -13,
|
53
|
+
102, 12, nil, nil, nil, nil, nil, nil, nil, -11,
|
54
54
|
nil, 46, nil, -6, nil, nil, nil, nil, nil, nil,
|
55
|
-
nil,
|
56
|
-
|
57
|
-
nil,
|
58
|
-
nil, nil, nil, nil, nil, nil, nil, 126, nil,
|
59
|
-
nil, nil, nil, nil, nil, nil, nil ]
|
55
|
+
nil, nil, nil, 41, 51, 49, 77, 38, nil, 86,
|
56
|
+
81, 95, 118, nil, nil, 131, nil, 88, nil, nil,
|
57
|
+
nil, nil, nil, 10, nil, nil, 94, nil, nil, 55,
|
58
|
+
nil, 107, nil, nil, nil, nil, nil, nil, 126, nil,
|
59
|
+
nil, nil, nil, nil, nil, nil, nil, nil ]
|
60
60
|
|
61
61
|
racc_action_default = [
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-11, -
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
62
|
+
-24, -21, -69, -2, -69, -69, -18, -45, -50, -24,
|
63
|
+
-69, -16, -54, -22, -12, -53, -69, -52, -51, -69,
|
64
|
+
-69, -69, -38, -28, -36, -69, -69, -37, -57, -69,
|
65
|
+
-57, -24, -5, -3, -8, -4, -7, -6, -9, -44,
|
66
|
+
-11, -24, -46, -69, -19, -15, -13, -14, -49, -43,
|
67
|
+
-42, -48, -47, -38, -36, -69, -69, -24, -20, -69,
|
68
|
+
-69, -41, -69, -29, -30, -69, -58, -69, -63, -59,
|
69
|
+
-64, -60, -61, -69, -62, -27, -69, -17, -10, -66,
|
70
|
+
-68, -69, -32, -31, 98, -1, -35, -40, -69, -33,
|
71
|
+
-34, -25, -55, -56, -26, -67, -65, -39 ]
|
72
72
|
|
73
73
|
racc_goto_table = [
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
39, 42, 25, 40, 77, 30, 20, 45, 48, 79,
|
75
|
+
51, 52, 67, 46, 76, 43, 50, 55, 47, 38,
|
76
|
+
31, 26, 81, nil, nil, nil, nil, nil, nil, nil,
|
77
|
+
85, nil, nil, nil, 80, 78, nil, nil, nil, nil,
|
78
78
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
79
|
-
nil, nil, nil, nil, nil, nil, nil,
|
80
|
-
nil,
|
81
|
-
nil,
|
79
|
+
nil, nil, nil, nil, nil, nil, nil, 86, nil, nil,
|
80
|
+
89, nil, nil, 90, nil, nil, nil, nil, nil, nil,
|
81
|
+
nil, nil, 95 ]
|
82
82
|
|
83
83
|
racc_goto_check = [
|
84
|
-
7, 7,
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
7, 7, 15, 8, 2, 9, 1, 8, 7, 5,
|
85
|
+
7, 7, 14, 10, 14, 1, 9, 15, 11, 6,
|
86
|
+
3, 16, 19, nil, nil, nil, nil, nil, nil, nil,
|
87
|
+
2, nil, nil, nil, 7, 8, nil, nil, nil, nil,
|
88
88
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
89
|
-
nil, nil, nil, nil, nil, nil, nil,
|
90
|
-
nil,
|
91
|
-
nil, 7 ]
|
89
|
+
nil, nil, nil, nil, nil, nil, nil, 15, nil, nil,
|
90
|
+
15, nil, nil, 15, nil, nil, nil, nil, nil, nil,
|
91
|
+
nil, nil, 7 ]
|
92
92
|
|
93
93
|
racc_goto_pointer = [
|
94
|
-
nil, 6, -
|
95
|
-
|
94
|
+
nil, 6, -27, 14, nil, -32, 12, -7, -4, 0,
|
95
|
+
-1, 4, nil, nil, -16, -2, 17, nil, nil, -19 ]
|
96
96
|
|
97
97
|
racc_goto_default = [
|
98
|
-
nil, nil,
|
99
|
-
15, 17,
|
98
|
+
nil, nil, 3, nil, 6, 7, nil, 11, nil, 14,
|
99
|
+
15, 17, 18, 2, nil, nil, nil, 8, 73, nil ]
|
100
100
|
|
101
101
|
racc_reduce_table = [
|
102
102
|
0, 0, :racc_error,
|
@@ -114,63 +114,64 @@ racc_reduce_table = [
|
|
114
114
|
1, 35, :_reduce_none,
|
115
115
|
2, 35, :_reduce_13,
|
116
116
|
2, 35, :_reduce_14,
|
117
|
-
|
118
|
-
|
117
|
+
2, 35, :_reduce_15,
|
118
|
+
1, 35, :_reduce_16,
|
119
|
+
3, 33, :_reduce_17,
|
119
120
|
1, 33, :_reduce_none,
|
120
|
-
2,
|
121
|
-
3, 36, :
|
122
|
-
1, 36, :_reduce_20,
|
121
|
+
2, 43, :_reduce_19,
|
122
|
+
3, 36, :_reduce_20,
|
123
123
|
1, 36, :_reduce_21,
|
124
|
-
1,
|
125
|
-
|
126
|
-
|
127
|
-
4,
|
128
|
-
|
129
|
-
|
130
|
-
|
124
|
+
1, 36, :_reduce_22,
|
125
|
+
1, 44, :_reduce_23,
|
126
|
+
0, 44, :_reduce_none,
|
127
|
+
4, 42, :_reduce_25,
|
128
|
+
4, 42, :_reduce_26,
|
129
|
+
3, 42, :_reduce_27,
|
130
|
+
2, 40, :_reduce_28,
|
131
131
|
3, 40, :_reduce_29,
|
132
132
|
3, 40, :_reduce_30,
|
133
133
|
3, 40, :_reduce_31,
|
134
|
-
3,
|
135
|
-
3,
|
136
|
-
3,
|
137
|
-
|
138
|
-
1,
|
139
|
-
1,
|
140
|
-
|
141
|
-
|
142
|
-
|
134
|
+
3, 40, :_reduce_32,
|
135
|
+
3, 46, :_reduce_33,
|
136
|
+
3, 46, :_reduce_34,
|
137
|
+
3, 46, :_reduce_35,
|
138
|
+
1, 46, :_reduce_none,
|
139
|
+
1, 46, :_reduce_none,
|
140
|
+
1, 46, :_reduce_38,
|
141
|
+
4, 47, :_reduce_39,
|
142
|
+
3, 47, :_reduce_40,
|
143
143
|
2, 47, :_reduce_41,
|
144
|
-
2,
|
144
|
+
2, 41, :_reduce_42,
|
145
|
+
2, 41, :_reduce_43,
|
145
146
|
1, 37, :_reduce_none,
|
146
147
|
0, 37, :_reduce_none,
|
147
|
-
2, 38, :_reduce_45,
|
148
148
|
2, 38, :_reduce_46,
|
149
149
|
2, 38, :_reduce_47,
|
150
150
|
2, 38, :_reduce_48,
|
151
|
+
2, 38, :_reduce_49,
|
151
152
|
1, 38, :_reduce_none,
|
152
153
|
1, 38, :_reduce_none,
|
153
154
|
1, 38, :_reduce_none,
|
154
155
|
1, 38, :_reduce_none,
|
155
|
-
1, 48, :
|
156
|
-
2,
|
157
|
-
2,
|
158
|
-
0,
|
159
|
-
1, 49, :_reduce_57,
|
156
|
+
1, 48, :_reduce_54,
|
157
|
+
2, 45, :_reduce_55,
|
158
|
+
2, 45, :_reduce_56,
|
159
|
+
0, 45, :_reduce_none,
|
160
160
|
1, 49, :_reduce_58,
|
161
161
|
1, 49, :_reduce_59,
|
162
162
|
1, 49, :_reduce_60,
|
163
163
|
1, 49, :_reduce_61,
|
164
164
|
1, 49, :_reduce_62,
|
165
165
|
1, 49, :_reduce_63,
|
166
|
-
|
166
|
+
1, 49, :_reduce_64,
|
167
|
+
3, 39, :_reduce_65,
|
167
168
|
1, 50, :_reduce_none,
|
168
169
|
2, 50, :_reduce_none,
|
169
170
|
1, 50, :_reduce_none ]
|
170
171
|
|
171
|
-
racc_reduce_n =
|
172
|
+
racc_reduce_n = 69
|
172
173
|
|
173
|
-
racc_shift_n =
|
174
|
+
racc_shift_n = 98
|
174
175
|
|
175
176
|
racc_token_table = {
|
176
177
|
false => 0,
|
@@ -267,13 +268,13 @@ Racc_token_to_s_table = [
|
|
267
268
|
"hcap_1toN",
|
268
269
|
"negation",
|
269
270
|
"function",
|
271
|
+
"pseudo",
|
270
272
|
"attrib",
|
271
273
|
"class",
|
272
274
|
"namespace",
|
273
275
|
"attrib_val_0or1",
|
274
276
|
"expr",
|
275
277
|
"an_plus_b",
|
276
|
-
"pseudo",
|
277
278
|
"attribute_id",
|
278
279
|
"eql_incl_dash",
|
279
280
|
"negation_arg" ]
|
@@ -361,6 +362,12 @@ def _reduce_13(val, _values, result)
|
|
361
362
|
end
|
362
363
|
|
363
364
|
def _reduce_14(val, _values, result)
|
365
|
+
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
366
|
+
|
367
|
+
result
|
368
|
+
end
|
369
|
+
|
370
|
+
def _reduce_15(val, _values, result)
|
364
371
|
result = Node.new(:CONDITIONAL_SELECTOR,
|
365
372
|
[
|
366
373
|
Node.new(:ELEMENT_NAME, ['*']),
|
@@ -371,7 +378,7 @@ def _reduce_14(val, _values, result)
|
|
371
378
|
result
|
372
379
|
end
|
373
380
|
|
374
|
-
def
|
381
|
+
def _reduce_16(val, _values, result)
|
375
382
|
result = Node.new(:CONDITIONAL_SELECTOR,
|
376
383
|
[Node.new(:ELEMENT_NAME, ['*']), val.first]
|
377
384
|
)
|
@@ -379,20 +386,20 @@ def _reduce_15(val, _values, result)
|
|
379
386
|
result
|
380
387
|
end
|
381
388
|
|
382
|
-
def
|
389
|
+
def _reduce_17(val, _values, result)
|
383
390
|
result = Node.new(val[1], [val.first, val.last])
|
384
391
|
|
385
392
|
result
|
386
393
|
end
|
387
394
|
|
388
|
-
# reduce
|
395
|
+
# reduce 18 omitted
|
389
396
|
|
390
|
-
def
|
397
|
+
def _reduce_19(val, _values, result)
|
391
398
|
result = Node.new(:CLASS_CONDITION, [val[1]])
|
392
399
|
result
|
393
400
|
end
|
394
401
|
|
395
|
-
def
|
402
|
+
def _reduce_20(val, _values, result)
|
396
403
|
result = Node.new(:ELEMENT_NAME,
|
397
404
|
[[val.first, val.last].compact.join(':')]
|
398
405
|
)
|
@@ -400,26 +407,26 @@ def _reduce_19(val, _values, result)
|
|
400
407
|
result
|
401
408
|
end
|
402
409
|
|
403
|
-
def
|
410
|
+
def _reduce_21(val, _values, result)
|
404
411
|
name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
|
405
412
|
result = Node.new(:ELEMENT_NAME, [name])
|
406
413
|
|
407
414
|
result
|
408
415
|
end
|
409
416
|
|
410
|
-
def
|
417
|
+
def _reduce_22(val, _values, result)
|
411
418
|
result = Node.new(:ELEMENT_NAME, val)
|
412
419
|
result
|
413
420
|
end
|
414
421
|
|
415
|
-
def
|
422
|
+
def _reduce_23(val, _values, result)
|
416
423
|
result = val[0]
|
417
424
|
result
|
418
425
|
end
|
419
426
|
|
420
|
-
# reduce
|
427
|
+
# reduce 24 omitted
|
421
428
|
|
422
|
-
def
|
429
|
+
def _reduce_25(val, _values, result)
|
423
430
|
result = Node.new(:ATTRIBUTE_CONDITION,
|
424
431
|
[Node.new(:ELEMENT_NAME, [val[1]])] + (val[2] || [])
|
425
432
|
)
|
@@ -427,7 +434,7 @@ def _reduce_24(val, _values, result)
|
|
427
434
|
result
|
428
435
|
end
|
429
436
|
|
430
|
-
def
|
437
|
+
def _reduce_26(val, _values, result)
|
431
438
|
result = Node.new(:ATTRIBUTE_CONDITION,
|
432
439
|
[val[1]] + (val[2] || [])
|
433
440
|
)
|
@@ -435,7 +442,7 @@ def _reduce_25(val, _values, result)
|
|
435
442
|
result
|
436
443
|
end
|
437
444
|
|
438
|
-
def
|
445
|
+
def _reduce_27(val, _values, result)
|
439
446
|
# Non standard, but hpricot supports it.
|
440
447
|
result = Node.new(:PSEUDO_CLASS,
|
441
448
|
[Node.new(:FUNCTION, ['nth-child(', val[1]])]
|
@@ -444,14 +451,8 @@ def _reduce_26(val, _values, result)
|
|
444
451
|
result
|
445
452
|
end
|
446
453
|
|
447
|
-
def _reduce_27(val, _values, result)
|
448
|
-
result = Node.new(:FUNCTION, [val.first.strip])
|
449
|
-
|
450
|
-
result
|
451
|
-
end
|
452
|
-
|
453
454
|
def _reduce_28(val, _values, result)
|
454
|
-
result = Node.new(:FUNCTION, [val.first.strip
|
455
|
+
result = Node.new(:FUNCTION, [val.first.strip])
|
455
456
|
|
456
457
|
result
|
457
458
|
end
|
@@ -475,7 +476,8 @@ def _reduce_31(val, _values, result)
|
|
475
476
|
end
|
476
477
|
|
477
478
|
def _reduce_32(val, _values, result)
|
478
|
-
|
479
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
480
|
+
|
479
481
|
result
|
480
482
|
end
|
481
483
|
|
@@ -489,11 +491,16 @@ def _reduce_34(val, _values, result)
|
|
489
491
|
result
|
490
492
|
end
|
491
493
|
|
492
|
-
|
494
|
+
def _reduce_35(val, _values, result)
|
495
|
+
result = [val.first, val.last]
|
496
|
+
result
|
497
|
+
end
|
493
498
|
|
494
499
|
# reduce 36 omitted
|
495
500
|
|
496
|
-
|
501
|
+
# reduce 37 omitted
|
502
|
+
|
503
|
+
def _reduce_38(val, _values, result)
|
497
504
|
if val[0] == 'even'
|
498
505
|
val = ["2","n","+","0"]
|
499
506
|
result = Node.new(:AN_PLUS_B, val)
|
@@ -511,7 +518,7 @@ def _reduce_37(val, _values, result)
|
|
511
518
|
result
|
512
519
|
end
|
513
520
|
|
514
|
-
def
|
521
|
+
def _reduce_39(val, _values, result)
|
515
522
|
if val[1] == 'n'
|
516
523
|
result = Node.new(:AN_PLUS_B, val)
|
517
524
|
else
|
@@ -521,7 +528,7 @@ def _reduce_38(val, _values, result)
|
|
521
528
|
result
|
522
529
|
end
|
523
530
|
|
524
|
-
def
|
531
|
+
def _reduce_40(val, _values, result)
|
525
532
|
# n+3, -n+3
|
526
533
|
if val[0] == 'n'
|
527
534
|
val.unshift("1")
|
@@ -537,7 +544,7 @@ def _reduce_39(val, _values, result)
|
|
537
544
|
result
|
538
545
|
end
|
539
546
|
|
540
|
-
def
|
547
|
+
def _reduce_41(val, _values, result)
|
541
548
|
if val[1] == 'n'
|
542
549
|
val << "+"
|
543
550
|
val << "0"
|
@@ -549,26 +556,20 @@ def _reduce_40(val, _values, result)
|
|
549
556
|
result
|
550
557
|
end
|
551
558
|
|
552
|
-
def
|
559
|
+
def _reduce_42(val, _values, result)
|
553
560
|
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
554
561
|
|
555
562
|
result
|
556
563
|
end
|
557
564
|
|
558
|
-
def
|
565
|
+
def _reduce_43(val, _values, result)
|
559
566
|
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
560
567
|
result
|
561
568
|
end
|
562
569
|
|
563
|
-
# reduce 43 omitted
|
564
|
-
|
565
570
|
# reduce 44 omitted
|
566
571
|
|
567
|
-
|
568
|
-
result = Node.new(:COMBINATOR, val)
|
569
|
-
|
570
|
-
result
|
571
|
-
end
|
572
|
+
# reduce 45 omitted
|
572
573
|
|
573
574
|
def _reduce_46(val, _values, result)
|
574
575
|
result = Node.new(:COMBINATOR, val)
|
@@ -588,7 +589,11 @@ def _reduce_48(val, _values, result)
|
|
588
589
|
result
|
589
590
|
end
|
590
591
|
|
591
|
-
|
592
|
+
def _reduce_49(val, _values, result)
|
593
|
+
result = Node.new(:COMBINATOR, val)
|
594
|
+
|
595
|
+
result
|
596
|
+
end
|
592
597
|
|
593
598
|
# reduce 50 omitted
|
594
599
|
|
@@ -596,70 +601,72 @@ end
|
|
596
601
|
|
597
602
|
# reduce 52 omitted
|
598
603
|
|
599
|
-
|
604
|
+
# reduce 53 omitted
|
605
|
+
|
606
|
+
def _reduce_54(val, _values, result)
|
600
607
|
result = Node.new(:ID, val)
|
601
608
|
result
|
602
609
|
end
|
603
610
|
|
604
|
-
def
|
611
|
+
def _reduce_55(val, _values, result)
|
605
612
|
result = [val.first, val[1]]
|
606
613
|
result
|
607
614
|
end
|
608
615
|
|
609
|
-
def
|
616
|
+
def _reduce_56(val, _values, result)
|
610
617
|
result = [val.first, val[1]]
|
611
618
|
result
|
612
619
|
end
|
613
620
|
|
614
|
-
# reduce
|
621
|
+
# reduce 57 omitted
|
615
622
|
|
616
|
-
def
|
623
|
+
def _reduce_58(val, _values, result)
|
617
624
|
result = :equal
|
618
625
|
result
|
619
626
|
end
|
620
627
|
|
621
|
-
def
|
628
|
+
def _reduce_59(val, _values, result)
|
622
629
|
result = :prefix_match
|
623
630
|
result
|
624
631
|
end
|
625
632
|
|
626
|
-
def
|
633
|
+
def _reduce_60(val, _values, result)
|
627
634
|
result = :suffix_match
|
628
635
|
result
|
629
636
|
end
|
630
637
|
|
631
|
-
def
|
638
|
+
def _reduce_61(val, _values, result)
|
632
639
|
result = :substring_match
|
633
640
|
result
|
634
641
|
end
|
635
642
|
|
636
|
-
def
|
643
|
+
def _reduce_62(val, _values, result)
|
637
644
|
result = :not_equal
|
638
645
|
result
|
639
646
|
end
|
640
647
|
|
641
|
-
def
|
648
|
+
def _reduce_63(val, _values, result)
|
642
649
|
result = :includes
|
643
650
|
result
|
644
651
|
end
|
645
652
|
|
646
|
-
def
|
653
|
+
def _reduce_64(val, _values, result)
|
647
654
|
result = :dash_match
|
648
655
|
result
|
649
656
|
end
|
650
657
|
|
651
|
-
def
|
658
|
+
def _reduce_65(val, _values, result)
|
652
659
|
result = Node.new(:NOT, [val[1]])
|
653
660
|
|
654
661
|
result
|
655
662
|
end
|
656
663
|
|
657
|
-
# reduce 65 omitted
|
658
|
-
|
659
664
|
# reduce 66 omitted
|
660
665
|
|
661
666
|
# reduce 67 omitted
|
662
667
|
|
668
|
+
# reduce 68 omitted
|
669
|
+
|
663
670
|
def _reduce_none(val, _values, result)
|
664
671
|
val[0]
|
665
672
|
end
|