rexml 3.4.1 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +103 -1
- data/lib/rexml/attribute.rb +7 -8
- data/lib/rexml/cdata.rb +1 -1
- data/lib/rexml/child.rb +2 -3
- data/lib/rexml/comment.rb +1 -1
- data/lib/rexml/doctype.rb +3 -8
- data/lib/rexml/document.rb +18 -4
- data/lib/rexml/element.rb +53 -59
- data/lib/rexml/encoding.rb +3 -6
- data/lib/rexml/functions.rb +3 -3
- data/lib/rexml/instruction.rb +1 -1
- data/lib/rexml/namespace.rb +4 -4
- data/lib/rexml/node.rb +2 -2
- data/lib/rexml/parsers/baseparser.rb +138 -81
- data/lib/rexml/parsers/xpathparser.rb +4 -4
- data/lib/rexml/quickpath.rb +19 -18
- data/lib/rexml/rexml.rb +1 -1
- data/lib/rexml/security.rb +2 -2
- data/lib/rexml/source.rb +6 -1
- data/lib/rexml/text.rb +14 -17
- data/lib/rexml/validation/relaxng.rb +27 -26
- data/lib/rexml/validation/validation.rb +8 -8
- data/lib/rexml/xpath.rb +2 -13
- data/lib/rexml/xpath_parser.rb +44 -42
- metadata +4 -4
@@ -157,16 +157,16 @@ module REXML
|
|
157
157
|
if ( @events[@current].matches?(event) )
|
158
158
|
@current += 1
|
159
159
|
if @events[@current].nil?
|
160
|
-
|
160
|
+
@previous.pop
|
161
161
|
elsif @events[@current].kind_of? State
|
162
162
|
@current += 1
|
163
163
|
@events[@current-1].previous = self
|
164
|
-
|
164
|
+
@events[@current-1]
|
165
165
|
else
|
166
|
-
|
166
|
+
self
|
167
167
|
end
|
168
168
|
else
|
169
|
-
|
169
|
+
nil
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -186,7 +186,7 @@ module REXML
|
|
186
186
|
end
|
187
187
|
|
188
188
|
def expected
|
189
|
-
|
189
|
+
[@events[@current]]
|
190
190
|
end
|
191
191
|
|
192
192
|
def <<( event )
|
@@ -244,7 +244,7 @@ module REXML
|
|
244
244
|
evt = :end_attribute
|
245
245
|
end
|
246
246
|
end
|
247
|
-
|
247
|
+
Event.new( evt, arg )
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
@@ -262,9 +262,10 @@ module REXML
|
|
262
262
|
rv = super
|
263
263
|
return rv if rv
|
264
264
|
@prior = @previous.pop
|
265
|
-
|
265
|
+
@prior.next( event )
|
266
|
+
else
|
267
|
+
super
|
266
268
|
end
|
267
|
-
super
|
268
269
|
end
|
269
270
|
|
270
271
|
def matches?(event)
|
@@ -274,7 +275,7 @@ module REXML
|
|
274
275
|
|
275
276
|
def expected
|
276
277
|
return [ @prior.expected, @events[0] ].flatten if @current == 0
|
277
|
-
|
278
|
+
[@events[@current]]
|
278
279
|
end
|
279
280
|
end
|
280
281
|
|
@@ -286,24 +287,24 @@ module REXML
|
|
286
287
|
@current += 1
|
287
288
|
if @events[@current].nil?
|
288
289
|
@current = 0
|
289
|
-
|
290
|
+
self
|
290
291
|
elsif @events[@current].kind_of? State
|
291
292
|
@current += 1
|
292
293
|
@events[@current-1].previous = self
|
293
|
-
|
294
|
+
@events[@current-1]
|
294
295
|
else
|
295
|
-
|
296
|
+
self
|
296
297
|
end
|
297
298
|
else
|
298
299
|
@prior = @previous.pop
|
299
300
|
return @prior.next( event ) if @current == 0
|
300
|
-
|
301
|
+
nil
|
301
302
|
end
|
302
303
|
end
|
303
304
|
|
304
305
|
def expected
|
305
306
|
return [ @prior.expected, @events[0] ].flatten if @current == 0
|
306
|
-
|
307
|
+
[@events[@current]]
|
307
308
|
end
|
308
309
|
end
|
309
310
|
|
@@ -326,17 +327,17 @@ module REXML
|
|
326
327
|
@ord += 1
|
327
328
|
if @events[@current].nil?
|
328
329
|
@current = 0
|
329
|
-
|
330
|
+
self
|
330
331
|
elsif @events[@current].kind_of? State
|
331
332
|
@current += 1
|
332
333
|
@events[@current-1].previous = self
|
333
|
-
|
334
|
+
@events[@current-1]
|
334
335
|
else
|
335
|
-
|
336
|
+
self
|
336
337
|
end
|
337
338
|
else
|
338
339
|
return @previous.pop.next( event ) if @current == 0 and @ord > 0
|
339
|
-
|
340
|
+
nil
|
340
341
|
end
|
341
342
|
end
|
342
343
|
|
@@ -347,9 +348,9 @@ module REXML
|
|
347
348
|
|
348
349
|
def expected
|
349
350
|
if @current == 0 and @ord > 0
|
350
|
-
|
351
|
+
[@previous[-1].expected, @events[0]].flatten
|
351
352
|
else
|
352
|
-
|
353
|
+
[@events[@current]]
|
353
354
|
end
|
354
355
|
end
|
355
356
|
end
|
@@ -403,7 +404,7 @@ module REXML
|
|
403
404
|
|
404
405
|
def expected
|
405
406
|
return [@events[@current]] if @events.size > 0
|
406
|
-
|
407
|
+
@choices.collect do |x|
|
407
408
|
if x[0].kind_of? State
|
408
409
|
x[0].expected
|
409
410
|
else
|
@@ -490,16 +491,16 @@ module REXML
|
|
490
491
|
@current += 1
|
491
492
|
if @events[@current].nil?
|
492
493
|
return self unless @choices[@choice].nil?
|
493
|
-
|
494
|
+
@previous.pop
|
494
495
|
elsif @events[@current].kind_of? State
|
495
496
|
@current += 1
|
496
497
|
@events[@current-1].previous = self
|
497
|
-
|
498
|
+
@events[@current-1]
|
498
499
|
else
|
499
|
-
|
500
|
+
self
|
500
501
|
end
|
501
502
|
else
|
502
|
-
|
503
|
+
nil
|
503
504
|
end
|
504
505
|
end
|
505
506
|
|
@@ -510,7 +511,7 @@ module REXML
|
|
510
511
|
|
511
512
|
def expected
|
512
513
|
return [@events[@current]] if @events[@current]
|
513
|
-
|
514
|
+
@choices[@choice..-1].collect do |x|
|
514
515
|
if x[0].kind_of? State
|
515
516
|
x[0].expected
|
516
517
|
else
|
@@ -80,26 +80,26 @@ module REXML
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def single?
|
83
|
-
|
83
|
+
(@event_type != :start_element and @event_type != :start_attribute)
|
84
84
|
end
|
85
85
|
|
86
86
|
def matches?( event )
|
87
87
|
return false unless event[0] == @event_type
|
88
88
|
case event[0]
|
89
89
|
when nil
|
90
|
-
|
90
|
+
true
|
91
91
|
when :start_element
|
92
|
-
|
92
|
+
event[1] == @event_arg
|
93
93
|
when :end_element
|
94
|
-
|
94
|
+
true
|
95
95
|
when :start_attribute
|
96
|
-
|
96
|
+
event[1] == @event_arg
|
97
97
|
when :end_attribute
|
98
|
-
|
98
|
+
true
|
99
99
|
when :end_document
|
100
|
-
|
100
|
+
true
|
101
101
|
when :text
|
102
|
-
|
102
|
+
@event_arg.nil? || @event_arg == event[1]
|
103
103
|
=begin
|
104
104
|
when :processing_instruction
|
105
105
|
false
|
data/lib/rexml/xpath.rb
CHANGED
@@ -31,12 +31,7 @@ module REXML
|
|
31
31
|
def XPath::first(element, path=nil, namespaces=nil, variables={}, options={})
|
32
32
|
raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
|
33
33
|
raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
|
34
|
-
|
35
|
-
parser.namespaces = namespaces
|
36
|
-
parser.variables = variables
|
37
|
-
path = "*" unless path
|
38
|
-
element = [element] unless element.kind_of? Array
|
39
|
-
parser.parse(path, element).flatten[0]
|
34
|
+
match(element, path, namespaces, variables, options).flatten[0]
|
40
35
|
end
|
41
36
|
|
42
37
|
# Iterates over nodes that match the given path, calling the supplied
|
@@ -60,12 +55,7 @@ module REXML
|
|
60
55
|
def XPath::each(element, path=nil, namespaces=nil, variables={}, options={}, &block)
|
61
56
|
raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
|
62
57
|
raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
|
63
|
-
|
64
|
-
parser.namespaces = namespaces
|
65
|
-
parser.variables = variables
|
66
|
-
path = "*" unless path
|
67
|
-
element = [element] unless element.kind_of? Array
|
68
|
-
parser.parse(path, element).each( &block )
|
58
|
+
match(element, path, namespaces, variables, options).each( &block )
|
69
59
|
end
|
70
60
|
|
71
61
|
# Returns an array of nodes matching a given XPath.
|
@@ -74,7 +64,6 @@ module REXML
|
|
74
64
|
parser.namespaces = namespaces
|
75
65
|
parser.variables = variables
|
76
66
|
path = "*" unless path
|
77
|
-
element = [element] unless element.kind_of? Array
|
78
67
|
parser.parse(path,element)
|
79
68
|
end
|
80
69
|
end
|
data/lib/rexml/xpath_parser.rb
CHANGED
@@ -76,19 +76,32 @@ module REXML
|
|
76
76
|
@variables = vars
|
77
77
|
end
|
78
78
|
|
79
|
-
def parse path,
|
79
|
+
def parse path, node
|
80
80
|
path_stack = @parser.parse( path )
|
81
|
-
|
81
|
+
if node.is_a?(Array)
|
82
|
+
Kernel.warn("REXML::XPath.each, REXML::XPath.first, REXML::XPath.match dropped support for nodeset...", uplevel: 1)
|
83
|
+
return [] if node.empty?
|
84
|
+
node = node.first
|
85
|
+
end
|
86
|
+
|
87
|
+
document = node.document
|
88
|
+
if document
|
89
|
+
document.__send__(:enable_cache) do
|
90
|
+
match( path_stack, node )
|
91
|
+
end
|
92
|
+
else
|
93
|
+
match( path_stack, node )
|
94
|
+
end
|
82
95
|
end
|
83
96
|
|
84
|
-
def get_first path,
|
97
|
+
def get_first path, node
|
85
98
|
path_stack = @parser.parse( path )
|
86
|
-
first( path_stack,
|
99
|
+
first( path_stack, node )
|
87
100
|
end
|
88
101
|
|
89
|
-
def predicate path,
|
102
|
+
def predicate path, node
|
90
103
|
path_stack = @parser.parse( path )
|
91
|
-
match( path_stack,
|
104
|
+
match( path_stack, node )
|
92
105
|
end
|
93
106
|
|
94
107
|
def []=( variable_name, value )
|
@@ -106,7 +119,7 @@ module REXML
|
|
106
119
|
case path[0]
|
107
120
|
when :document
|
108
121
|
# do nothing
|
109
|
-
|
122
|
+
first( path[1..-1], node )
|
110
123
|
when :child
|
111
124
|
for c in node.children
|
112
125
|
r = first( path[1..-1], c )
|
@@ -116,9 +129,9 @@ module REXML
|
|
116
129
|
name = path[2]
|
117
130
|
if node.name == name
|
118
131
|
return node if path.size == 3
|
119
|
-
|
132
|
+
first( path[3..-1], node )
|
120
133
|
else
|
121
|
-
|
134
|
+
nil
|
122
135
|
end
|
123
136
|
when :descendant_or_self
|
124
137
|
r = first( path[1..-1], node )
|
@@ -128,23 +141,21 @@ module REXML
|
|
128
141
|
return r if r
|
129
142
|
end
|
130
143
|
when :node
|
131
|
-
|
144
|
+
first( path[1..-1], node )
|
132
145
|
when :any
|
133
|
-
|
146
|
+
first( path[1..-1], node )
|
147
|
+
else
|
148
|
+
nil
|
134
149
|
end
|
135
|
-
return nil
|
136
150
|
end
|
137
151
|
|
138
152
|
|
139
|
-
def match(path_stack,
|
140
|
-
nodeset =
|
141
|
-
position = i + 1
|
142
|
-
XPathNode.new(node, position: position)
|
143
|
-
end
|
153
|
+
def match(path_stack, node)
|
154
|
+
nodeset = [XPathNode.new(node, position: 1)]
|
144
155
|
result = expr(path_stack, nodeset)
|
145
156
|
case result
|
146
157
|
when Array # nodeset
|
147
|
-
unnode(result)
|
158
|
+
unnode(result).uniq
|
148
159
|
else
|
149
160
|
[result]
|
150
161
|
end
|
@@ -162,10 +173,10 @@ module REXML
|
|
162
173
|
# 2. If no mapping was supplied, use the context node to look up the namespace
|
163
174
|
def get_namespace( node, prefix )
|
164
175
|
if @namespaces
|
165
|
-
|
176
|
+
@namespaces[prefix] || ''
|
166
177
|
else
|
167
178
|
return node.namespace( prefix ) if node.node_type == :element
|
168
|
-
|
179
|
+
''
|
169
180
|
end
|
170
181
|
end
|
171
182
|
|
@@ -492,14 +503,10 @@ module REXML
|
|
492
503
|
if strict?
|
493
504
|
raw_node.name == name and raw_node.namespace == ""
|
494
505
|
else
|
495
|
-
|
496
|
-
ns = get_namespace(raw_node, prefix)
|
497
|
-
raw_node.name == name and raw_node.namespace == ns
|
506
|
+
raw_node.name == name and raw_node.namespace == get_namespace(raw_node, prefix)
|
498
507
|
end
|
499
508
|
else
|
500
|
-
|
501
|
-
ns = get_namespace(raw_node, prefix)
|
502
|
-
raw_node.name == name and raw_node.namespace == ns
|
509
|
+
raw_node.name == name and raw_node.namespace == get_namespace(raw_node, prefix)
|
503
510
|
end
|
504
511
|
when :attribute
|
505
512
|
if prefix.nil?
|
@@ -507,9 +514,7 @@ module REXML
|
|
507
514
|
elsif prefix.empty?
|
508
515
|
raw_node.name == name and raw_node.namespace == ""
|
509
516
|
else
|
510
|
-
|
511
|
-
ns = get_namespace(raw_node.element, prefix)
|
512
|
-
raw_node.name == name and raw_node.namespace == ns
|
517
|
+
raw_node.name == name and raw_node.namespace == get_namespace(raw_node.element, prefix)
|
513
518
|
end
|
514
519
|
else
|
515
520
|
false
|
@@ -671,7 +676,7 @@ module REXML
|
|
671
676
|
if order == :forward
|
672
677
|
index
|
673
678
|
else
|
674
|
-
|
679
|
+
index.map(&:-@)
|
675
680
|
end
|
676
681
|
end
|
677
682
|
ordered.collect do |_index, node|
|
@@ -758,22 +763,19 @@ module REXML
|
|
758
763
|
end
|
759
764
|
|
760
765
|
def following_node_of( node )
|
761
|
-
if node.kind_of?
|
762
|
-
|
763
|
-
|
764
|
-
return next_sibling_node(node)
|
766
|
+
return node.children[0] if node.kind_of?(Element) and node.children.size > 0
|
767
|
+
|
768
|
+
next_sibling_node(node)
|
765
769
|
end
|
766
770
|
|
767
771
|
def next_sibling_node(node)
|
768
772
|
psn = node.next_sibling_node
|
769
773
|
while psn.nil?
|
770
|
-
if node.parent.nil? or node.parent.class == Document
|
771
|
-
return nil
|
772
|
-
end
|
774
|
+
return nil if node.parent.nil? or node.parent.class == Document
|
773
775
|
node = node.parent
|
774
776
|
psn = node.next_sibling_node
|
775
777
|
end
|
776
|
-
|
778
|
+
psn
|
777
779
|
end
|
778
780
|
|
779
781
|
def child(nodeset)
|
@@ -806,13 +808,13 @@ module REXML
|
|
806
808
|
def norm b
|
807
809
|
case b
|
808
810
|
when true, false
|
809
|
-
|
811
|
+
b
|
810
812
|
when 'true', 'false'
|
811
|
-
|
813
|
+
Functions::boolean( b )
|
812
814
|
when /^\d+(\.\d+)?$/, Numeric
|
813
|
-
|
815
|
+
Functions::number( b )
|
814
816
|
else
|
815
|
-
|
817
|
+
Functions::string( b )
|
816
818
|
end
|
817
819
|
end
|
818
820
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: An XML toolkit for Ruby
|
13
13
|
email:
|
@@ -102,7 +102,7 @@ homepage: https://github.com/ruby/rexml
|
|
102
102
|
licenses:
|
103
103
|
- BSD-2-Clause
|
104
104
|
metadata:
|
105
|
-
changelog_uri: https://github.com/ruby/rexml/releases/tag/v3.4.
|
105
|
+
changelog_uri: https://github.com/ruby/rexml/releases/tag/v3.4.2
|
106
106
|
rdoc_options:
|
107
107
|
- "--main"
|
108
108
|
- README.md
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
rubygems_version: 3.6.
|
122
|
+
rubygems_version: 3.6.9
|
123
123
|
specification_version: 4
|
124
124
|
summary: An XML toolkit for Ruby
|
125
125
|
test_files: []
|