rexml 3.3.7 → 3.4.4
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 +240 -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 +21 -5
- 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 +211 -118
- data/lib/rexml/parsers/pullparser.rb +4 -0
- data/lib/rexml/parsers/sax2parser.rb +2 -0
- 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 +68 -8
- data/lib/rexml/text.rb +29 -57
- 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
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
|
+
version: 3.4.4
|
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.
|
105
|
+
changelog_uri: https://github.com/ruby/rexml/releases/tag/v3.4.4
|
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: []
|