nokogiri 1.11.0.rc4-java → 1.11.5-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.

Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +12 -12
  4. data/LICENSE.md +1 -1
  5. data/README.md +168 -91
  6. data/dependencies.yml +12 -12
  7. data/ext/java/nokogiri/EncodingHandler.java +76 -89
  8. data/ext/java/nokogiri/HtmlDocument.java +135 -144
  9. data/ext/java/nokogiri/HtmlElementDescription.java +102 -117
  10. data/ext/java/nokogiri/HtmlEntityLookup.java +33 -60
  11. data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -222
  12. data/ext/java/nokogiri/HtmlSaxPushParser.java +162 -169
  13. data/ext/java/nokogiri/NokogiriService.java +595 -556
  14. data/ext/java/nokogiri/XmlAttr.java +118 -126
  15. data/ext/java/nokogiri/XmlAttributeDecl.java +95 -106
  16. data/ext/java/nokogiri/XmlCdata.java +35 -58
  17. data/ext/java/nokogiri/XmlComment.java +46 -67
  18. data/ext/java/nokogiri/XmlDocument.java +645 -572
  19. data/ext/java/nokogiri/XmlDocumentFragment.java +125 -137
  20. data/ext/java/nokogiri/XmlDtd.java +448 -414
  21. data/ext/java/nokogiri/XmlElement.java +23 -48
  22. data/ext/java/nokogiri/XmlElementContent.java +343 -316
  23. data/ext/java/nokogiri/XmlElementDecl.java +124 -125
  24. data/ext/java/nokogiri/XmlEntityDecl.java +119 -127
  25. data/ext/java/nokogiri/XmlEntityReference.java +49 -72
  26. data/ext/java/nokogiri/XmlNamespace.java +175 -175
  27. data/ext/java/nokogiri/XmlNode.java +1843 -1620
  28. data/ext/java/nokogiri/XmlNodeSet.java +361 -331
  29. data/ext/java/nokogiri/XmlProcessingInstruction.java +47 -69
  30. data/ext/java/nokogiri/XmlReader.java +513 -450
  31. data/ext/java/nokogiri/XmlRelaxng.java +85 -104
  32. data/ext/java/nokogiri/XmlSaxParserContext.java +328 -315
  33. data/ext/java/nokogiri/XmlSaxPushParser.java +227 -220
  34. data/ext/java/nokogiri/XmlSchema.java +328 -295
  35. data/ext/java/nokogiri/XmlSyntaxError.java +113 -115
  36. data/ext/java/nokogiri/XmlText.java +55 -76
  37. data/ext/java/nokogiri/XmlXpathContext.java +240 -238
  38. data/ext/java/nokogiri/XsltStylesheet.java +280 -269
  39. data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
  40. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +201 -202
  41. data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
  42. data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
  43. data/ext/java/nokogiri/internals/NokogiriDomParser.java +63 -80
  44. data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
  45. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +27 -52
  46. data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -286
  47. data/ext/java/nokogiri/internals/NokogiriHelpers.java +736 -652
  48. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +184 -173
  49. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +81 -98
  50. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +64 -79
  51. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +84 -99
  52. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +48 -65
  53. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +116 -131
  54. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -56
  55. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +23 -46
  56. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +55 -72
  57. data/ext/java/nokogiri/internals/ParserContext.java +206 -211
  58. data/ext/java/nokogiri/internals/ReaderNode.java +478 -403
  59. data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -739
  60. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +31 -54
  61. data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
  62. data/ext/java/nokogiri/internals/XmlDeclHandler.java +3 -34
  63. data/ext/java/nokogiri/internals/XmlDomParserContext.java +206 -207
  64. data/ext/java/nokogiri/internals/XmlSaxParser.java +22 -47
  65. data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
  66. data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
  67. data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
  68. data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
  69. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
  70. data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
  71. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
  72. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
  73. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
  74. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
  75. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
  76. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
  77. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
  78. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
  79. data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
  80. data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
  81. data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
  82. data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
  83. data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
  84. data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
  85. data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
  86. data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
  87. data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
  88. data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
  89. data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
  90. data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
  91. data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
  92. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
  93. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -574
  94. data/ext/nokogiri/depend +34 -474
  95. data/ext/nokogiri/extconf.rb +270 -183
  96. data/ext/nokogiri/html_document.c +10 -15
  97. data/ext/nokogiri/html_element_description.c +84 -71
  98. data/ext/nokogiri/html_entity_lookup.c +21 -16
  99. data/ext/nokogiri/html_sax_parser_context.c +67 -64
  100. data/ext/nokogiri/html_sax_push_parser.c +42 -34
  101. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  102. data/ext/nokogiri/nokogiri.c +190 -60
  103. data/ext/nokogiri/test_global_handlers.c +40 -0
  104. data/ext/nokogiri/xml_attr.c +15 -15
  105. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  106. data/ext/nokogiri/xml_cdata.c +13 -18
  107. data/ext/nokogiri/xml_comment.c +19 -26
  108. data/ext/nokogiri/xml_document.c +246 -188
  109. data/ext/nokogiri/xml_document_fragment.c +13 -15
  110. data/ext/nokogiri/xml_dtd.c +54 -48
  111. data/ext/nokogiri/xml_element_content.c +30 -27
  112. data/ext/nokogiri/xml_element_decl.c +22 -22
  113. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  114. data/ext/nokogiri/xml_entity_decl.c +32 -30
  115. data/ext/nokogiri/xml_entity_reference.c +16 -18
  116. data/ext/nokogiri/xml_namespace.c +56 -49
  117. data/ext/nokogiri/xml_node.c +371 -320
  118. data/ext/nokogiri/xml_node_set.c +168 -156
  119. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  120. data/ext/nokogiri/xml_reader.c +191 -157
  121. data/ext/nokogiri/xml_relax_ng.c +29 -23
  122. data/ext/nokogiri/xml_sax_parser.c +117 -112
  123. data/ext/nokogiri/xml_sax_parser_context.c +101 -84
  124. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  125. data/ext/nokogiri/xml_schema.c +48 -42
  126. data/ext/nokogiri/xml_syntax_error.c +42 -21
  127. data/ext/nokogiri/xml_text.c +13 -17
  128. data/ext/nokogiri/xml_xpath_context.c +134 -127
  129. data/ext/nokogiri/xslt_stylesheet.c +157 -157
  130. data/lib/nokogiri.rb +2 -6
  131. data/lib/nokogiri/css/parser.rb +1 -1
  132. data/lib/nokogiri/extension.rb +26 -0
  133. data/lib/nokogiri/html/document_fragment.rb +15 -15
  134. data/lib/nokogiri/nokogiri.jar +0 -0
  135. data/lib/nokogiri/version/constant.rb +1 -1
  136. data/lib/nokogiri/version/info.rb +32 -8
  137. data/lib/nokogiri/xml/document.rb +74 -28
  138. data/lib/nokogiri/xml/node.rb +39 -42
  139. data/lib/nokogiri/xml/reader.rb +2 -9
  140. data/lib/nokogiri/xml/xpath.rb +1 -3
  141. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  142. metadata +62 -127
  143. data/ext/nokogiri/xml_io.c +0 -63
  144. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
@@ -1,35 +1,3 @@
1
- /**
2
- * (The MIT License)
3
- *
4
- * Copyright (c) 2008 - 2012:
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
-
33
1
  package nokogiri.internals;
34
2
 
35
3
  import javax.xml.transform.ErrorListener;
@@ -37,51 +5,66 @@ import javax.xml.transform.TransformerException;
37
5
 
38
6
  /**
39
7
  * Error Listener for XSLT transformer
40
- *
8
+ *
41
9
  * @author Yoko Harada <yokolet@gmail.com>
42
10
  */
43
- public class NokogiriXsltErrorListener implements ErrorListener {
44
- public enum ErrorType {
45
- SUCCESS,
46
- WARNING,
47
- ERROR,
48
- FATAL
49
- }
11
+ public class NokogiriXsltErrorListener implements ErrorListener
12
+ {
13
+ public enum ErrorType {
14
+ SUCCESS,
15
+ WARNING,
16
+ ERROR,
17
+ FATAL
18
+ }
19
+
20
+ private ErrorType type = ErrorType.SUCCESS;
21
+ private String errorMessage = null;
22
+ private Exception exception = null;
23
+
24
+ public void
25
+ warning(TransformerException ex)
26
+ {
27
+ type = ErrorType.WARNING;
28
+ setError(ex);
29
+ }
30
+
31
+ public void
32
+ error(TransformerException ex)
33
+ {
34
+ type = ErrorType.ERROR;
35
+ setError(ex);
36
+ }
37
+
38
+ public void
39
+ fatalError(TransformerException ex)
40
+ {
41
+ type = ErrorType.FATAL;
42
+ setError(ex);
43
+ }
50
44
 
51
- private ErrorType type = ErrorType.SUCCESS;
52
- private String errorMessage = null;
53
- private Exception exception = null;
45
+ private void
46
+ setError(TransformerException ex)
47
+ {
48
+ errorMessage = ex.getMessage();
49
+ exception = ex;
50
+ }
54
51
 
55
- public void warning(TransformerException ex) {
56
- type = ErrorType.WARNING;
57
- setError(ex);
58
- }
52
+ public String
53
+ getErrorMessage()
54
+ {
55
+ return errorMessage;
56
+ }
59
57
 
60
- public void error(TransformerException ex) {
61
- type = ErrorType.ERROR;
62
- setError(ex);
63
- }
58
+ public ErrorType
59
+ getErrorType()
60
+ {
61
+ return type;
62
+ }
64
63
 
65
- public void fatalError(TransformerException ex) {
66
- type = ErrorType.FATAL;
67
- setError(ex);
68
- }
69
-
70
- private void setError(TransformerException ex) {
71
- errorMessage = ex.getMessage();
72
- exception = ex;
73
- }
74
-
75
- public String getErrorMessage() {
76
- return errorMessage;
77
- }
78
-
79
- public ErrorType getErrorType() {
80
- return type;
81
- }
82
-
83
- public Exception getException() {
84
- return exception;
85
- }
64
+ public Exception
65
+ getException()
66
+ {
67
+ return exception;
68
+ }
86
69
 
87
70
  }
@@ -1,35 +1,3 @@
1
- /**
2
- * (The MIT License)
3
- *
4
- * Copyright (c) 2008 - 2012:
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
-
33
1
  package nokogiri.internals;
34
2
 
35
3
  import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
@@ -58,202 +26,229 @@ import org.xml.sax.InputSource;
58
26
  * @author Patrick Mahoney <pat@polycrystal.org>
59
27
  * @author Yoko Harada <yokolet@gmail.com>
60
28
  */
61
- public abstract class ParserContext extends RubyObject {
62
- protected InputSource source = null;
63
- protected IRubyObject detected_encoding = null;
64
- protected int stringDataSize = -1;
65
- protected String java_encoding;
66
-
67
- public ParserContext(Ruby runtime) {
68
- // default to class 'Object' because this class isn't exposed to Ruby
69
- super(runtime, runtime.getObject());
29
+ public abstract class ParserContext extends RubyObject
30
+ {
31
+ protected InputSource source = null;
32
+ protected IRubyObject detected_encoding = null;
33
+ protected int stringDataSize = -1;
34
+ protected String java_encoding;
35
+
36
+ public
37
+ ParserContext(Ruby runtime)
38
+ {
39
+ // default to class 'Object' because this class isn't exposed to Ruby
40
+ super(runtime, runtime.getObject());
41
+ }
42
+
43
+ public
44
+ ParserContext(Ruby runtime, RubyClass klass)
45
+ {
46
+ super(runtime, klass);
47
+ }
48
+
49
+ protected InputSource
50
+ getInputSource()
51
+ {
52
+ return source;
53
+ }
54
+
55
+ public void
56
+ setIOInputSource(ThreadContext context, IRubyObject data, IRubyObject url)
57
+ {
58
+ source = new InputSource();
59
+ ParserContext.setUrl(context, source, url);
60
+
61
+ source.setByteStream(new IOInputStream(data));
62
+ if (java_encoding != null) {
63
+ source.setEncoding(java_encoding);
70
64
  }
65
+ }
71
66
 
72
- public ParserContext(Ruby runtime, RubyClass klass) {
73
- super(runtime, klass);
74
- }
67
+ public void
68
+ setStringInputSource(ThreadContext context, IRubyObject data, IRubyObject url)
69
+ {
70
+ source = new InputSource();
71
+ ParserContext.setUrl(context, source, url);
75
72
 
76
- protected InputSource getInputSource() {
77
- return source;
78
- }
79
-
80
- public void setIOInputSource(ThreadContext context, IRubyObject data, IRubyObject url) {
81
- source = new InputSource();
82
- ParserContext.setUrl(context, source, url);
73
+ Ruby ruby = context.getRuntime();
83
74
 
84
- source.setByteStream(new IOInputStream(data));
85
- if (java_encoding != null) {
86
- source.setEncoding(java_encoding);
87
- }
75
+ if (!(data instanceof RubyString)) {
76
+ throw ruby.newArgumentError("must be kind_of String");
88
77
  }
89
78
 
90
- public void setStringInputSource(ThreadContext context, IRubyObject data, IRubyObject url) {
91
- source = new InputSource();
92
- ParserContext.setUrl(context, source, url);
93
-
94
- Ruby ruby = context.getRuntime();
95
-
96
- if (!(data instanceof RubyString)) {
97
- throw ruby.newArgumentError("must be kind_of String");
98
- }
99
-
100
- RubyString stringData = (RubyString) data;
101
-
102
- if (stringData.encoding(context) != null) {
103
- RubyString stringEncoding = stringData.encoding(context).asString();
104
- String encName = NokogiriHelpers.getValidEncodingOrNull(stringEncoding);
105
- if (encName != null) {
106
- java_encoding = encName;
107
- }
108
- }
109
-
110
- ByteList bytes = stringData.getByteList();
79
+ RubyString stringData = (RubyString) data;
111
80
 
112
- stringDataSize = bytes.length() - bytes.begin();
113
- ByteArrayInputStream stream = new ByteArrayInputStream(bytes.unsafeBytes(), bytes.begin(), bytes.length());
114
- source.setByteStream(stream);
115
- source.setEncoding(java_encoding);
81
+ if (stringData.encoding(context) != null) {
82
+ RubyString stringEncoding = stringData.encoding(context).asString();
83
+ String encName = NokogiriHelpers.getValidEncodingOrNull(stringEncoding);
84
+ if (encName != null) {
85
+ java_encoding = encName;
86
+ }
116
87
  }
117
88
 
118
- public static void setUrl(ThreadContext context, InputSource source, IRubyObject url) {
119
- String path = rubyStringToString(url);
120
- // Dir.chdir might be called at some point before this.
121
- if (path != null) {
89
+ ByteList bytes = stringData.getByteList();
90
+
91
+ stringDataSize = bytes.length() - bytes.begin();
92
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes.unsafeBytes(), bytes.begin(), bytes.length());
93
+ source.setByteStream(stream);
94
+ source.setEncoding(java_encoding);
95
+ }
96
+
97
+ public static void
98
+ setUrl(ThreadContext context, InputSource source, IRubyObject url)
99
+ {
100
+ String path = rubyStringToString(url);
101
+ // Dir.chdir might be called at some point before this.
102
+ if (path != null) {
103
+ try {
104
+ URI uri = URI.create(path);
105
+ source.setSystemId(uri.toURL().toString());
106
+ } catch (Exception ex) {
107
+ // fallback to the old behavior
108
+ File file = new File(path);
109
+ if (file.isAbsolute()) {
110
+ source.setSystemId(path);
111
+ } else {
112
+ String pwd = context.getRuntime().getCurrentDirectory();
113
+ String absolutePath;
122
114
  try {
123
- URI uri = URI.create(path);
124
- source.setSystemId(uri.toURL().toString());
125
- } catch (Exception ex) {
126
- // fallback to the old behavior
127
- File file = new File(path);
128
- if (file.isAbsolute()) {
129
- source.setSystemId(path);
130
- } else {
131
- String pwd = context.getRuntime().getCurrentDirectory();
132
- String absolutePath;
133
- try {
134
- absolutePath = new File(pwd, path).getCanonicalPath();
135
- } catch (IOException e) {
136
- absolutePath = new File(pwd, path).getAbsolutePath();
137
- }
138
- source.setSystemId(absolutePath);
139
- }
115
+ absolutePath = new File(pwd, path).getCanonicalPath();
116
+ } catch (IOException e) {
117
+ absolutePath = new File(pwd, path).getAbsolutePath();
140
118
  }
119
+ source.setSystemId(absolutePath);
141
120
  }
121
+ }
142
122
  }
143
-
144
- protected void setEncoding(String encoding) {
145
- source.setEncoding(encoding);
123
+ }
124
+
125
+ protected void
126
+ setEncoding(String encoding)
127
+ {
128
+ source.setEncoding(encoding);
129
+ }
130
+
131
+ /**
132
+ * Set the InputSource to read from <code>file</code>, a String filename.
133
+ */
134
+ public void
135
+ setInputSourceFile(ThreadContext context, IRubyObject file)
136
+ {
137
+ source = new InputSource();
138
+ ParserContext.setUrl(context, source, file);
139
+ }
140
+
141
+ /**
142
+ * Set the InputSource from <code>stream</code>.
143
+ */
144
+ public void
145
+ setInputSource(InputStream stream)
146
+ {
147
+ source = new InputSource(stream);
148
+ }
149
+
150
+ /**
151
+ * Wrap Nokogiri parser options in a utility class. This is
152
+ * read-only.
153
+ */
154
+ public static class Options
155
+ {
156
+ protected static final long STRICT = 0;
157
+ protected static final long RECOVER = 1;
158
+ protected static final long NOENT = 2;
159
+ protected static final long DTDLOAD = 4;
160
+ protected static final long DTDATTR = 8;
161
+ protected static final long DTDVALID = 16;
162
+ protected static final long NOERROR = 32;
163
+ protected static final long NOWARNING = 64;
164
+ protected static final long PEDANTIC = 128;
165
+ protected static final long NOBLANKS = 256;
166
+ protected static final long SAX1 = 512;
167
+ protected static final long XINCLUDE = 1024;
168
+ protected static final long NONET = 2048;
169
+ protected static final long NODICT = 4096;
170
+ protected static final long NSCLEAN = 8192;
171
+ protected static final long NOCDATA = 16384;
172
+ protected static final long NOXINCNODE = 32768;
173
+
174
+ public final boolean strict;
175
+ public final boolean recover;
176
+ public final boolean noEnt;
177
+ public final boolean dtdLoad;
178
+ public final boolean dtdAttr;
179
+ public final boolean dtdValid;
180
+ public final boolean noError;
181
+ public final boolean noWarning;
182
+ public final boolean pedantic;
183
+ public final boolean noBlanks;
184
+ public final boolean sax1;
185
+ public final boolean xInclude;
186
+ public final boolean noNet;
187
+ public final boolean noDict;
188
+ public final boolean nsClean;
189
+ public final boolean noCdata;
190
+ public final boolean noXIncNode;
191
+
192
+ protected static boolean
193
+ test(long options, long mask)
194
+ {
195
+ return ((options & mask) == mask);
146
196
  }
147
197
 
148
- /**
149
- * Set the InputSource to read from <code>file</code>, a String filename.
150
- */
151
- public void setInputSourceFile(ThreadContext context, IRubyObject file) {
152
- source = new InputSource();
153
- ParserContext.setUrl(context, source, file);
198
+ public
199
+ Options(long options)
200
+ {
201
+ strict = ((options & RECOVER) == STRICT);
202
+ recover = test(options, RECOVER);
203
+ noEnt = test(options, NOENT);
204
+ dtdLoad = test(options, DTDLOAD);
205
+ dtdAttr = test(options, DTDATTR);
206
+ dtdValid = test(options, DTDVALID);
207
+ noError = test(options, NOERROR);
208
+ noWarning = test(options, NOWARNING);
209
+ pedantic = test(options, PEDANTIC);
210
+ noBlanks = test(options, NOBLANKS);
211
+ sax1 = test(options, SAX1);
212
+ xInclude = test(options, XINCLUDE);
213
+ noNet = test(options, NONET);
214
+ noDict = test(options, NODICT);
215
+ nsClean = test(options, NSCLEAN);
216
+ noCdata = test(options, NOCDATA);
217
+ noXIncNode = test(options, NOXINCNODE);
154
218
  }
155
-
156
- /**
157
- * Set the InputSource from <code>stream</code>.
158
- */
159
- public void setInputSource(InputStream stream) {
160
- source = new InputSource(stream);
161
- }
162
-
163
- /**
164
- * Wrap Nokogiri parser options in a utility class. This is
165
- * read-only.
166
- */
167
- public static class Options {
168
- protected static final long STRICT = 0;
169
- protected static final long RECOVER = 1;
170
- protected static final long NOENT = 2;
171
- protected static final long DTDLOAD = 4;
172
- protected static final long DTDATTR = 8;
173
- protected static final long DTDVALID = 16;
174
- protected static final long NOERROR = 32;
175
- protected static final long NOWARNING = 64;
176
- protected static final long PEDANTIC = 128;
177
- protected static final long NOBLANKS = 256;
178
- protected static final long SAX1 = 512;
179
- protected static final long XINCLUDE = 1024;
180
- protected static final long NONET = 2048;
181
- protected static final long NODICT = 4096;
182
- protected static final long NSCLEAN = 8192;
183
- protected static final long NOCDATA = 16384;
184
- protected static final long NOXINCNODE = 32768;
185
-
186
- public final boolean strict;
187
- public final boolean recover;
188
- public final boolean noEnt;
189
- public final boolean dtdLoad;
190
- public final boolean dtdAttr;
191
- public final boolean dtdValid;
192
- public final boolean noError;
193
- public final boolean noWarning;
194
- public final boolean pedantic;
195
- public final boolean noBlanks;
196
- public final boolean sax1;
197
- public final boolean xInclude;
198
- public final boolean noNet;
199
- public final boolean noDict;
200
- public final boolean nsClean;
201
- public final boolean noCdata;
202
- public final boolean noXIncNode;
203
-
204
- protected static boolean test(long options, long mask) {
205
- return ((options & mask) == mask);
206
- }
207
-
208
- public Options(long options) {
209
- strict = ((options & RECOVER) == STRICT);
210
- recover = test(options, RECOVER);
211
- noEnt = test(options, NOENT);
212
- dtdLoad = test(options, DTDLOAD);
213
- dtdAttr = test(options, DTDATTR);
214
- dtdValid = test(options, DTDVALID);
215
- noError = test(options, NOERROR);
216
- noWarning = test(options, NOWARNING);
217
- pedantic = test(options, PEDANTIC);
218
- noBlanks = test(options, NOBLANKS);
219
- sax1 = test(options, SAX1);
220
- xInclude = test(options, XINCLUDE);
221
- noNet = test(options, NONET);
222
- noDict = test(options, NODICT);
223
- nsClean = test(options, NSCLEAN);
224
- noCdata = test(options, NOCDATA);
225
- noXIncNode = test(options, NOXINCNODE);
226
- }
219
+ }
220
+
221
+ /*
222
+ public static class NokogiriXInlcudeEntityResolver implements org.xml.sax.EntityResolver {
223
+ InputSource source;
224
+ public NokogiriXInlcudeEntityResolver(InputSource source) {
225
+ this.source = source;
226
+ }
227
+
228
+ @Override
229
+ public InputSource resolveEntity(String publicId, String systemId)
230
+ throws SAXException, IOException {
231
+ if (systemId != null) source.setSystemId(systemId);
232
+ if (publicId != null) source.setPublicId(publicId);
233
+ return source;
234
+ }
235
+ } */
236
+
237
+ public static abstract class ParserTask<T extends ParserContext> implements Callable<T>
238
+ {
239
+
240
+ protected final ThreadContext context; // TODO does not seem like a good idea!?
241
+ protected final IRubyObject handler;
242
+ protected final T parser;
243
+
244
+ protected
245
+ ParserTask(ThreadContext context, IRubyObject handler, T parser)
246
+ {
247
+ this.context = context;
248
+ this.handler = handler;
249
+ this.parser = parser;
227
250
  }
228
251
 
229
- /*
230
- public static class NokogiriXInlcudeEntityResolver implements org.xml.sax.EntityResolver {
231
- InputSource source;
232
- public NokogiriXInlcudeEntityResolver(InputSource source) {
233
- this.source = source;
234
- }
235
-
236
- @Override
237
- public InputSource resolveEntity(String publicId, String systemId)
238
- throws SAXException, IOException {
239
- if (systemId != null) source.setSystemId(systemId);
240
- if (publicId != null) source.setPublicId(publicId);
241
- return source;
242
- }
243
- } */
244
-
245
- public static abstract class ParserTask<T extends ParserContext> implements Callable<T> {
246
-
247
- protected final ThreadContext context; // TODO does not seem like a good idea!?
248
- protected final IRubyObject handler;
249
- protected final T parser;
250
-
251
- protected ParserTask(ThreadContext context, IRubyObject handler, T parser) {
252
- this.context = context;
253
- this.handler = handler;
254
- this.parser = parser;
255
- }
256
-
257
- }
252
+ }
258
253
 
259
254
  }