nokogiri 1.5.0.beta.2 → 1.5.0.beta.3
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 +63 -0
- data/CHANGELOG.rdoc +44 -1
- data/Manifest.txt +3 -3
- data/README.ja.rdoc +4 -4
- data/README.rdoc +4 -4
- data/Rakefile +3 -0
- data/bin/nokogiri +6 -1
- data/ext/java/nokogiri/EncodingHandler.java +32 -0
- data/ext/java/nokogiri/HtmlDocument.java +36 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +34 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +34 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +41 -3
- data/ext/java/nokogiri/NokogiriService.java +109 -13
- data/ext/java/nokogiri/XmlAttr.java +40 -4
- data/ext/java/nokogiri/XmlAttributeDecl.java +32 -0
- data/ext/java/nokogiri/XmlCdata.java +41 -2
- data/ext/java/nokogiri/XmlComment.java +38 -1
- data/ext/java/nokogiri/XmlDocument.java +56 -11
- data/ext/java/nokogiri/XmlDocumentFragment.java +39 -30
- data/ext/java/nokogiri/XmlDtd.java +37 -0
- data/ext/java/nokogiri/XmlElement.java +51 -2
- data/ext/java/nokogiri/XmlElementContent.java +32 -0
- data/ext/java/nokogiri/XmlElementDecl.java +32 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +32 -0
- data/ext/java/nokogiri/XmlEntityReference.java +35 -2
- data/ext/java/nokogiri/XmlNamespace.java +55 -5
- data/ext/java/nokogiri/XmlNode.java +129 -136
- data/ext/java/nokogiri/XmlNodeSet.java +36 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +34 -1
- data/ext/java/nokogiri/XmlReader.java +36 -0
- data/ext/java/nokogiri/XmlRelaxng.java +34 -1
- data/ext/java/nokogiri/XmlSaxParserContext.java +52 -7
- data/ext/java/nokogiri/XmlSaxPushParser.java +36 -0
- data/ext/java/nokogiri/XmlSchema.java +34 -1
- data/ext/java/nokogiri/XmlSyntaxError.java +48 -18
- data/ext/java/nokogiri/XmlText.java +45 -6
- data/ext/java/nokogiri/XmlXpathContext.java +45 -0
- data/ext/java/nokogiri/XsltStylesheet.java +58 -3
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +50 -26
- data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +35 -1
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +51 -13
- data/ext/java/nokogiri/internals/NokogiriHandler.java +70 -21
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +95 -38
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +37 -3
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +39 -1
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +43 -7
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +77 -10
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +49 -20
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +34 -2
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -1
- data/ext/java/nokogiri/internals/ParserContext.java +32 -0
- data/ext/java/nokogiri/internals/PushInputStream.java +33 -3
- data/ext/java/nokogiri/internals/ReaderNode.java +50 -8
- data/ext/java/nokogiri/internals/SaveContext.java +35 -2
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +34 -1
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +32 -0
- data/ext/java/nokogiri/internals/XmlDomParser.java +32 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +43 -11
- data/ext/java/nokogiri/internals/XmlSaxParser.java +32 -0
- data/ext/java/nokogiri/internals/XsltExtensionFunction.java +72 -0
- data/ext/nokogiri/depend +358 -32
- data/ext/nokogiri/extconf.rb +1 -3
- data/ext/nokogiri/nokogiri.c +2 -0
- data/ext/nokogiri/nokogiri.h +7 -0
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_io.c +2 -2
- data/ext/nokogiri/xml_node.c +31 -6
- data/ext/nokogiri/xml_node_set.c +1 -1
- data/ext/nokogiri/xml_sax_parser.c +1 -1
- data/ext/nokogiri/xml_sax_parser_context.c +40 -0
- data/ext/nokogiri/xml_xpath_context.c +33 -2
- data/ext/nokogiri/xslt_stylesheet.c +122 -6
- data/lib/nokogiri.rb +12 -5
- data/lib/nokogiri/css/generated_tokenizer.rb +1 -2
- data/lib/nokogiri/css/xpath_visitor.rb +15 -7
- data/lib/nokogiri/decorators/slop.rb +5 -3
- data/lib/nokogiri/html/document.rb +3 -3
- data/lib/nokogiri/html/document_fragment.rb +19 -17
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/document.rb +26 -1
- data/lib/nokogiri/xml/document_fragment.rb +2 -2
- data/lib/nokogiri/xml/dtd.rb +11 -0
- data/lib/nokogiri/xml/node.rb +156 -45
- data/lib/nokogiri/xml/node_set.rb +2 -2
- data/lib/nokogiri/xml/reader.rb +36 -0
- data/lib/nokogiri/xml/sax/document.rb +4 -2
- data/lib/nokogiri/xslt.rb +9 -5
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- data/tasks/cross_compile.rb +27 -8
- data/test/css/test_parser.rb +29 -18
- data/test/decorators/test_slop.rb +16 -0
- data/test/html/test_document_fragment.rb +46 -3
- data/test/html/test_node.rb +9 -0
- data/test/xml/sax/test_parser.rb +11 -3
- data/test/xml/sax/test_parser_context.rb +50 -0
- data/test/xml/sax/test_push_parser.rb +18 -1
- data/test/xml/test_document_fragment.rb +15 -8
- data/test/xml/test_dtd.rb +15 -0
- data/test/xml/test_node.rb +31 -2
- data/test/xml/test_node_reparenting.rb +59 -31
- data/test/xml/test_node_set.rb +13 -0
- data/test/xml/test_xpath.rb +32 -0
- data/test/xslt/test_custom_functions.rb +94 -0
- metadata +83 -81
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/spec/helper.rb +0 -3
- data/spec/xml/reader_spec.rb +0 -307
@@ -1,5 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2010:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
32
|
+
|
1
33
|
package nokogiri;
|
2
34
|
|
35
|
+
import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
|
36
|
+
|
3
37
|
import java.io.ByteArrayInputStream;
|
4
38
|
import java.io.InputStream;
|
5
39
|
import java.nio.charset.Charset;
|
@@ -22,9 +56,13 @@ import org.jruby.runtime.ThreadContext;
|
|
22
56
|
import org.jruby.runtime.builtin.IRubyObject;
|
23
57
|
import org.xml.sax.SAXException;
|
24
58
|
|
59
|
+
/**
|
60
|
+
* Class for Nokogiri::HTML::SAX::ParserContext.
|
61
|
+
*
|
62
|
+
*/
|
63
|
+
|
25
64
|
@JRubyClass(name="Nokogiri::HTML::SAX::ParserContext", parent="Nokogiri::XML::SAX::ParserContext")
|
26
65
|
public class HtmlSaxParserContext extends XmlSaxParserContext {
|
27
|
-
private SAXParser parser;
|
28
66
|
|
29
67
|
public HtmlSaxParserContext(Ruby ruby, RubyClass rubyClass) {
|
30
68
|
super(ruby, rubyClass);
|
@@ -55,7 +93,7 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
|
|
55
93
|
new HtmlSaxParserContext(context.getRuntime(), (RubyClass) klazz);
|
56
94
|
String javaEncoding = findEncoding(context, encoding);
|
57
95
|
if (javaEncoding != null) {
|
58
|
-
String input = applyEncoding((
|
96
|
+
String input = applyEncoding(rubyStringToString(data), javaEncoding);
|
59
97
|
ByteArrayInputStream istream = new ByteArrayInputStream(input.getBytes());
|
60
98
|
ctx.setInputSource(istream);
|
61
99
|
ctx.getInputSource().setEncoding(javaEncoding);
|
@@ -115,7 +153,7 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
|
|
115
153
|
private static String findEncoding(ThreadContext context, IRubyObject encoding) {
|
116
154
|
String rubyEncoding = null;
|
117
155
|
if (encoding instanceof RubyString) {
|
118
|
-
rubyEncoding = (
|
156
|
+
rubyEncoding = rubyStringToString(encoding);
|
119
157
|
} else if (encoding instanceof RubyFixnum) {
|
120
158
|
int value = (Integer)encoding.toJava(Integer.class);
|
121
159
|
rubyEncoding = findName(value);
|
@@ -1,7 +1,36 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2010:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
2
32
|
|
3
|
-
|
4
|
-
import java.util.List;
|
33
|
+
package nokogiri;
|
5
34
|
|
6
35
|
import org.jruby.Ruby;
|
7
36
|
import org.jruby.RubyArray;
|
@@ -14,7 +43,9 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
14
43
|
import org.jruby.runtime.load.BasicLibraryService;
|
15
44
|
|
16
45
|
/**
|
17
|
-
*
|
46
|
+
* Class to provide Nokogiri. This class is used to make "require 'nokogiri'" work
|
47
|
+
* in JRuby. Also, this class holds a Ruby type cache and allocators of Ruby types.
|
48
|
+
*
|
18
49
|
* @author headius
|
19
50
|
*/
|
20
51
|
public class NokogiriService implements BasicLibraryService {
|
@@ -183,6 +214,7 @@ public class NokogiriService implements BasicLibraryService {
|
|
183
214
|
private void createXsltModule(Ruby ruby, RubyModule xsltModule) {
|
184
215
|
RubyClass stylesheet = xsltModule.defineClassUnder("Stylesheet", ruby.getObject(), XSLT_STYLESHEET_ALLOCATOR);
|
185
216
|
stylesheet.defineAnnotatedMethods(XsltStylesheet.class);
|
217
|
+
xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
|
186
218
|
}
|
187
219
|
|
188
220
|
private static ObjectAllocator ENCODING_HANDLER_ALLOCATOR = new ObjectAllocator() {
|
@@ -192,8 +224,16 @@ public class NokogiriService implements BasicLibraryService {
|
|
192
224
|
};
|
193
225
|
|
194
226
|
private static ObjectAllocator HTML_DOCUMENT_ALLOCATOR = new ObjectAllocator() {
|
227
|
+
private HtmlDocument htmlDocument = null;
|
195
228
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
196
|
-
|
229
|
+
if (htmlDocument == null) htmlDocument = new HtmlDocument(runtime, klazz);
|
230
|
+
try {
|
231
|
+
HtmlDocument clone = (HtmlDocument) htmlDocument.clone();
|
232
|
+
clone.setMetaClass(klazz);
|
233
|
+
return clone;
|
234
|
+
} catch (CloneNotSupportedException e) {
|
235
|
+
return new HtmlDocument(runtime, klazz);
|
236
|
+
}
|
197
237
|
}
|
198
238
|
};
|
199
239
|
|
@@ -218,20 +258,44 @@ public class NokogiriService implements BasicLibraryService {
|
|
218
258
|
};
|
219
259
|
|
220
260
|
private static ObjectAllocator XML_ATTR_ALLOCATOR = new ObjectAllocator() {
|
221
|
-
|
222
|
-
|
261
|
+
private XmlAttr xmlAttr = null;
|
262
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
263
|
+
if (xmlAttr == null) xmlAttr = new XmlAttr(runtime, klazz);
|
264
|
+
try {
|
265
|
+
XmlAttr clone = (XmlAttr) xmlAttr.clone();
|
266
|
+
clone.setMetaClass(klazz);
|
267
|
+
return clone;
|
268
|
+
} catch (CloneNotSupportedException e) {
|
269
|
+
return new XmlAttr(runtime, klazz);
|
270
|
+
}
|
223
271
|
}
|
224
272
|
};
|
225
273
|
|
226
274
|
private static ObjectAllocator XML_CDATA_ALLOCATOR = new ObjectAllocator() {
|
275
|
+
private XmlCdata xmlCdata = null;
|
227
276
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
228
|
-
|
277
|
+
if (xmlCdata == null) xmlCdata = new XmlCdata(runtime, klazz);
|
278
|
+
try {
|
279
|
+
XmlCdata clone = (XmlCdata) xmlCdata.clone();
|
280
|
+
clone.setMetaClass(klazz);
|
281
|
+
return clone;
|
282
|
+
} catch (CloneNotSupportedException e) {
|
283
|
+
return new XmlCdata(runtime, klazz);
|
284
|
+
}
|
229
285
|
}
|
230
286
|
};
|
231
287
|
|
232
288
|
private static ObjectAllocator XML_COMMENT_ALLOCATOR = new ObjectAllocator() {
|
289
|
+
private XmlComment xmlComment = null;
|
233
290
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
234
|
-
|
291
|
+
if (xmlComment == null) xmlComment = new XmlComment(runtime, klazz);
|
292
|
+
try {
|
293
|
+
XmlComment clone = (XmlComment) xmlComment.clone();
|
294
|
+
clone.setMetaClass(klazz);
|
295
|
+
return clone;
|
296
|
+
} catch (CloneNotSupportedException e) {
|
297
|
+
return new XmlComment(runtime, klazz);
|
298
|
+
}
|
235
299
|
}
|
236
300
|
};
|
237
301
|
|
@@ -243,8 +307,16 @@ public class NokogiriService implements BasicLibraryService {
|
|
243
307
|
};
|
244
308
|
|
245
309
|
private static ObjectAllocator XML_DOCUMENT_ALLOCATOR = new ObjectAllocator() {
|
310
|
+
private XmlDocument xmlDocument = null;
|
246
311
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
247
|
-
|
312
|
+
if (xmlDocument == null) xmlDocument = new XmlDocument(runtime, klazz);
|
313
|
+
try {
|
314
|
+
XmlDocument clone = (XmlDocument) xmlDocument.clone();
|
315
|
+
clone.setMetaClass(klazz);
|
316
|
+
return clone;
|
317
|
+
} catch (CloneNotSupportedException e) {
|
318
|
+
return new XmlDocument(runtime, klazz);
|
319
|
+
}
|
248
320
|
}
|
249
321
|
};
|
250
322
|
|
@@ -261,8 +333,16 @@ public class NokogiriService implements BasicLibraryService {
|
|
261
333
|
};
|
262
334
|
|
263
335
|
private static ObjectAllocator XML_ELEMENT_ALLOCATOR = new ObjectAllocator() {
|
336
|
+
private XmlElement xmlElement = null;
|
264
337
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
265
|
-
|
338
|
+
if (xmlElement == null) xmlElement = new XmlElement(runtime, klazz);
|
339
|
+
try {
|
340
|
+
XmlElement clone = (XmlElement)xmlElement.clone();
|
341
|
+
clone.setMetaClass(klazz);
|
342
|
+
return clone;
|
343
|
+
} catch (CloneNotSupportedException e) {
|
344
|
+
return new XmlElement(runtime, klazz);
|
345
|
+
}
|
266
346
|
}
|
267
347
|
};
|
268
348
|
|
@@ -273,14 +353,30 @@ public class NokogiriService implements BasicLibraryService {
|
|
273
353
|
};
|
274
354
|
|
275
355
|
private static ObjectAllocator XML_NAMESPACE_ALLOCATOR = new ObjectAllocator() {
|
356
|
+
private XmlNamespace xmlNamespace = null;
|
276
357
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
277
|
-
|
358
|
+
if (xmlNamespace == null) xmlNamespace = new XmlNamespace(runtime, klazz);
|
359
|
+
try {
|
360
|
+
XmlNamespace clone = (XmlNamespace) xmlNamespace.clone();
|
361
|
+
clone.setMetaClass(klazz);
|
362
|
+
return clone;
|
363
|
+
} catch (CloneNotSupportedException e) {
|
364
|
+
return new XmlNamespace(runtime, klazz);
|
365
|
+
}
|
278
366
|
}
|
279
367
|
};
|
280
368
|
|
281
369
|
private static ObjectAllocator XML_NODE_ALLOCATOR = new ObjectAllocator() {
|
370
|
+
private XmlNode xmlNode = null;
|
282
371
|
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
283
|
-
|
372
|
+
if (xmlNode == null) xmlNode = new XmlNode(runtime, klazz);
|
373
|
+
try {
|
374
|
+
XmlNode clone = (XmlNode) xmlNode.clone();
|
375
|
+
clone.setMetaClass(klazz);
|
376
|
+
return clone;
|
377
|
+
} catch (CloneNotSupportedException e) {
|
378
|
+
return new XmlNode(runtime, klazz);
|
379
|
+
}
|
284
380
|
}
|
285
381
|
};
|
286
382
|
|
@@ -1,3 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2010:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
32
|
+
|
1
33
|
package nokogiri;
|
2
34
|
|
3
35
|
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
@@ -10,13 +42,17 @@ import org.jruby.RubyClass;
|
|
10
42
|
import org.jruby.RubyString;
|
11
43
|
import org.jruby.anno.JRubyClass;
|
12
44
|
import org.jruby.anno.JRubyMethod;
|
13
|
-
import org.jruby.javasupport.JavaUtil;
|
14
45
|
import org.jruby.runtime.ThreadContext;
|
15
46
|
import org.jruby.runtime.builtin.IRubyObject;
|
16
47
|
import org.w3c.dom.Attr;
|
17
48
|
import org.w3c.dom.Element;
|
18
49
|
import org.w3c.dom.Node;
|
19
50
|
|
51
|
+
/**
|
52
|
+
* Class for Nokogiri::XML::Attr
|
53
|
+
*
|
54
|
+
*/
|
55
|
+
|
20
56
|
@JRubyClass(name="Nokogiri::XML::Attr", parent="Nokogiri::XML::Node")
|
21
57
|
public class XmlAttr extends XmlNode{
|
22
58
|
|
@@ -56,7 +92,7 @@ public class XmlAttr extends XmlNode{
|
|
56
92
|
XmlDocument xmlDoc = (XmlDocument)doc;
|
57
93
|
String str = rubyStringToString(content);
|
58
94
|
Node attr = xmlDoc.getDocument().createAttribute(str);
|
59
|
-
setNode(attr);
|
95
|
+
setNode(context, attr);
|
60
96
|
}
|
61
97
|
|
62
98
|
public boolean isHtmlBooleanAttr() {
|
@@ -101,13 +137,13 @@ public class XmlAttr extends XmlNode{
|
|
101
137
|
if (node == null) return context.getRuntime().getNil();
|
102
138
|
String attrValue = ((Attr)node).getValue();
|
103
139
|
if (attrValue == null) return context.getRuntime().getNil();
|
104
|
-
return
|
140
|
+
return RubyString.newString(context.getRuntime(), attrValue);
|
105
141
|
}
|
106
142
|
|
107
143
|
@JRubyMethod(name = {"value=", "content="})
|
108
144
|
public IRubyObject value_set(ThreadContext context, IRubyObject content){
|
109
145
|
Attr attr = (Attr) node;
|
110
|
-
attr.setValue((
|
146
|
+
attr.setValue(rubyStringToString(XmlNode.encode_special_chars(context, content)));
|
111
147
|
setContent(content);
|
112
148
|
return content;
|
113
149
|
}
|
@@ -1,3 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2010:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
32
|
+
|
1
33
|
package nokogiri;
|
2
34
|
|
3
35
|
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
@@ -1,5 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2010:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
32
|
+
|
1
33
|
package nokogiri;
|
2
34
|
|
35
|
+
import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
|
36
|
+
|
3
37
|
import nokogiri.internals.SaveContext;
|
4
38
|
|
5
39
|
import org.jruby.Ruby;
|
@@ -11,6 +45,11 @@ import org.w3c.dom.CDATASection;
|
|
11
45
|
import org.w3c.dom.Document;
|
12
46
|
import org.w3c.dom.Node;
|
13
47
|
|
48
|
+
/**
|
49
|
+
* Class for Nokogiri::XML::CDATA
|
50
|
+
*
|
51
|
+
*/
|
52
|
+
|
14
53
|
@JRubyClass(name="Nokogiri::XML::CDATA", parent="Nokogiri::XML::Text")
|
15
54
|
public class XmlCdata extends XmlText {
|
16
55
|
public XmlCdata(Ruby ruby, RubyClass rubyClass) {
|
@@ -31,8 +70,8 @@ public class XmlCdata extends XmlText {
|
|
31
70
|
XmlDocument xmlDoc =(XmlDocument) ((XmlNode) doc).document(context);
|
32
71
|
doc = xmlDoc;
|
33
72
|
Document document = xmlDoc.getDocument();
|
34
|
-
Node node = document.createCDATASection((content.isNil()) ? null : (
|
35
|
-
setNode(node);
|
73
|
+
Node node = document.createCDATASection((content.isNil()) ? null : rubyStringToString(content));
|
74
|
+
setNode(context, node);
|
36
75
|
}
|
37
76
|
|
38
77
|
@Override
|
@@ -1,3 +1,35 @@
|
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2010:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
32
|
+
|
1
33
|
package nokogiri;
|
2
34
|
|
3
35
|
import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
|
@@ -11,6 +43,11 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
11
43
|
import org.w3c.dom.Document;
|
12
44
|
import org.w3c.dom.Node;
|
13
45
|
|
46
|
+
/**
|
47
|
+
* Class for Nokogiri::XML::Comment
|
48
|
+
*
|
49
|
+
*/
|
50
|
+
|
14
51
|
@JRubyClass(name="Nokogiri::XML::Comment", parent="Nokogiri::XML::CharacterData")
|
15
52
|
public class XmlComment extends XmlNode {
|
16
53
|
public XmlComment(Ruby ruby, RubyClass rubyClass, Node node) {
|
@@ -32,7 +69,7 @@ public class XmlComment extends XmlNode {
|
|
32
69
|
XmlDocument xmlDoc = (XmlDocument) doc;
|
33
70
|
Document document = xmlDoc.getDocument();
|
34
71
|
Node node = document.createComment(rubyStringToString(text));
|
35
|
-
setNode(node);
|
72
|
+
setNode(context, node);
|
36
73
|
}
|
37
74
|
|
38
75
|
@Override
|