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.

Files changed (113) hide show
  1. data/CHANGELOG.ja.rdoc +63 -0
  2. data/CHANGELOG.rdoc +44 -1
  3. data/Manifest.txt +3 -8
  4. data/README.ja.rdoc +4 -4
  5. data/README.rdoc +4 -4
  6. data/Rakefile +3 -0
  7. data/bin/nokogiri +6 -1
  8. data/ext/java/nokogiri/EncodingHandler.java +32 -0
  9. data/ext/java/nokogiri/HtmlDocument.java +36 -0
  10. data/ext/java/nokogiri/HtmlElementDescription.java +34 -0
  11. data/ext/java/nokogiri/HtmlEntityLookup.java +34 -0
  12. data/ext/java/nokogiri/HtmlSaxParserContext.java +41 -3
  13. data/ext/java/nokogiri/NokogiriService.java +109 -13
  14. data/ext/java/nokogiri/XmlAttr.java +40 -4
  15. data/ext/java/nokogiri/XmlAttributeDecl.java +32 -0
  16. data/ext/java/nokogiri/XmlCdata.java +41 -2
  17. data/ext/java/nokogiri/XmlComment.java +38 -1
  18. data/ext/java/nokogiri/XmlDocument.java +56 -11
  19. data/ext/java/nokogiri/XmlDocumentFragment.java +39 -30
  20. data/ext/java/nokogiri/XmlDtd.java +37 -0
  21. data/ext/java/nokogiri/XmlElement.java +51 -2
  22. data/ext/java/nokogiri/XmlElementContent.java +32 -0
  23. data/ext/java/nokogiri/XmlElementDecl.java +32 -0
  24. data/ext/java/nokogiri/XmlEntityDecl.java +32 -0
  25. data/ext/java/nokogiri/XmlEntityReference.java +35 -2
  26. data/ext/java/nokogiri/XmlNamespace.java +55 -5
  27. data/ext/java/nokogiri/XmlNode.java +129 -136
  28. data/ext/java/nokogiri/XmlNodeSet.java +36 -0
  29. data/ext/java/nokogiri/XmlProcessingInstruction.java +34 -1
  30. data/ext/java/nokogiri/XmlReader.java +36 -0
  31. data/ext/java/nokogiri/XmlRelaxng.java +34 -1
  32. data/ext/java/nokogiri/XmlSaxParserContext.java +52 -7
  33. data/ext/java/nokogiri/XmlSaxPushParser.java +36 -0
  34. data/ext/java/nokogiri/XmlSchema.java +34 -1
  35. data/ext/java/nokogiri/XmlSyntaxError.java +48 -18
  36. data/ext/java/nokogiri/XmlText.java +45 -6
  37. data/ext/java/nokogiri/XmlXpathContext.java +45 -0
  38. data/ext/java/nokogiri/XsltStylesheet.java +58 -3
  39. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +50 -26
  40. data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +35 -1
  41. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +51 -13
  42. data/ext/java/nokogiri/internals/NokogiriHandler.java +70 -21
  43. data/ext/java/nokogiri/internals/NokogiriHelpers.java +95 -38
  44. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +37 -3
  45. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +39 -1
  46. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +43 -7
  47. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +77 -10
  48. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +49 -20
  49. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +34 -2
  50. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -1
  51. data/ext/java/nokogiri/internals/ParserContext.java +32 -0
  52. data/ext/java/nokogiri/internals/PushInputStream.java +33 -3
  53. data/ext/java/nokogiri/internals/ReaderNode.java +50 -8
  54. data/ext/java/nokogiri/internals/SaveContext.java +35 -2
  55. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +34 -1
  56. data/ext/java/nokogiri/internals/XmlDeclHandler.java +32 -0
  57. data/ext/java/nokogiri/internals/XmlDomParser.java +32 -0
  58. data/ext/java/nokogiri/internals/XmlDomParserContext.java +43 -11
  59. data/ext/java/nokogiri/internals/XmlSaxParser.java +32 -0
  60. data/ext/java/nokogiri/internals/XsltExtensionFunction.java +72 -0
  61. data/ext/nokogiri/depend +358 -32
  62. data/ext/nokogiri/extconf.rb +1 -3
  63. data/ext/nokogiri/nokogiri.c +2 -0
  64. data/ext/nokogiri/nokogiri.h +7 -0
  65. data/ext/nokogiri/xml_dtd.c +2 -2
  66. data/ext/nokogiri/xml_io.c +2 -2
  67. data/ext/nokogiri/xml_node.c +31 -6
  68. data/ext/nokogiri/xml_node_set.c +1 -1
  69. data/ext/nokogiri/xml_sax_parser.c +1 -1
  70. data/ext/nokogiri/xml_sax_parser_context.c +40 -0
  71. data/ext/nokogiri/xml_xpath_context.c +33 -2
  72. data/ext/nokogiri/xslt_stylesheet.c +122 -6
  73. data/lib/nokogiri.rb +12 -5
  74. data/lib/nokogiri/css/generated_tokenizer.rb +1 -2
  75. data/lib/nokogiri/css/xpath_visitor.rb +15 -7
  76. data/lib/nokogiri/decorators/slop.rb +5 -3
  77. data/lib/nokogiri/html/document.rb +3 -3
  78. data/lib/nokogiri/html/document_fragment.rb +19 -17
  79. data/lib/nokogiri/nokogiri.jar +0 -0
  80. data/lib/nokogiri/version.rb +1 -1
  81. data/lib/nokogiri/xml/document.rb +26 -1
  82. data/lib/nokogiri/xml/document_fragment.rb +2 -2
  83. data/lib/nokogiri/xml/dtd.rb +11 -0
  84. data/lib/nokogiri/xml/node.rb +156 -45
  85. data/lib/nokogiri/xml/node_set.rb +2 -2
  86. data/lib/nokogiri/xml/reader.rb +36 -0
  87. data/lib/nokogiri/xml/sax/document.rb +4 -2
  88. data/lib/nokogiri/xslt.rb +9 -5
  89. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  90. data/tasks/cross_compile.rb +27 -8
  91. data/test/css/test_parser.rb +29 -18
  92. data/test/decorators/test_slop.rb +16 -0
  93. data/test/html/test_document_fragment.rb +46 -3
  94. data/test/html/test_node.rb +9 -0
  95. data/test/xml/sax/test_parser.rb +11 -3
  96. data/test/xml/sax/test_parser_context.rb +50 -0
  97. data/test/xml/sax/test_push_parser.rb +18 -1
  98. data/test/xml/test_document_fragment.rb +15 -8
  99. data/test/xml/test_dtd.rb +15 -0
  100. data/test/xml/test_node.rb +31 -2
  101. data/test/xml/test_node_reparenting.rb +59 -31
  102. data/test/xml/test_node_set.rb +13 -0
  103. data/test/xml/test_xpath.rb +32 -0
  104. data/test/xslt/test_custom_functions.rb +94 -0
  105. metadata +483 -495
  106. data/ext/nokogiri/libcharset-1.dll +0 -0
  107. data/ext/nokogiri/libexslt.dll +0 -0
  108. data/ext/nokogiri/libiconv-2.dll +0 -0
  109. data/ext/nokogiri/libxml2.dll +0 -0
  110. data/ext/nokogiri/libxslt.dll +0 -0
  111. data/ext/nokogiri/zlib1.dll +0 -0
  112. data/spec/helper.rb +0 -3
  113. data/spec/xml/reader_spec.rb +0 -307
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,3 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
2
-
3
- require 'nokogiri'
@@ -1,307 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'helper')
2
-
3
- include Nokogiri::XML
4
-
5
- describe Nokogiri::XML::Reader do
6
-
7
- it "should return the correct local_names" do
8
- xml = <<-oexml
9
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
10
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
11
- </x>
12
- oexml
13
- r = Nokogiri::XML::Reader.from_memory(xml)
14
- r.should_not be_nil
15
- r.local_name.should be_nil
16
- r.map{|x| x.local_name}.should == ["x","#text","foo","#text","foo","#text","x"]
17
- end
18
-
19
- it "should return the correct names" do
20
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
21
- <x xmlns:edi='http://ecommerce.example.org/schema'>
22
- <edi:foo>hello</edi:foo>
23
- </x>
24
- eoxml
25
- reader.should_not be_nil
26
- reader.name.should be_nil
27
- reader.map{|x| x.name}.should == ["x", "#text", "edi:foo", "#text", "edi:foo", "#text", "x"]
28
- end
29
-
30
- it "should set io as source when called from_io method" do
31
- io = StringIO.new(<<-eoxml)
32
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
33
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
34
- </x>
35
- eoxml
36
- reader = Nokogiri::XML::Reader.from_io(io)
37
- reader.source.should be_equal(io)
38
- end
39
-
40
- it "should raise ArgumentError if nil is passed" do
41
- lambda{
42
- Nokogiri::XML::Reader.from_memory(nil)
43
- }.should raise_error(ArgumentError)
44
- lambda{
45
- Nokogiri::XML::Reader.from_io(nil)
46
- }.should raise_error(ArgumentError)
47
- end
48
-
49
- it "should parse from_io" do
50
- io = StringIO.new(<<-eoxml)
51
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
52
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
53
- </x>
54
- eoxml
55
- reader = Nokogiri::XML::Reader.from_io(io)
56
- reader.should_not be_default
57
- reader.map{ |x| x.default? }.should == [false, false, false, false, false, false, false]
58
- end
59
-
60
- it "should parse when passed an io object" do
61
- io = StringIO.new(<<-eoxml)
62
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
63
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
64
- </x>
65
- eoxml
66
- reader = Nokogiri::XML::Reader(io)
67
- reader.should_not be_default
68
- reader.map{ |x| x.default? }.should == [false, false, false, false, false, false, false]
69
- end
70
-
71
- it "should set string as source when called from_memory" do
72
- xml = <<-eoxml
73
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
74
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
75
- </x>
76
- eoxml
77
- reader = Nokogiri::XML::Reader(xml)
78
- reader.source.should be_equal(xml)
79
- end
80
-
81
- it "should return false for default" do # Sorry for the description. Couldn't avoid to.
82
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
83
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
84
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
85
- </x>
86
- eoxml
87
- reader.should_not be_default
88
- reader.map { |x| x.default? }.should == [false, false, false, false, false, false, false]
89
- end
90
-
91
- it "should return the correct boolean value when asked for value?" do
92
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
93
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
94
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
95
- </x>
96
- eoxml
97
-
98
- reader.value?.should == false # Look for how should I do this in RSpec.
99
- reader.map {|x| x.value? }.should == [false, true, false, true, false, true, false]
100
- end
101
-
102
- it "should be able to deal with errors" do
103
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
104
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
105
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
106
- <foo>
107
- </x>
108
- eoxml
109
-
110
- reader.errors.should have(0).items
111
-
112
- lambda {
113
- reader.each { |node| }
114
- }.should raise_error(Nokogiri::XML::SyntaxError)
115
-
116
- reader.errors.should have(1).item
117
- end
118
-
119
- it "should retrieve the right arguments" do
120
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
121
- <x xmlns:tenderlove='http://tenderlovemaking.com/'
122
- xmlns='http://mothership.connection.com/'
123
- >
124
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
125
- </x>
126
- eoxml
127
- reader.attributes.should be_empty
128
- reader.map { |x| x.attributes }.should == [{'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
129
- 'xmlns'=>'http://mothership.connection.com/'},
130
- {}, {"awesome"=>"true"}, {}, {"awesome"=>"true"}, {},
131
- {'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
132
- 'xmlns'=>'http://mothership.connection.com/'}]
133
- end
134
-
135
- it "should be able to acces the same attribute through both attribute and attributes method" do
136
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
137
- <x xmlns:tenderlove='http://tenderlovemaking.com/'
138
- xmlns='http://mothership.connection.com/'
139
- >
140
- <tenderlove:foo awesome='true' size='giant'>snuggles!</tenderlove:foo>
141
- </x>
142
- eoxml
143
-
144
- reader.attribute(nil).should be_nil
145
-
146
- reader.each do |node|
147
- node.attributes.each do |key, value|
148
- node.attribute(key).should == value
149
- end
150
- end
151
- end
152
-
153
- it "should be able to retrieve an attribute given an index" do
154
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
155
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
156
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
157
- </x>
158
- eoxml
159
-
160
- reader.attribute_at(nil).should be_nil
161
- reader.attribute_at(0).should be_nil
162
-
163
- reader.map {|x| x.attribute_at(0) }.should == ['http://tenderlovemaking.com/', nil, 'true', nil, 'true', nil, 'http://tenderlovemaking.com/']
164
- end
165
-
166
- it "should be able to access an attribute value by its name" do # I should get this test for free
167
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
168
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
169
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
170
- </x>
171
- eoxml
172
-
173
- reader.attribute(nil).should be_nil
174
- reader.attribute('awesome').should be_nil
175
-
176
- reader.map {|x| x.attribute('awesome') }.should ==[nil, nil, 'true', nil, 'true', nil, nil]
177
- end
178
-
179
- it "should retrieve the correct number of attributes" do
180
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
181
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
182
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
183
- </x>
184
- eoxml
185
-
186
- reader.attribute_count.should == 0
187
- reader.map {|x| x.attribute_count}.should == [1, 0, 1, 0, 0, 0, 0]
188
- end
189
-
190
- it "should return the depth of the current node" do
191
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
192
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
193
- <tenderlove:foo>snuggles!</tenderlove:foo>
194
- </x>
195
- eoxml
196
-
197
- reader.depth.should == 0
198
-
199
- reader.map {|x| x.depth}.should == [0,1,1,2,1,1,0]
200
- end
201
-
202
- it "should return the right encoding" do
203
- string = <<-eoxml
204
- <awesome>
205
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
206
- <p xml:lang="ja">日本語が上手です</p>
207
- </awesome>
208
- eoxml
209
- reader = Nokogiri::XML::Reader.from_memory(string, nil, 'UTF-8')
210
- reader.map { |x| x.encoding }.uniq.should == ['UTF-8']
211
- end
212
-
213
- it "should return the right xml version" do
214
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
215
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
216
- <tenderlove:foo>snuggles!</tenderlove:foo>
217
- </x>
218
- eoxml
219
-
220
- reader.xml_version.should be_nil
221
-
222
- reader.map { |x| x.xml_version }.uniq.should == ['1.0']
223
- end
224
-
225
- it "should retrieve the correct lang" do
226
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
227
- <awesome>
228
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
229
- <p xml:lang="ja">日本語が上手です</p>
230
- </awesome>
231
- eoxml
232
-
233
- reader.lang.should be_nil
234
-
235
- reader.map {|x| x.lang}.should == [nil, nil, "en", "en", "en", nil, "ja", "ja", "ja", nil, nil]
236
- end
237
-
238
- it "should retrieve the correct value" do
239
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
240
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
241
- <tenderlove:foo>snuggles!</tenderlove:foo>
242
- </x>
243
- eoxml
244
-
245
- reader.value.should be_nil
246
-
247
- reader.map {|x| x.value }.should == [nil, "\n ", nil, "snuggles!", nil, "\n ", nil]
248
- end
249
-
250
- it "should return the node's prefix" do
251
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
252
- <x xmlns:edi='http://ecommerce.example.org/schema'>
253
- <edi:foo>hello</edi:foo>
254
- </x>
255
- eoxml
256
-
257
- reader.prefix.should be_nil
258
-
259
- reader.map { |n| n.prefix }.should == [nil, nil, "edi", nil, "edi", nil, nil]
260
- end
261
-
262
- it "should return the reader state, whatever it is" do
263
- reader = Nokogiri::XML::Reader.from_memory('<foo>bar</bar>')
264
- reader.state.should_not be_nil
265
- end
266
-
267
- it "should return the namespace's uri" do
268
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
269
- <x xmlns:edi='http://ecommerce.example.org/schema'>
270
- <edi:foo>hello</edi:foo>
271
- </x>
272
- eoxml
273
- reader.namespace_uri.should be_nil
274
-
275
- reader.map { |n| n.namespace_uri }.should == [nil,
276
- nil,
277
- "http://ecommerce.example.org/schema",
278
- nil,
279
- "http://ecommerce.example.org/schema",
280
- nil,
281
- nil]
282
- end
283
-
284
- it "should return the node's local_name" do
285
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
286
- <x xmlns:edi='http://ecommerce.example.org/schema'>
287
- <edi:foo>hello</edi:foo>
288
- </x>
289
- eoxml
290
-
291
- reader.local_name.should be_nil
292
-
293
- reader.map {|n| n.local_name }.should == ["x", "#text", "foo", "#text", "foo", "#text", "x"]
294
- end
295
-
296
- it "should return node's name" do
297
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
298
- <x xmlns:edi='http://ecommerce.example.org/schema'>
299
- <edi:foo>hello</edi:foo>
300
- </x>
301
- eoxml
302
-
303
- reader.name.should be_nil
304
-
305
- reader.map { |n| n.name }.should ==["x", "#text", "edi:foo", "#text", "edi:foo", "#text", "x"]
306
- end
307
- end