nokogiri 1.5.3.rc2-java → 1.5.3.rc3-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/CHANGELOG.ja.rdoc +2 -0
- data/CHANGELOG.rdoc +2 -0
- data/ext/nokogiri/xml_xpath_context.c +20 -16
- data/ext/nokogiri/xml_xpath_context.h +1 -0
- data/ext/nokogiri/xslt_stylesheet.c +7 -64
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xslt.rb +1 -1
- data/test/helper.rb +18 -45
- data/test/html/sax/test_parser.rb +5 -3
- data/test/html/sax/test_parser_context.rb +8 -10
- data/test/html/test_document.rb +1 -3
- data/test/html/test_node.rb +2 -4
- data/test/test_xslt_transforms.rb +3 -1
- data/test/xml/sax/test_parser_context.rb +10 -17
- data/test/xml/test_attr.rb +5 -6
- data/test/xml/test_builder.rb +5 -6
- data/test/xml/test_cdata.rb +1 -3
- data/test/xml/test_document.rb +5 -12
- data/test/xml/test_node_set.rb +2 -2
- data/test/xml/test_text.rb +1 -3
- data/test/xml/test_xpath.rb +4 -6
- data/test/xslt/test_custom_functions.rb +35 -0
- metadata +2 -2
data/CHANGELOG.ja.rdoc
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
* Nokogiri::XML::Node#css now works for XML documents with default
|
7
7
|
namespaces when the rule contains attribute selector without
|
8
8
|
namespace.
|
9
|
+
* Fixed marshalling bugs around how arguments are passed to (and
|
10
|
+
returned from) XSLT custom xpath functions. #640.
|
9
11
|
|
10
12
|
|
11
13
|
== 1.5.2 / 2012-03-09
|
data/CHANGELOG.rdoc
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
* Nokogiri::XML::Node#css now works for XML documents with default
|
7
7
|
namespaces when the rule contains attribute selector without
|
8
8
|
namespace.
|
9
|
+
* Fixed marshalling bugs around how arguments are passed to (and
|
10
|
+
returned from) XSLT custom xpath functions. #640.
|
9
11
|
|
10
12
|
|
11
13
|
== 1.5.2 / 2012-03-09
|
@@ -49,26 +49,19 @@ static VALUE register_variable(VALUE self, VALUE name, VALUE value)
|
|
49
49
|
return self;
|
50
50
|
}
|
51
51
|
|
52
|
-
|
52
|
+
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler, const char* function_name)
|
53
53
|
{
|
54
|
-
|
55
|
-
VALUE result;
|
54
|
+
int i;
|
55
|
+
VALUE result, doc;
|
56
56
|
VALUE *argv;
|
57
|
-
VALUE doc;
|
58
57
|
VALUE node_set = Qnil;
|
59
58
|
xmlNodeSetPtr xml_node_set = NULL;
|
60
59
|
xmlXPathObjectPtr obj;
|
61
|
-
int i;
|
62
60
|
nokogiriNodeSetTuple *node_set_tuple;
|
63
61
|
|
64
|
-
assert(ctx);
|
65
|
-
assert(ctx->context);
|
66
|
-
assert(ctx->context->userData);
|
67
62
|
assert(ctx->context->doc);
|
68
63
|
assert(DOC_RUBY_OBJECT_TEST(ctx->context->doc));
|
69
64
|
|
70
|
-
xpath_handler = (VALUE)(ctx->context->userData);
|
71
|
-
|
72
65
|
argv = (VALUE *)calloc((size_t)nargs, sizeof(VALUE));
|
73
66
|
for (i = 0 ; i < nargs ; ++i) {
|
74
67
|
rb_gc_register_address(&argv[i]);
|
@@ -100,12 +93,7 @@ static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
|
|
100
93
|
} while(i-- > 0);
|
101
94
|
}
|
102
95
|
|
103
|
-
result = rb_funcall2(
|
104
|
-
xpath_handler,
|
105
|
-
rb_intern((const char *)ctx->context->function),
|
106
|
-
nargs,
|
107
|
-
argv
|
108
|
-
);
|
96
|
+
result = rb_funcall2(handler, rb_intern((const char*)function_name), nargs, argv);
|
109
97
|
|
110
98
|
for (i = 0 ; i < nargs ; ++i) {
|
111
99
|
rb_gc_unregister_address(&argv[i]);
|
@@ -156,6 +144,22 @@ static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
|
|
156
144
|
}
|
157
145
|
}
|
158
146
|
|
147
|
+
static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
|
148
|
+
{
|
149
|
+
VALUE handler = Qnil;
|
150
|
+
const char *function = NULL ;
|
151
|
+
|
152
|
+
assert(ctx);
|
153
|
+
assert(ctx->context);
|
154
|
+
assert(ctx->context->userData);
|
155
|
+
assert(ctx->context->function);
|
156
|
+
|
157
|
+
handler = (VALUE)(ctx->context->userData);
|
158
|
+
function = (const char*)(ctx->context->function);
|
159
|
+
|
160
|
+
Nokogiri_marshal_xpath_funcall_and_return_values(ctx, nargs, handler, function);
|
161
|
+
}
|
162
|
+
|
159
163
|
static xmlXPathFunction lookup( void *ctx,
|
160
164
|
const xmlChar * name,
|
161
165
|
const xmlChar* ns_uri )
|
@@ -168,74 +168,17 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
|
|
168
168
|
|
169
169
|
static void method_caller(xmlXPathParserContextPtr ctxt, int nargs)
|
170
170
|
{
|
171
|
-
|
172
|
-
const
|
173
|
-
size_t i, count;
|
174
|
-
|
171
|
+
VALUE handler;
|
172
|
+
const char *function_name;
|
175
173
|
xsltTransformContextPtr transform;
|
176
|
-
|
177
|
-
VALUE obj;
|
178
|
-
VALUE *args;
|
179
|
-
VALUE result;
|
174
|
+
const xmlChar *functionURI;
|
180
175
|
|
181
176
|
transform = xsltXPathGetTransformContext(ctxt);
|
182
|
-
|
183
|
-
function = ctxt->context->function;
|
184
177
|
functionURI = ctxt->context->functionURI;
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
for(i = 0; i < count; i++) {
|
191
|
-
VALUE thing;
|
192
|
-
|
193
|
-
xpath = valuePop(ctxt);
|
194
|
-
switch(xpath->type) {
|
195
|
-
case XPATH_STRING:
|
196
|
-
thing = NOKOGIRI_STR_NEW2(xpath->stringval);
|
197
|
-
break;
|
198
|
-
case XPATH_NODESET:
|
199
|
-
if(NULL == xpath->nodesetval) {
|
200
|
-
thing = Nokogiri_wrap_xml_node_set(
|
201
|
-
xmlXPathNodeSetCreate(NULL),
|
202
|
-
DOC_RUBY_OBJECT(ctxt->context->doc));
|
203
|
-
} else {
|
204
|
-
thing = Nokogiri_wrap_xml_node_set(xpath->nodesetval,
|
205
|
-
DOC_RUBY_OBJECT(ctxt->context->doc));
|
206
|
-
}
|
207
|
-
break;
|
208
|
-
default:
|
209
|
-
rb_raise(rb_eRuntimeError, "do not handle type: %d", xpath->type);
|
210
|
-
}
|
211
|
-
args[i] = thing;
|
212
|
-
xmlFree(xpath);
|
213
|
-
}
|
214
|
-
result = rb_funcall3(obj, rb_intern((const char *)function), (int)count, args);
|
215
|
-
free(args);
|
216
|
-
switch(TYPE(result)) {
|
217
|
-
case T_FLOAT:
|
218
|
-
case T_BIGNUM:
|
219
|
-
case T_FIXNUM:
|
220
|
-
xmlXPathReturnNumber(ctxt, NUM2DBL(result));
|
221
|
-
break;
|
222
|
-
case T_STRING:
|
223
|
-
xmlXPathReturnString(
|
224
|
-
ctxt,
|
225
|
-
xmlStrdup((xmlChar *)StringValuePtr(result))
|
226
|
-
);
|
227
|
-
break;
|
228
|
-
case T_TRUE:
|
229
|
-
xmlXPathReturnTrue(ctxt);
|
230
|
-
break;
|
231
|
-
case T_FALSE:
|
232
|
-
xmlXPathReturnFalse(ctxt);
|
233
|
-
break;
|
234
|
-
case T_NIL:
|
235
|
-
break;
|
236
|
-
default:
|
237
|
-
rb_raise(rb_eRuntimeError, "Invalid return type");
|
238
|
-
}
|
178
|
+
handler = (VALUE)xsltGetExtData(transform, functionURI);
|
179
|
+
function_name = (const char*)(ctxt->context->function);
|
180
|
+
|
181
|
+
Nokogiri_marshal_xpath_funcall_and_return_values(ctxt, nargs, handler, (const char*)function_name);
|
239
182
|
}
|
240
183
|
|
241
184
|
static void * initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
|
data/lib/nokogiri/nokogiri.jar
CHANGED
Binary file
|
data/lib/nokogiri/version.rb
CHANGED
data/lib/nokogiri/xslt.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -11,25 +11,25 @@ warn "#{__FILE__}:#{__LINE__}: version info: #{Nokogiri::VERSION_INFO.inspect}"
|
|
11
11
|
|
12
12
|
module Nokogiri
|
13
13
|
class TestCase < MiniTest::Spec
|
14
|
-
ASSETS_DIR
|
15
|
-
XML_FILE = File.join(ASSETS_DIR, 'staff.xml')
|
16
|
-
XSLT_FILE = File.join(ASSETS_DIR, 'staff.xslt')
|
17
|
-
EXSLT_FILE = File.join(ASSETS_DIR, 'exslt.xslt')
|
18
|
-
EXML_FILE = File.join(ASSETS_DIR, 'exslt.xml')
|
19
|
-
HTML_FILE = File.join(ASSETS_DIR, 'tlm.html')
|
20
|
-
NICH_FILE = File.join(ASSETS_DIR, '2ch.html')
|
21
|
-
SHIFT_JIS_XML = File.join(ASSETS_DIR, 'shift_jis.xml')
|
22
|
-
SHIFT_JIS_HTML = File.join(ASSETS_DIR, 'shift_jis.html')
|
23
|
-
ENCODING_XHTML_FILE = File.join(ASSETS_DIR, 'encoding.xhtml')
|
24
|
-
ENCODING_HTML_FILE = File.join(ASSETS_DIR, 'encoding.html')
|
25
|
-
NOENCODING_FILE = File.join(ASSETS_DIR, 'noencoding.html')
|
26
|
-
METACHARSET_FILE = File.join(ASSETS_DIR, 'metacharset.html')
|
27
|
-
PO_XML_FILE = File.join(ASSETS_DIR, 'po.xml')
|
28
|
-
PO_SCHEMA_FILE = File.join(ASSETS_DIR, 'po.xsd')
|
14
|
+
ASSETS_DIR = File.expand_path File.join(File.dirname(__FILE__), 'files')
|
29
15
|
ADDRESS_SCHEMA_FILE = File.join(ASSETS_DIR, 'address_book.rlx')
|
30
|
-
ADDRESS_XML_FILE
|
31
|
-
|
32
|
-
|
16
|
+
ADDRESS_XML_FILE = File.join(ASSETS_DIR, 'address_book.xml')
|
17
|
+
ENCODING_HTML_FILE = File.join(ASSETS_DIR, 'encoding.html')
|
18
|
+
ENCODING_XHTML_FILE = File.join(ASSETS_DIR, 'encoding.xhtml')
|
19
|
+
EXML_FILE = File.join(ASSETS_DIR, 'exslt.xml')
|
20
|
+
EXSLT_FILE = File.join(ASSETS_DIR, 'exslt.xslt')
|
21
|
+
HTML_FILE = File.join(ASSETS_DIR, 'tlm.html')
|
22
|
+
METACHARSET_FILE = File.join(ASSETS_DIR, 'metacharset.html')
|
23
|
+
NICH_FILE = File.join(ASSETS_DIR, '2ch.html')
|
24
|
+
NOENCODING_FILE = File.join(ASSETS_DIR, 'noencoding.html')
|
25
|
+
PO_SCHEMA_FILE = File.join(ASSETS_DIR, 'po.xsd')
|
26
|
+
PO_XML_FILE = File.join(ASSETS_DIR, 'po.xml')
|
27
|
+
SHIFT_JIS_HTML = File.join(ASSETS_DIR, 'shift_jis.html')
|
28
|
+
SHIFT_JIS_XML = File.join(ASSETS_DIR, 'shift_jis.xml')
|
29
|
+
SNUGGLES_FILE = File.join(ASSETS_DIR, 'snuggles.xml')
|
30
|
+
XML_FILE = File.join(ASSETS_DIR, 'staff.xml')
|
31
|
+
XML_XINCLUDE_FILE = File.join(ASSETS_DIR, 'xinclude.xml')
|
32
|
+
XSLT_FILE = File.join(ASSETS_DIR, 'staff.xslt')
|
33
33
|
|
34
34
|
def teardown
|
35
35
|
if ENV['NOKOGIRI_GC']
|
@@ -68,33 +68,6 @@ module Nokogiri
|
|
68
68
|
alias :assert_not_nil :refute_nil
|
69
69
|
alias :assert_raise :assert_raises
|
70
70
|
alias :assert_not_equal :refute_equal
|
71
|
-
|
72
|
-
def assert_nothing_raised(*args)
|
73
|
-
self._assertions += 1
|
74
|
-
if Module === args.last
|
75
|
-
msg = nil
|
76
|
-
else
|
77
|
-
msg = args.pop
|
78
|
-
end
|
79
|
-
begin
|
80
|
-
line = __LINE__; yield
|
81
|
-
rescue Exception => e
|
82
|
-
bt = e.backtrace
|
83
|
-
as = e.instance_of?(MiniTest::Assertion)
|
84
|
-
if as
|
85
|
-
ans = /\A#{Regexp.quote(__FILE__)}:#{line}:in /o
|
86
|
-
bt.reject! {|ln| ans =~ ln}
|
87
|
-
end
|
88
|
-
if ((args.empty? && !as) ||
|
89
|
-
args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
|
90
|
-
msg = message(msg) { "Exception raised:\n<#{mu_pp(e)}>" }
|
91
|
-
raise MiniTest::Assertion, msg.call, bt
|
92
|
-
else
|
93
|
-
raise
|
94
|
-
end
|
95
|
-
end
|
96
|
-
nil
|
97
|
-
end
|
98
71
|
end
|
99
72
|
|
100
73
|
module SAX
|
@@ -12,19 +12,21 @@ module Nokogiri
|
|
12
12
|
|
13
13
|
def test_parse_empty_document
|
14
14
|
# This caused a segfault in libxml 2.6.x
|
15
|
-
|
15
|
+
assert_nil @parser.parse ''
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_parse_empty_file
|
19
19
|
# Make sure empty files don't break stuff
|
20
20
|
empty_file_name = File.join(Dir.tmpdir, 'bogus.xml')
|
21
21
|
FileUtils.touch empty_file_name
|
22
|
-
assert_nothing_raised
|
22
|
+
# assert_nothing_raised do
|
23
|
+
@parser.parse_file empty_file_name
|
24
|
+
# end
|
23
25
|
end
|
24
26
|
|
25
27
|
def test_parse_file
|
26
28
|
@parser.parse_file(HTML_FILE)
|
27
|
-
|
29
|
+
|
28
30
|
# Take a look at the comment in test_parse_document to know
|
29
31
|
# a possible reason to this difference.
|
30
32
|
if Nokogiri.uses_libxml?
|
@@ -7,15 +7,13 @@ module Nokogiri
|
|
7
7
|
module SAX
|
8
8
|
class TestParserContext < Nokogiri::SAX::TestCase
|
9
9
|
def test_from_io
|
10
|
-
|
11
|
-
|
12
|
-
end
|
10
|
+
ctx = ParserContext.new StringIO.new('fo'), 'UTF-8'
|
11
|
+
assert ctx
|
13
12
|
end
|
14
13
|
|
15
14
|
def test_from_string
|
16
|
-
|
17
|
-
|
18
|
-
end
|
15
|
+
ctx = ParserContext.new 'blah blah'
|
16
|
+
assert ctx
|
19
17
|
end
|
20
18
|
|
21
19
|
def test_parse_with
|
@@ -26,20 +24,20 @@ module Nokogiri
|
|
26
24
|
end
|
27
25
|
|
28
26
|
def test_parse_with_sax_parser
|
29
|
-
assert_nothing_raised do
|
27
|
+
# assert_nothing_raised do
|
30
28
|
xml = "<root />"
|
31
29
|
ctx = ParserContext.new xml
|
32
30
|
parser = Parser.new Doc.new
|
33
31
|
ctx.parse_with parser
|
34
|
-
end
|
32
|
+
# end
|
35
33
|
end
|
36
34
|
|
37
35
|
def test_from_file
|
38
|
-
assert_nothing_raised do
|
36
|
+
# assert_nothing_raised do
|
39
37
|
ctx = ParserContext.file HTML_FILE, 'UTF-8'
|
40
38
|
parser = Parser.new Doc.new
|
41
39
|
ctx.parse_with parser
|
42
|
-
end
|
40
|
+
# end
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
data/test/html/test_document.rb
CHANGED
@@ -232,9 +232,7 @@ eohtml
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def test_parse_handles_nil_gracefully
|
235
|
-
|
236
|
-
@doc = Nokogiri::HTML::Document.parse(nil)
|
237
|
-
end
|
235
|
+
@doc = Nokogiri::HTML::Document.parse(nil)
|
238
236
|
assert_instance_of Nokogiri::HTML::Document, @doc
|
239
237
|
end
|
240
238
|
|
data/test/html/test_node.rb
CHANGED
@@ -101,9 +101,7 @@ module Nokogiri
|
|
101
101
|
assert another_node, 'should have a node'
|
102
102
|
|
103
103
|
# This used to segv
|
104
|
-
|
105
|
-
node.add_previous_sibling another_node
|
106
|
-
end
|
104
|
+
assert node.add_previous_sibling another_node
|
107
105
|
end
|
108
106
|
|
109
107
|
def test_swap
|
@@ -138,7 +136,7 @@ module Nokogiri
|
|
138
136
|
|
139
137
|
def test_fragment_handler_does_not_regurge_on_invalid_attributes
|
140
138
|
iframe = %Q{<iframe style="width: 0%; height: 0px" src="http://someurl" allowtransparency></iframe>}
|
141
|
-
|
139
|
+
assert @html.at('div').fragment(iframe)
|
142
140
|
end
|
143
141
|
|
144
142
|
def test_fragment
|
@@ -158,7 +158,9 @@ encoding="iso-8859-1" indent="yes"/>
|
|
158
158
|
assert_equal result_array, result_hash
|
159
159
|
end
|
160
160
|
|
161
|
-
if Nokogiri.uses_libxml?
|
161
|
+
if Nokogiri.uses_libxml?
|
162
|
+
# By now, cannot get it working on JRuby, see:
|
163
|
+
# http://yokolet.blogspot.com/2010/10/pure-java-nokogiri-xslt-extension.html
|
162
164
|
def test_exslt
|
163
165
|
assert doc = Nokogiri::XML.parse(File.read(EXML_FILE))
|
164
166
|
assert doc.xml?
|
@@ -66,15 +66,12 @@ world
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_from_io
|
69
|
-
|
70
|
-
|
71
|
-
end
|
69
|
+
ctx = ParserContext.new StringIO.new('fo'), 'UTF-8'
|
70
|
+
assert ctx
|
72
71
|
end
|
73
72
|
|
74
73
|
def test_from_string
|
75
|
-
|
76
|
-
ParserContext.new 'blah blah'
|
77
|
-
end
|
74
|
+
assert ParserContext.new 'blah blah'
|
78
75
|
end
|
79
76
|
|
80
77
|
def test_parse_with
|
@@ -85,20 +82,16 @@ world
|
|
85
82
|
end
|
86
83
|
|
87
84
|
def test_parse_with_sax_parser
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
ctx.parse_with parser
|
93
|
-
end
|
85
|
+
xml = "<root />"
|
86
|
+
ctx = ParserContext.new xml
|
87
|
+
parser = Parser.new Doc.new
|
88
|
+
assert_nil ctx.parse_with parser
|
94
89
|
end
|
95
90
|
|
96
91
|
def test_from_file
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
ctx.parse_with parser
|
101
|
-
end
|
92
|
+
ctx = ParserContext.file XML_FILE
|
93
|
+
parser = Parser.new Doc.new
|
94
|
+
assert_nil ctx.parse_with parser
|
102
95
|
end
|
103
96
|
|
104
97
|
def test_parse_with_returns_nil
|
data/test/xml/test_attr.rb
CHANGED
@@ -4,12 +4,11 @@ module Nokogiri
|
|
4
4
|
module XML
|
5
5
|
class TestAttr < Nokogiri::TestCase
|
6
6
|
def test_new
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
7
|
+
100.times {
|
8
|
+
doc = Nokogiri::XML::Document.new
|
9
|
+
assert doc
|
10
|
+
assert Nokogiri::XML::Attr.new(doc, 'foo')
|
11
|
+
}
|
13
12
|
end
|
14
13
|
|
15
14
|
def test_content=
|
data/test/xml/test_builder.rb
CHANGED
@@ -47,14 +47,13 @@ module Nokogiri
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_builder_with_unlink
|
50
|
-
|
51
|
-
|
52
|
-
xml.
|
53
|
-
|
54
|
-
xml.bar2
|
55
|
-
end
|
50
|
+
b = Nokogiri::XML::Builder.new do |xml|
|
51
|
+
xml.foo do
|
52
|
+
xml.bar { xml.parent.unlink }
|
53
|
+
xml.bar2
|
56
54
|
end
|
57
55
|
end
|
56
|
+
assert b
|
58
57
|
end
|
59
58
|
|
60
59
|
def test_with_root
|
data/test/xml/test_cdata.rb
CHANGED
data/test/xml/test_document.rb
CHANGED
@@ -124,9 +124,8 @@ module Nokogiri
|
|
124
124
|
|
125
125
|
def test_pp
|
126
126
|
out = StringIO.new('')
|
127
|
-
|
128
|
-
|
129
|
-
end
|
127
|
+
::PP.pp @xml, out
|
128
|
+
assert_operator out.string.length, :>, 0
|
130
129
|
end
|
131
130
|
|
132
131
|
def test_create_internal_subset_on_existing_subset
|
@@ -295,9 +294,7 @@ module Nokogiri
|
|
295
294
|
end
|
296
295
|
|
297
296
|
def test_parse_handles_nil_gracefully
|
298
|
-
|
299
|
-
@doc = Nokogiri::XML::Document.parse(nil)
|
300
|
-
end
|
297
|
+
@doc = Nokogiri::XML::Document.parse(nil)
|
301
298
|
assert_instance_of Nokogiri::XML::Document, @doc
|
302
299
|
end
|
303
300
|
|
@@ -633,9 +630,7 @@ module Nokogiri
|
|
633
630
|
|
634
631
|
def test_new
|
635
632
|
doc = nil
|
636
|
-
|
637
|
-
doc = Nokogiri::XML::Document.new
|
638
|
-
}
|
633
|
+
doc = Nokogiri::XML::Document.new
|
639
634
|
assert doc
|
640
635
|
assert doc.xml?
|
641
636
|
assert_nil doc.root
|
@@ -643,9 +638,7 @@ module Nokogiri
|
|
643
638
|
|
644
639
|
def test_set_root
|
645
640
|
doc = nil
|
646
|
-
|
647
|
-
doc = Nokogiri::XML::Document.new
|
648
|
-
}
|
641
|
+
doc = Nokogiri::XML::Document.new
|
649
642
|
assert doc
|
650
643
|
assert doc.xml?
|
651
644
|
assert_nil doc.root
|
data/test/xml/test_node_set.rb
CHANGED
@@ -168,7 +168,7 @@ module Nokogiri
|
|
168
168
|
set = html.xpath("/html/body/div")
|
169
169
|
assert_equal set.first, set.search(".a").first
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
def test_css_search_with_namespace
|
173
173
|
fragment = Nokogiri::XML.fragment(<<-eoxml)
|
174
174
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
@@ -176,7 +176,7 @@ module Nokogiri
|
|
176
176
|
<body></body>
|
177
177
|
</html>
|
178
178
|
eoxml
|
179
|
-
|
179
|
+
assert fragment.children.search( 'body', { 'xmlns' => 'http://www.w3.org/1999/xhtml' })
|
180
180
|
end
|
181
181
|
|
182
182
|
def test_double_equal
|
data/test/xml/test_text.rb
CHANGED
data/test/xml/test_xpath.rb
CHANGED
@@ -100,12 +100,10 @@ module Nokogiri
|
|
100
100
|
|
101
101
|
def test_css_search_uses_custom_selectors
|
102
102
|
set = @xml.xpath('//employee')
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
@xml.xpath("//employee[nokogiri:thing(.)]", @ns, @handler)
|
108
|
-
end
|
103
|
+
if Nokogiri.uses_libxml?
|
104
|
+
@xml.css('employee:thing()', @handler)
|
105
|
+
else
|
106
|
+
@xml.xpath("//employee[nokogiri:thing(.)]", @ns, @handler)
|
109
107
|
end
|
110
108
|
assert_equal(set.length, @handler.things.length)
|
111
109
|
assert_equal(set.to_a, @handler.things.flatten)
|
@@ -58,6 +58,41 @@ EOXSL
|
|
58
58
|
assert_equal 'FOO', result.css('title').first.text
|
59
59
|
end
|
60
60
|
|
61
|
+
|
62
|
+
def test_function_arguments
|
63
|
+
skip("Pure Java version doesn't support this feature.") if !Nokogiri.uses_libxml?
|
64
|
+
foo = Class.new do
|
65
|
+
include MiniTest::Assertions
|
66
|
+
|
67
|
+
def multiarg *args
|
68
|
+
assert_equal ["abc", "xyz"], args
|
69
|
+
args.first
|
70
|
+
end
|
71
|
+
|
72
|
+
def numericarg arg
|
73
|
+
assert_equal 42, arg
|
74
|
+
arg
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
xsl = Nokogiri.XSLT(<<-EOXSL, "http://e.org/functions" => foo)
|
79
|
+
<?xml version="1.0"?>
|
80
|
+
<xsl:stylesheet version="1.0"
|
81
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
82
|
+
xmlns:f="http://e.org/functions"
|
83
|
+
extension-element-prefixes="f">
|
84
|
+
|
85
|
+
<xsl:template match="text()">
|
86
|
+
<xsl:copy-of select="f:multiarg('abc', 'xyz')"/>
|
87
|
+
<xsl:copy-of select="f:numericarg(42)"/>
|
88
|
+
</xsl:template>
|
89
|
+
</xsl:stylesheet>
|
90
|
+
EOXSL
|
91
|
+
|
92
|
+
xsl.transform @xml
|
93
|
+
end
|
94
|
+
|
95
|
+
|
61
96
|
def test_function_XSLT
|
62
97
|
skip("Pure Java version doesn't support this feature.") if !Nokogiri.uses_libxml?
|
63
98
|
foo = Class.new do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.5.3.
|
5
|
+
version: 1.5.3.rc3
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Aaron Patterson
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2012-03-
|
15
|
+
date: 2012-03-26 00:00:00 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: hoe-bundler
|