rexml 3.4.4 → 3.4.5

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +304 -0
  3. data/doc/rexml/tasks/rdoc/child.rdoc +1 -1
  4. data/doc/rexml/tasks/rdoc/document.rdoc +1 -1
  5. data/doc/rexml/tasks/rdoc/element.rdoc +1 -1
  6. data/doc/rexml/tasks/rdoc/node.rdoc +1 -1
  7. data/doc/rexml/tasks/rdoc/parent.rdoc +1 -1
  8. data/doc/rexml/tutorial.rdoc +4 -2
  9. data/lib/rexml/attribute.rb +11 -2
  10. data/lib/rexml/cdata.rb +1 -1
  11. data/lib/rexml/comment.rb +1 -1
  12. data/lib/rexml/doctype.rb +21 -18
  13. data/lib/rexml/document.rb +6 -21
  14. data/lib/rexml/element.rb +164 -158
  15. data/lib/rexml/entity.rb +19 -10
  16. data/lib/rexml/formatters/default.rb +35 -19
  17. data/lib/rexml/formatters/pretty.rb +2 -3
  18. data/lib/rexml/functions.rb +164 -147
  19. data/lib/rexml/instruction.rb +3 -3
  20. data/lib/rexml/namespace.rb +9 -1
  21. data/lib/rexml/output.rb +1 -1
  22. data/lib/rexml/parent.rb +1 -3
  23. data/lib/rexml/parsers/baseparser.rb +60 -73
  24. data/lib/rexml/parsers/sax2parser.rb +9 -20
  25. data/lib/rexml/parsers/xpathparser.rb +87 -58
  26. data/lib/rexml/rexml.rb +2 -2
  27. data/lib/rexml/security.rb +6 -6
  28. data/lib/rexml/source.rb +9 -8
  29. data/lib/rexml/text.rb +39 -35
  30. data/lib/rexml/validation/relaxng.rb +11 -0
  31. data/lib/rexml/xmldecl.rb +2 -2
  32. data/lib/rexml/xmltokens.rb +8 -8
  33. data/lib/rexml/xpath.rb +0 -1
  34. data/lib/rexml/xpath_parser.rb +745 -467
  35. metadata +16 -17
  36. data/lib/rexml/quickpath.rb +0 -267
  37. /data/doc/rexml/tasks/{tocs → includes}/child_toc.rdoc +0 -0
  38. /data/doc/rexml/tasks/{tocs → includes}/document_toc.rdoc +0 -0
  39. /data/doc/rexml/tasks/{tocs → includes}/element_toc.rdoc +0 -0
  40. /data/doc/rexml/tasks/{tocs → includes}/node_toc.rdoc +0 -0
  41. /data/doc/rexml/tasks/{tocs → includes}/parent_toc.rdoc +0 -0
  42. /data/doc/rexml/tasks/{tocs/master_toc.rdoc → rdoc/toc.rdoc} +0 -0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.4
4
+ version: 3.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -19,34 +19,34 @@ extra_rdoc_files:
19
19
  - NEWS.md
20
20
  - README.md
21
21
  - doc/rexml/context.rdoc
22
+ - doc/rexml/tasks/includes/child_toc.rdoc
23
+ - doc/rexml/tasks/includes/document_toc.rdoc
24
+ - doc/rexml/tasks/includes/element_toc.rdoc
25
+ - doc/rexml/tasks/includes/node_toc.rdoc
26
+ - doc/rexml/tasks/includes/parent_toc.rdoc
22
27
  - doc/rexml/tasks/rdoc/child.rdoc
23
28
  - doc/rexml/tasks/rdoc/document.rdoc
24
29
  - doc/rexml/tasks/rdoc/element.rdoc
25
30
  - doc/rexml/tasks/rdoc/node.rdoc
26
31
  - doc/rexml/tasks/rdoc/parent.rdoc
27
- - doc/rexml/tasks/tocs/child_toc.rdoc
28
- - doc/rexml/tasks/tocs/document_toc.rdoc
29
- - doc/rexml/tasks/tocs/element_toc.rdoc
30
- - doc/rexml/tasks/tocs/master_toc.rdoc
31
- - doc/rexml/tasks/tocs/node_toc.rdoc
32
- - doc/rexml/tasks/tocs/parent_toc.rdoc
32
+ - doc/rexml/tasks/rdoc/toc.rdoc
33
33
  - doc/rexml/tutorial.rdoc
34
34
  files:
35
35
  - LICENSE.txt
36
36
  - NEWS.md
37
37
  - README.md
38
38
  - doc/rexml/context.rdoc
39
+ - doc/rexml/tasks/includes/child_toc.rdoc
40
+ - doc/rexml/tasks/includes/document_toc.rdoc
41
+ - doc/rexml/tasks/includes/element_toc.rdoc
42
+ - doc/rexml/tasks/includes/node_toc.rdoc
43
+ - doc/rexml/tasks/includes/parent_toc.rdoc
39
44
  - doc/rexml/tasks/rdoc/child.rdoc
40
45
  - doc/rexml/tasks/rdoc/document.rdoc
41
46
  - doc/rexml/tasks/rdoc/element.rdoc
42
47
  - doc/rexml/tasks/rdoc/node.rdoc
43
48
  - doc/rexml/tasks/rdoc/parent.rdoc
44
- - doc/rexml/tasks/tocs/child_toc.rdoc
45
- - doc/rexml/tasks/tocs/document_toc.rdoc
46
- - doc/rexml/tasks/tocs/element_toc.rdoc
47
- - doc/rexml/tasks/tocs/master_toc.rdoc
48
- - doc/rexml/tasks/tocs/node_toc.rdoc
49
- - doc/rexml/tasks/tocs/parent_toc.rdoc
49
+ - doc/rexml/tasks/rdoc/toc.rdoc
50
50
  - doc/rexml/tutorial.rdoc
51
51
  - lib/rexml.rb
52
52
  - lib/rexml/attlistdecl.rb
@@ -83,7 +83,6 @@ files:
83
83
  - lib/rexml/parsers/treeparser.rb
84
84
  - lib/rexml/parsers/ultralightparser.rb
85
85
  - lib/rexml/parsers/xpathparser.rb
86
- - lib/rexml/quickpath.rb
87
86
  - lib/rexml/rexml.rb
88
87
  - lib/rexml/sax2listener.rb
89
88
  - lib/rexml/security.rb
@@ -102,7 +101,7 @@ homepage: https://github.com/ruby/rexml
102
101
  licenses:
103
102
  - BSD-2-Clause
104
103
  metadata:
105
- changelog_uri: https://github.com/ruby/rexml/releases/tag/v3.4.4
104
+ changelog_uri: https://github.com/ruby/rexml/releases/tag/v3.4.5
106
105
  rdoc_options:
107
106
  - "--main"
108
107
  - README.md
@@ -112,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
111
  requirements:
113
112
  - - ">="
114
113
  - !ruby/object:Gem::Version
115
- version: 2.5.0
114
+ version: 2.6.0
116
115
  required_rubygems_version: !ruby/object:Gem::Requirement
117
116
  requirements:
118
117
  - - ">="
119
118
  - !ruby/object:Gem::Version
120
119
  version: '0'
121
120
  requirements: []
122
- rubygems_version: 3.6.9
121
+ rubygems_version: 4.0.20
123
122
  specification_version: 4
124
123
  summary: An XML toolkit for Ruby
125
124
  test_files: []
@@ -1,267 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative 'functions'
3
- require_relative 'xmltokens'
4
-
5
- module REXML
6
- class QuickPath
7
- include Functions
8
- include XMLTokens
9
-
10
- # A base Hash object to be used when initializing a
11
- # default empty namespaces set.
12
- EMPTY_HASH = {}
13
-
14
- def QuickPath::first element, path, namespaces=EMPTY_HASH
15
- match(element, path, namespaces)[0]
16
- end
17
-
18
- def QuickPath::each element, path, namespaces=EMPTY_HASH, &block
19
- path = "*" unless path
20
- match(element, path, namespaces).each( &block )
21
- end
22
-
23
- def QuickPath::match element, path, namespaces=EMPTY_HASH
24
- raise "nil is not a valid xpath" unless path
25
- results = nil
26
- Functions::namespace_context = namespaces
27
- case path
28
- when /^\/([^\/]|$)/u
29
- # match on root
30
- path = path[1..-1]
31
- return [element.root.parent] if path == ''
32
- results = filter([element.root], path)
33
- when /^[-\w]*::/u
34
- results = filter([element], path)
35
- when /^\*/u
36
- results = filter(element.to_a, path)
37
- when /^[\[!\w:]/u
38
- # match on child
39
- children = element.to_a
40
- results = filter(children, path)
41
- else
42
- results = filter([element], path)
43
- end
44
- results
45
- end
46
-
47
- # Given an array of nodes it filters the array based on the path. The
48
- # result is that when this method returns, the array will contain elements
49
- # which match the path
50
- def QuickPath::filter elements, path
51
- return elements if path.nil? or path == '' or elements.size == 0
52
- case path
53
- when /^\/\//u # Descendant
54
- axe( elements, "descendant-or-self", $' )
55
- when /^\/?\b(\w[-\w]*)\b::/u # Axe
56
- axe( elements, $1, $' )
57
- when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child
58
- rest = $'
59
- results = []
60
- elements.each do |element|
61
- results |= filter( element.to_a, rest )
62
- end
63
- results
64
- when /^\/?(\w[-\w]*)\(/u # / Function
65
- function( elements, $1, $' )
66
- when Namespace::NAMESPLIT # Element name
67
- name = $2
68
- ns = $1
69
- rest = $'
70
- elements.delete_if do |element|
71
- !(element.kind_of? Element and
72
- (element.expanded_name == name or
73
- (element.name == name and
74
- element.namespace == Functions.namespace_context[ns])))
75
- end
76
- filter( elements, rest )
77
- when /^\/\[/u
78
- matches = []
79
- elements.each do |element|
80
- matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element
81
- end
82
- matches
83
- when /^\[/u # Predicate
84
- predicate( elements, path )
85
- when /^\/?\.\.\./u # Ancestor
86
- axe( elements, "ancestor", $' )
87
- when /^\/?\.\./u # Parent
88
- filter( elements.collect{|e|e.parent}, $' )
89
- when /^\/?\./u # Self
90
- filter( elements, $' )
91
- when /^\*/u # Any
92
- results = []
93
- elements.each do |element|
94
- results |= filter( [element], $' ) if element.kind_of? Element
95
- #if element.kind_of? Element
96
- # children = element.to_a
97
- # children.delete_if { |child| !child.kind_of?(Element) }
98
- # results |= filter( children, $' )
99
- #end
100
- end
101
- results
102
- else
103
- []
104
- end
105
- end
106
-
107
- def QuickPath::axe( elements, axe_name, rest )
108
- matches = []
109
- matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u
110
- case axe_name
111
- when /^descendant/u
112
- elements.each do |element|
113
- matches |= filter( element.to_a, "descendant-or-self::#{rest}" ) if element.kind_of? Element
114
- end
115
- when /^ancestor/u
116
- elements.each do |element|
117
- while element.parent
118
- matches << element.parent
119
- element = element.parent
120
- end
121
- end
122
- matches = filter( matches, rest )
123
- when "self"
124
- matches = filter( elements, rest )
125
- when "child"
126
- elements.each do |element|
127
- matches |= filter( element.to_a, rest ) if element.kind_of? Element
128
- end
129
- when "attribute"
130
- elements.each do |element|
131
- matches << element.attributes[ rest ] if element.kind_of? Element
132
- end
133
- when "parent"
134
- matches = filter(elements.collect{|element| element.parent}.uniq, rest)
135
- when "following-sibling"
136
- matches = filter(elements.collect{|element| element.next_sibling}.uniq,
137
- rest)
138
- when "previous-sibling"
139
- matches = filter(elements.collect{|element|
140
- element.previous_sibling}.uniq, rest )
141
- end
142
- matches.uniq
143
- end
144
-
145
- OPERAND_ = '((?=(?:(?!and|or).)*[^\s<>=])[^\s<>=]+)'
146
- # A predicate filters a node-set with respect to an axis to produce a
147
- # new node-set. For each node in the node-set to be filtered, the
148
- # PredicateExpr is evaluated with that node as the context node, with
149
- # the number of nodes in the node-set as the context size, and with the
150
- # proximity position of the node in the node-set with respect to the
151
- # axis as the context position; if PredicateExpr evaluates to true for
152
- # that node, the node is included in the new node-set; otherwise, it is
153
- # not included.
154
- #
155
- # A PredicateExpr is evaluated by evaluating the Expr and converting
156
- # the result to a boolean. If the result is a number, the result will
157
- # be converted to true if the number is equal to the context position
158
- # and will be converted to false otherwise; if the result is not a
159
- # number, then the result will be converted as if by a call to the
160
- # boolean function. Thus a location path para[3] is equivalent to
161
- # para[position()=3].
162
- def QuickPath::predicate( elements, path )
163
- ind = 1
164
- bcount = 1
165
- while bcount > 0
166
- bcount += 1 if path[ind] == ?[
167
- bcount -= 1 if path[ind] == ?]
168
- ind += 1
169
- end
170
- ind -= 1
171
- predicate = path[1..ind-1]
172
- rest = path[ind+1..-1]
173
-
174
- # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c'
175
- #
176
- predicate.gsub!(
177
- /#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u,
178
- '\1 \2 \3 and \3 \4 \5' )
179
- # Let's do some Ruby trickery to avoid some work:
180
- predicate.gsub!( /&/u, "&&" )
181
- predicate.gsub!( /=/u, "==" )
182
- predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' )
183
- predicate.gsub!( /\bmod\b/u, "%" )
184
- predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
185
- fname = $1
186
- fname.gsub( /-/u, "_" )
187
- }
188
-
189
- Functions.pair = [ 0, elements.size ]
190
- results = []
191
- elements.each do |element|
192
- Functions.pair[0] += 1
193
- Functions.node = element
194
- res = eval( predicate )
195
- case res
196
- when true
197
- results << element
198
- when Integer
199
- results << element if Functions.pair[0] == res
200
- when String
201
- results << element
202
- end
203
- end
204
- filter( results, rest )
205
- end
206
-
207
- def QuickPath::attribute( name )
208
- Functions.node.attributes[name] if Functions.node.kind_of? Element
209
- end
210
-
211
- def QuickPath::name()
212
- Functions.node.name if Functions.node.kind_of? Element
213
- end
214
-
215
- def QuickPath::method_missing( id, *args )
216
- begin
217
- Functions.send( id.id2name, *args )
218
- rescue Exception
219
- raise "METHOD: #{id.id2name}(#{args.join ', '})\n#{$!.message}"
220
- end
221
- end
222
-
223
- def QuickPath::function( elements, fname, rest )
224
- args = parse_args( elements, rest )
225
- Functions.pair = [0, elements.size]
226
- results = []
227
- elements.each do |element|
228
- Functions.pair[0] += 1
229
- Functions.node = element
230
- res = Functions.send( fname, *args )
231
- case res
232
- when true
233
- results << element
234
- when Integer
235
- results << element if Functions.pair[0] == res
236
- end
237
- end
238
- results
239
- end
240
-
241
- def QuickPath::parse_args( element, string )
242
- # /.*?(?:\)|,)/
243
- arguments = []
244
- buffer = ""
245
- while string and string != ""
246
- c = string[0]
247
- string.sub!(/^./u, "")
248
- case c
249
- when ?,
250
- # if depth = 1, then we start a new argument
251
- arguments << evaluate( buffer )
252
- #arguments << evaluate( string[0..count] )
253
- when ?(
254
- # start a new method call
255
- function( element, buffer, string )
256
- buffer = ""
257
- when ?)
258
- # close the method call and return arguments
259
- return arguments
260
- else
261
- buffer << c
262
- end
263
- end
264
- ""
265
- end
266
- end
267
- end
File without changes
File without changes
File without changes