nokogiri 1.5.0.beta.4-java → 1.5.0-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 (87) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGELOG.ja.rdoc +34 -0
  3. data/CHANGELOG.rdoc +40 -1
  4. data/Manifest.txt +11 -2
  5. data/README.rdoc +1 -1
  6. data/Rakefile +96 -105
  7. data/bin/nokogiri +1 -2
  8. data/ext/java/nokogiri/HtmlDocument.java +1 -31
  9. data/ext/java/nokogiri/HtmlSaxParserContext.java +1 -1
  10. data/ext/java/nokogiri/NokogiriService.java +77 -22
  11. data/ext/java/nokogiri/XmlAttr.java +5 -16
  12. data/ext/java/nokogiri/XmlCdata.java +4 -11
  13. data/ext/java/nokogiri/XmlComment.java +5 -5
  14. data/ext/java/nokogiri/XmlDocument.java +49 -59
  15. data/ext/java/nokogiri/XmlDocumentFragment.java +14 -8
  16. data/ext/java/nokogiri/XmlDtd.java +45 -43
  17. data/ext/java/nokogiri/XmlElement.java +19 -46
  18. data/ext/java/nokogiri/XmlElementDecl.java +9 -5
  19. data/ext/java/nokogiri/XmlEntityReference.java +24 -2
  20. data/ext/java/nokogiri/XmlNamespace.java +89 -34
  21. data/ext/java/nokogiri/XmlNode.java +31 -52
  22. data/ext/java/nokogiri/XmlNodeSet.java +42 -86
  23. data/ext/java/nokogiri/XmlProcessingInstruction.java +15 -19
  24. data/ext/java/nokogiri/XmlReader.java +40 -43
  25. data/ext/java/nokogiri/XmlSaxParserContext.java +2 -2
  26. data/ext/java/nokogiri/XmlSchema.java +14 -9
  27. data/ext/java/nokogiri/XmlText.java +18 -35
  28. data/ext/java/nokogiri/XmlXpathContext.java +43 -23
  29. data/ext/java/nokogiri/XsltStylesheet.java +17 -3
  30. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +2 -4
  31. data/ext/java/nokogiri/internals/NokogiriHelpers.java +77 -20
  32. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +13 -17
  33. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +13 -1
  34. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +23 -8
  35. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +20 -3
  36. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +67 -0
  37. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +86 -0
  38. data/ext/java/nokogiri/internals/ParserContext.java +25 -27
  39. data/ext/java/nokogiri/internals/ReaderNode.java +58 -1
  40. data/ext/java/nokogiri/internals/SaveContextVisitor.java +567 -0
  41. data/ext/java/nokogiri/internals/XmlDomParser.java +1 -2
  42. data/ext/java/nokogiri/internals/XmlDomParserContext.java +6 -0
  43. data/ext/nokogiri/nokogiri.c +24 -1
  44. data/ext/nokogiri/xml_io.c +32 -7
  45. data/ext/nokogiri/xml_node.c +14 -13
  46. data/ext/nokogiri/xml_sax_parser.c +9 -4
  47. data/ext/nokogiri/xslt_stylesheet.c +7 -1
  48. data/lib/nokogiri.rb +3 -22
  49. data/lib/nokogiri/css.rb +4 -0
  50. data/lib/nokogiri/html/document.rb +10 -14
  51. data/lib/nokogiri/nokogiri.jar +0 -0
  52. data/lib/nokogiri/version.rb +76 -23
  53. data/lib/nokogiri/xml/builder.rb +7 -0
  54. data/lib/nokogiri/xml/document.rb +17 -1
  55. data/lib/nokogiri/xml/document_fragment.rb +14 -0
  56. data/lib/nokogiri/xml/node.rb +36 -28
  57. data/lib/nokogiri/xml/node/save_options.rb +17 -1
  58. data/lib/nokogiri/xml/node_set.rb +7 -0
  59. data/lib/nokogiri/xml/parse_options.rb +8 -0
  60. data/lib/nokogiri/xml/reader.rb +6 -6
  61. data/lib/nokogiri/xml/schema.rb +7 -1
  62. data/lib/xercesImpl.jar +0 -0
  63. data/nokogiri_help_responses.md +40 -0
  64. data/tasks/cross_compile.rb +134 -159
  65. data/tasks/nokogiri.org.rb +18 -0
  66. data/tasks/test.rb +1 -1
  67. data/test/files/encoding.html +82 -0
  68. data/test/files/encoding.xhtml +84 -0
  69. data/test/files/metacharset.html +10 -0
  70. data/test/files/noencoding.html +47 -0
  71. data/test/helper.rb +2 -0
  72. data/test/html/test_document.rb +15 -0
  73. data/test/html/test_document_encoding.rb +13 -0
  74. data/test/test_memory_leak.rb +20 -0
  75. data/test/test_reader.rb +22 -0
  76. data/test/test_xslt_transforms.rb +6 -2
  77. data/test/xml/node/test_save_options.rb +10 -2
  78. data/test/xml/test_builder.rb +17 -0
  79. data/test/xml/test_document.rb +22 -0
  80. data/test/xml/test_node.rb +19 -1
  81. data/test/xml/test_node_reparenting.rb +16 -3
  82. data/test/xml/test_node_set.rb +34 -0
  83. data/test/xml/test_schema.rb +5 -0
  84. data/test/xslt/test_exception_handling.rb +37 -0
  85. metadata +141 -107
  86. data/deps.rip +0 -5
  87. data/ext/java/nokogiri/internals/SaveContext.java +0 -288
data/deps.rip DELETED
@@ -1,5 +0,0 @@
1
- git://github.com/luislavena/rake-compiler.git v0.6.0
2
- git://github.com/tenderlove/rexical.git
3
- git://github.com/jimweirich/rake.git
4
- git://github.com/jmhodges/fakehoe.git
5
- git://github.com/tenderlove/racc.git
@@ -1,288 +0,0 @@
1
- /**
2
- * (The MIT License)
3
- *
4
- * Copyright (c) 2008 - 2011:
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
- package nokogiri.internals;
34
-
35
- import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
36
-
37
- import java.nio.charset.Charset;
38
-
39
- import org.jruby.Ruby;
40
- import org.jruby.RubyClass;
41
- import org.jruby.RubyEncoding;
42
- import org.jruby.RubyString;
43
- import org.jruby.javasupport.util.RuntimeHelpers;
44
- import org.jruby.runtime.ThreadContext;
45
- import org.jruby.runtime.builtin.IRubyObject;
46
- import org.jruby.util.ByteList;
47
-
48
- /**
49
- * A class for serializing a document.
50
- *
51
- * @author sergio
52
- * @author Patrick Mahoney <pat@polycrystal.org>
53
- * @author Yoko Harada <yokolet@gmail.com>
54
- */
55
- public class SaveContext {
56
-
57
- private final ThreadContext context;
58
- private final RubyClass elementDescription;
59
- private StringBuffer buffer;
60
- private int options;
61
- private int level=0;
62
- private String encoding, indentString;
63
- private boolean format, noDecl, noEmpty, noXhtml, xhtml, asXml, asHtml;
64
-
65
- /*
66
- * U can't touch this.
67
- * http://www.youtube.com/watch?v=WJ2ZFVx6A4Q
68
- *
69
- * Taken from libxml save options.
70
- */
71
-
72
- public static final int FORMAT = 1;
73
- public static final int NO_DECL = 2;
74
- public static final int NO_EMPTY = 4;
75
- public static final int NO_XHTML = 8;
76
- public static final int XHTML = 16;
77
- public static final int AS_XML = 32;
78
- public static final int AS_HTML = 64;
79
-
80
- public SaveContext(ThreadContext context, int options, String indentString, String encoding) {
81
- this.context = context;
82
- this.elementDescription = (RubyClass)getNokogiriClass(context.getRuntime(), "Nokogiri::HTML::ElementDescription");
83
- this.options = options;
84
- this.encoding = encoding;
85
- this.indentString = indentString;
86
- this.buffer = new StringBuffer();
87
- format = (options & FORMAT) == FORMAT;
88
- noDecl = (options & NO_DECL) == NO_DECL;
89
- noEmpty = (options & NO_EMPTY) == NO_EMPTY;
90
- noXhtml = (options & NO_XHTML) == NO_XHTML;
91
- xhtml = (options & XHTML) == XHTML;
92
- asXml = (options & AS_XML) == AS_XML;
93
- asHtml = (options & AS_HTML) == AS_HTML;
94
- }
95
-
96
- public void append(String s) {
97
- this.buffer.append(s);
98
- }
99
-
100
- public void append(char c) {
101
- buffer.append(c);
102
- }
103
-
104
- public void append(StringBuffer sb) {
105
- this.buffer.append(sb);
106
- }
107
-
108
- public void appendQuoted(String s) {
109
- this.append("\"");
110
- this.append(s);
111
- this.append("\"");
112
- }
113
-
114
- public void appendQuoted(StringBuffer sb) {
115
- this.append("\"");
116
- this.append(sb);
117
- this.append("\"");
118
- }
119
-
120
- public void emptyTag(String name) {
121
- emptyTagStart(name);
122
- emptyTagEnd(name);
123
- }
124
-
125
- public void emptyTagStart(String name) {
126
- openTagInlineStart(name);
127
- }
128
-
129
- public void emptyTagEnd(String name) {
130
- if (asHtml) {
131
- if (isEmpty(name) && noEmpty()) {
132
- append(">");
133
- } else {
134
- openTagInlineEnd();
135
- closeTagInline(name);
136
- }
137
- } else if (xhtml) {
138
- append(" />");
139
- } else {
140
- append("/>");
141
- }
142
- }
143
-
144
- public void openTag(String name) {
145
- openTagStart(name);
146
- openTagEnd();
147
- }
148
-
149
- public void openTagStart(String name) {
150
- maybeBreak();
151
- indent();
152
- append("<");
153
- append(name);
154
- }
155
-
156
- public void openTagEnd() {
157
- append(">");
158
- maybeBreak();
159
- increaseLevel();
160
- }
161
-
162
- public void closeTag(String name) {
163
- decreaseLevel();
164
- maybeBreak();
165
- indent();
166
- append("</");
167
- append(name);
168
- append(">");
169
- maybeBreak();
170
- }
171
-
172
- public void openTagInline(String name) {
173
- openTagInlineStart(name);
174
- openTagInlineEnd();
175
- }
176
-
177
- public void openTagInlineStart(String name) {
178
- maybeIndent();
179
- append("<");
180
- append(name);
181
- }
182
-
183
- public void openTagInlineEnd() {
184
- append(">");
185
- }
186
-
187
- public void closeTagInline(String name) {
188
- append("</");
189
- append(name);
190
- append(">");
191
- }
192
-
193
- public void maybeBreak() {
194
- if (format && !endsInNewline()) append('\n');
195
- }
196
-
197
- public void maybeSpace() {
198
- if (!endsInWhitespace()) append(' ');
199
- }
200
-
201
- /**
202
- * Indent if this is the start of a fresh line.
203
- */
204
- public void maybeIndent() {
205
- if (format && endsInNewline()) indent();
206
- }
207
-
208
- public void indent() {
209
- if (format) append(getCurrentIndentString());
210
- }
211
-
212
- public boolean endsInWhitespace() {
213
- return (Character.isWhitespace(lastChar()));
214
- }
215
-
216
- public boolean endsInNewline() {
217
- return (lastChar() == '\n');
218
- }
219
-
220
- public char lastChar() {
221
- if (buffer.length() == 0) return '\n'; // logically, the char
222
- // *before* a text file
223
- // is a newline
224
- return buffer.charAt(buffer.length() - 1);
225
- }
226
-
227
- public boolean asHtml() { return this.asHtml; }
228
-
229
- public boolean asXml() { return this.asXml; }
230
-
231
- public void decreaseLevel() {
232
- if(this.level > 0) this.level--;
233
- }
234
-
235
- public String encoding() { return this.encoding; }
236
-
237
- public boolean format() { return this.format; }
238
-
239
- public String getCurrentIndentString() {
240
- StringBuffer res = new StringBuffer();
241
- for(int i = 0; i < this.level; i++) {
242
- res.append(this.indentString());
243
- }
244
- return res.toString();
245
- }
246
-
247
- public String getEncoding() { return this.encoding; }
248
-
249
- public void increaseLevel() {
250
- if(this.level >= 0) this.level++;
251
- }
252
-
253
- public String indentString() { return this.indentString; }
254
-
255
- public boolean noDecl() { return this.noDecl; }
256
-
257
- public boolean noEmpty() { return this.noEmpty; }
258
-
259
- public boolean noXhtml() { return this.noXhtml; }
260
-
261
- public void setFormat(boolean format) { this.format = format; }
262
-
263
- public void setLevel(int level) { this.level = level; }
264
-
265
- @Override
266
- public String toString() { return this.buffer.toString(); }
267
-
268
- public RubyString toRubyString(Ruby runtime) {
269
- ByteList bytes;
270
- if (encoding == null) bytes = new ByteList(buffer.toString().getBytes());
271
- else bytes = new ByteList(RubyEncoding.encode(buffer.toString(), Charset.forName(encoding)), false);
272
- return RubyString.newString(runtime, bytes);
273
- }
274
-
275
- public boolean Xhtml() { return this.xhtml; }
276
-
277
- /**
278
- * Looks up the HTML ElementDescription and tests if it is an
279
- * empty element.
280
- */
281
- protected boolean isEmpty(String name) {
282
- IRubyObject desc =
283
- RuntimeHelpers.invoke(context,
284
- elementDescription, "[]",
285
- context.getRuntime().newString(name));
286
- return RuntimeHelpers.invoke(context, desc, "empty?").isTrue();
287
- }
288
- }