nokogiri 1.5.0.beta.2-java → 1.5.0.beta.3-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 +63 -0
- data/CHANGELOG.rdoc +44 -1
- data/Manifest.txt +3 -8
- 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/nokogiri.jar +0 -0
- 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 +483 -495
- 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/zlib1.dll +0 -0
- data/spec/helper.rb +0 -3
- data/spec/xml/reader_spec.rb +0 -307
@@ -1,7 +1,38 @@
|
|
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.internals;
|
2
34
|
|
3
35
|
import java.util.ArrayList;
|
4
|
-
import java.util.Enumeration;
|
5
36
|
import java.util.Hashtable;
|
6
37
|
import java.util.Iterator;
|
7
38
|
import java.util.List;
|
@@ -11,6 +42,13 @@ import java.util.Map.Entry;
|
|
11
42
|
import javax.xml.XMLConstants;
|
12
43
|
import javax.xml.namespace.NamespaceContext;
|
13
44
|
|
45
|
+
/**
|
46
|
+
* Holder of each node's namespace.
|
47
|
+
*
|
48
|
+
* @author Yoko Harada <yokolet@gmail.com>
|
49
|
+
*
|
50
|
+
*/
|
51
|
+
|
14
52
|
public class NokogiriNamespaceContext implements NamespaceContext {
|
15
53
|
public static final String NOKOGIRI_PREFIX = "nokogiri";
|
16
54
|
public static final String NOKOGIRI_URI = "http://www.nokogiri.org/default_ns/ruby/extensions_functions";
|
@@ -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.internals;
|
2
34
|
|
3
35
|
import org.apache.xerces.xni.parser.XMLParseException;
|
@@ -5,33 +37,37 @@ import org.xml.sax.SAXException;
|
|
5
37
|
import org.xml.sax.SAXParseException;
|
6
38
|
|
7
39
|
/**
|
8
|
-
*
|
40
|
+
* Error Handler for XML document when recover is true (default).
|
41
|
+
*
|
9
42
|
* @author sergio
|
10
43
|
*/
|
11
44
|
public class NokogiriNonStrictErrorHandler extends NokogiriErrorHandler{
|
45
|
+
public NokogiriNonStrictErrorHandler(boolean noerror, boolean nowarning) {
|
46
|
+
super(noerror, nowarning);
|
47
|
+
}
|
12
48
|
|
13
49
|
public void warning(SAXParseException ex) throws SAXException {
|
14
|
-
|
50
|
+
errors.add(ex);
|
15
51
|
}
|
16
52
|
|
17
53
|
public void error(SAXParseException ex) throws SAXException {
|
18
|
-
|
54
|
+
errors.add(ex);
|
19
55
|
}
|
20
56
|
|
21
57
|
public void fatalError(SAXParseException ex) throws SAXException {
|
22
|
-
|
58
|
+
errors.add(ex);
|
23
59
|
}
|
24
60
|
|
25
61
|
public void error(String domain, String key, XMLParseException e) {
|
26
|
-
|
62
|
+
errors.add(e);
|
27
63
|
}
|
28
64
|
|
29
65
|
public void fatalError(String domain, String key, XMLParseException e) {
|
30
|
-
|
66
|
+
errors.add(e);
|
31
67
|
}
|
32
68
|
|
33
69
|
public void warning(String domain, String key, XMLParseException e) {
|
34
|
-
|
70
|
+
errors.add(e);
|
35
71
|
}
|
36
72
|
|
37
73
|
}
|
@@ -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.internals;
|
2
34
|
|
3
35
|
import org.apache.xerces.xni.parser.XMLParseException;
|
@@ -12,19 +44,18 @@ import org.xml.sax.SAXParseException;
|
|
12
44
|
* availability of creating NodeSet from a given fragment. When the fragment nodes
|
13
45
|
* are to be created from HTML document, which means NekoHtml is used, always errors
|
14
46
|
* increases. As a result, even though the given fragment is correct HTML, NodeSet
|
15
|
-
* base on the given fragment won't be created. This is why warnings are eliminated.
|
47
|
+
* base on the given fragment won't be created. This is why all warnings are eliminated.
|
16
48
|
*
|
17
49
|
* @author Yoko Harada <yokolet@gmail.com>
|
18
50
|
*/
|
19
51
|
public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler {
|
20
|
-
private boolean noerror;
|
21
52
|
|
22
|
-
public NokogiriNonStrictErrorHandler4NekoHtml() {
|
23
|
-
|
53
|
+
public NokogiriNonStrictErrorHandler4NekoHtml(boolean nowarning) {
|
54
|
+
super(false, nowarning);
|
24
55
|
}
|
25
56
|
|
26
|
-
public NokogiriNonStrictErrorHandler4NekoHtml(boolean noerror) {
|
27
|
-
|
57
|
+
public NokogiriNonStrictErrorHandler4NekoHtml(boolean noerror, boolean nowarning) {
|
58
|
+
super(noerror, nowarning);
|
28
59
|
}
|
29
60
|
|
30
61
|
public void warning(SAXParseException ex) throws SAXException {
|
@@ -32,21 +63,57 @@ public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler
|
|
32
63
|
}
|
33
64
|
|
34
65
|
public void error(SAXParseException ex) throws SAXException {
|
35
|
-
|
66
|
+
errors.add(ex);
|
36
67
|
}
|
37
68
|
|
38
69
|
public void fatalError(SAXParseException ex) throws SAXException {
|
39
|
-
|
70
|
+
errors.add(ex);
|
40
71
|
}
|
41
72
|
|
73
|
+
/**
|
74
|
+
* Implementation of org.apache.xerces.xni.parser.XMLErrorHandler. This method
|
75
|
+
* is invoked during parsing fired by HtmlDomParserContext and is a NekoHtml requirement.
|
76
|
+
*
|
77
|
+
* @param domain The domain of the error. The domain can be any string but is
|
78
|
+
* suggested to be a valid URI. The domain can be used to conveniently
|
79
|
+
* specify a web site location of the relevant specification or
|
80
|
+
* document pertaining to this warning.
|
81
|
+
* @param key The error key. This key can be any string and is implementation
|
82
|
+
* dependent.
|
83
|
+
* @param e Exception.
|
84
|
+
*/
|
42
85
|
public void error(String domain, String key, XMLParseException e) {
|
43
|
-
|
86
|
+
errors.add(e);
|
44
87
|
}
|
45
88
|
|
89
|
+
/**
|
90
|
+
* Implementation of org.apache.xerces.xni.parser.XMLErrorHandler. This method
|
91
|
+
* is invoked during parsing fired by HtmlDomParserContext and is a NekoHtml requirement.
|
92
|
+
*
|
93
|
+
* @param domain The domain of the fatal error. The domain can be any string but is
|
94
|
+
* suggested to be a valid URI. The domain can be used to conveniently
|
95
|
+
* specify a web site location of the relevant specification or
|
96
|
+
* document pertaining to this warning.
|
97
|
+
* @param key The fatal error key. This key can be any string and is implementation
|
98
|
+
* dependent.
|
99
|
+
* @param e Exception.
|
100
|
+
*/
|
46
101
|
public void fatalError(String domain, String key, XMLParseException e) {
|
47
|
-
|
102
|
+
errors.add(e);
|
48
103
|
}
|
49
104
|
|
105
|
+
/**
|
106
|
+
* Implementation of org.apache.xerces.xni.parser.XMLErrorHandler. This method
|
107
|
+
* is invoked during parsing fired by HtmlDomParserContext and is a NekoHtml requirement.
|
108
|
+
*
|
109
|
+
* @param domain The domain of the warning. The domain can be any string but is
|
110
|
+
* suggested to be a valid URI. The domain can be used to conveniently
|
111
|
+
* specify a web site location of the relevant specification or
|
112
|
+
* document pertaining to this warning.
|
113
|
+
* @param key The warning key. This key can be any string and is implementation
|
114
|
+
* dependent.
|
115
|
+
* @param e Exception.
|
116
|
+
*/
|
50
117
|
public void warning(String domain, String key, XMLParseException e) {
|
51
118
|
//noop. NekoHtml adds too many warnings.
|
52
119
|
}
|
@@ -1,49 +1,78 @@
|
|
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.internals;
|
2
34
|
|
3
|
-
import java.util.ArrayList;
|
4
|
-
import java.util.List;
|
5
35
|
import org.apache.xerces.xni.parser.XMLParseException;
|
6
|
-
import org.jruby.runtime.ThreadContext;
|
7
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
8
36
|
import org.xml.sax.SAXException;
|
9
37
|
import org.xml.sax.SAXParseException;
|
10
38
|
|
11
39
|
/**
|
12
|
-
*
|
40
|
+
* Strict error handler. Even though strict is specified, Nokogiri allows to go further
|
41
|
+
* when NOERROR or/both NOWARNING is/are true.
|
42
|
+
*
|
13
43
|
* @author sergio
|
14
44
|
*/
|
15
|
-
public class NokogiriStrictErrorHandler extends NokogiriErrorHandler{
|
16
|
-
|
17
|
-
|
18
|
-
public List<IRubyObject> getErrorsReadyForRuby(ThreadContext context){
|
19
|
-
return new ArrayList<IRubyObject>();
|
45
|
+
public class NokogiriStrictErrorHandler extends NokogiriErrorHandler {
|
46
|
+
public NokogiriStrictErrorHandler(boolean noerror, boolean nowarning) {
|
47
|
+
super(noerror, nowarning);
|
20
48
|
}
|
21
49
|
|
22
50
|
public void warning(SAXParseException spex) throws SAXException {
|
23
|
-
throw spex;
|
51
|
+
if (!nowarning) throw spex;
|
52
|
+
else errors.add(spex);
|
24
53
|
}
|
25
54
|
|
26
55
|
public void error(SAXParseException spex) throws SAXException {
|
27
|
-
throw spex;
|
56
|
+
if (!noerror) throw spex;
|
57
|
+
else errors.add(spex);
|
28
58
|
}
|
29
59
|
|
30
60
|
public void fatalError(SAXParseException spex) throws SAXException {
|
31
61
|
throw spex;
|
32
62
|
}
|
33
63
|
|
34
|
-
public void error(String domain, String key, XMLParseException e)
|
35
|
-
|
36
|
-
|
64
|
+
public void error(String domain, String key, XMLParseException e) throws XMLParseException {
|
65
|
+
if (!noerror) throw e;
|
66
|
+
else errors.add(e);
|
37
67
|
}
|
38
68
|
|
39
|
-
public void fatalError(String domain, String key, XMLParseException e)
|
40
|
-
throws XMLParseException {
|
69
|
+
public void fatalError(String domain, String key, XMLParseException e) throws XMLParseException {
|
41
70
|
throw e;
|
42
71
|
}
|
43
72
|
|
44
|
-
public void warning(String domain, String key, XMLParseException e)
|
45
|
-
|
46
|
-
|
73
|
+
public void warning(String domain, String key, XMLParseException e) throws XMLParseException {
|
74
|
+
if (!nowarning) throw e;
|
75
|
+
if (!usesNekoHtml(domain)) errors.add(e);
|
47
76
|
}
|
48
77
|
|
49
78
|
}
|
@@ -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.internals;
|
2
34
|
|
3
35
|
import java.util.List;
|
@@ -17,11 +49,11 @@ import org.jruby.javasupport.JavaUtil;
|
|
17
49
|
import org.jruby.javasupport.util.RuntimeHelpers;
|
18
50
|
import org.jruby.runtime.ThreadContext;
|
19
51
|
import org.jruby.runtime.builtin.IRubyObject;
|
20
|
-
import org.w3c.dom.Node;
|
21
52
|
import org.w3c.dom.NodeList;
|
22
53
|
|
23
54
|
/**
|
24
|
-
*
|
55
|
+
* Xpath function handler.
|
56
|
+
*
|
25
57
|
* @author sergio
|
26
58
|
*/
|
27
59
|
public class NokogiriXPathFunction implements XPathFunction {
|
@@ -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.internals;
|
2
34
|
|
3
35
|
import javax.xml.namespace.QName;
|
@@ -6,7 +38,8 @@ import javax.xml.xpath.XPathFunctionResolver;
|
|
6
38
|
import org.jruby.runtime.builtin.IRubyObject;
|
7
39
|
|
8
40
|
/**
|
9
|
-
*
|
41
|
+
* Xpath function resolver class, which is used in XmlXpathContext.
|
42
|
+
*
|
10
43
|
* @author sergio
|
11
44
|
*/
|
12
45
|
public class NokogiriXPathFunctionResolver implements XPathFunctionResolver {
|