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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f7d0bba9d8346e2374abacaf7aea57044c66f368a695521bc16f6b07e31eaf
|
4
|
+
data.tar.gz: 674cf531dbe9684f3cc9945255aec412d0b80ae0117da3c57552c5ae3bbc66a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36c00f2e2c0ed931c85a0e0fb7720771d314f93fa1e66e1057b4e8fb7fe1d1bd3f50debdfa05587e511f1cad8d7345aa8066b18392554da6e8f6baad6a3b9d7
|
7
|
+
data.tar.gz: dc53db592782ad36f083493b8864d49872b8c989b9e2f5d9a1811d56fae3100cf2cad27bb4ab81b9d308715da523d0a4f71d4e236e5847d540d0e92a85c1bd20
|
data/NEWS.md
CHANGED
@@ -1,5 +1,107 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.4.2 - 2025-08-26 {#version-3-4-2}
|
4
|
+
|
5
|
+
### Improvement
|
6
|
+
|
7
|
+
* Improved performance.
|
8
|
+
* GH-244
|
9
|
+
* GH-245
|
10
|
+
* GH-246
|
11
|
+
* GH-249
|
12
|
+
* GH-256
|
13
|
+
* Patch by NAITOH Jun
|
14
|
+
|
15
|
+
* Raise appropriate exception when failing to match start tag in DOCTYPE
|
16
|
+
* GH-247
|
17
|
+
* Patch by NAITOH Jun
|
18
|
+
|
19
|
+
* Deprecate accepting array as an element in XPath.match, first and each
|
20
|
+
* GH-252
|
21
|
+
* Patch by tomoya ishida
|
22
|
+
|
23
|
+
* Don't call needless encoding_updated
|
24
|
+
* GH-259
|
25
|
+
* Patch by Sutou Kouhei
|
26
|
+
|
27
|
+
* Reuse XPath::match
|
28
|
+
* GH-263
|
29
|
+
* Patch by pboling
|
30
|
+
|
31
|
+
* Cache redundant calls for doctype
|
32
|
+
* GH-264
|
33
|
+
* Patch by pboling
|
34
|
+
|
35
|
+
* Use Safe Navigation (&.) from Ruby 2.3
|
36
|
+
* GH-265
|
37
|
+
* Patch by pboling
|
38
|
+
|
39
|
+
* Remove redundant return statements
|
40
|
+
* GH-266
|
41
|
+
* Patch by pboling
|
42
|
+
|
43
|
+
* Added XML declaration check & Source#skip_spaces method
|
44
|
+
* GH-282
|
45
|
+
* Patch by NAITOH Jun
|
46
|
+
* Reported by Sofi Aberegg
|
47
|
+
|
48
|
+
### Fixes
|
49
|
+
|
50
|
+
* Fix docs typo
|
51
|
+
* GH-248
|
52
|
+
* Patch by James Coleman
|
53
|
+
|
54
|
+
* Fix reverse sort in xpath_parser
|
55
|
+
* GH-251
|
56
|
+
* Patch by tomoya ishida
|
57
|
+
|
58
|
+
* Fix duplicate responses in XPath following, following-sibling, preceding, preceding-sibling
|
59
|
+
* GH-255
|
60
|
+
* Patch by NAITOH Jun
|
61
|
+
|
62
|
+
* Fix wrong Encoding resolution
|
63
|
+
* GH-258
|
64
|
+
* Patch by Sutou Kouhei
|
65
|
+
|
66
|
+
* Handle nil when parsing fragment
|
67
|
+
* GH-267
|
68
|
+
* GH-268
|
69
|
+
* Patch by pboling
|
70
|
+
|
71
|
+
* [Documentation] Use # to reference instance methods
|
72
|
+
* GH-269
|
73
|
+
* GH-270
|
74
|
+
* Patch by pboling
|
75
|
+
|
76
|
+
* Fix & Deprecate REXML::Text#text_indent
|
77
|
+
* GH-273
|
78
|
+
* GH-275
|
79
|
+
* Patch by pboling
|
80
|
+
|
81
|
+
* remove bundler from dev deps
|
82
|
+
* GH-276
|
83
|
+
* GH-277
|
84
|
+
* Patch by pboling
|
85
|
+
|
86
|
+
* remove ostruct from dev deps
|
87
|
+
* GH-280
|
88
|
+
* GH-281
|
89
|
+
* Patch by pboling
|
90
|
+
|
91
|
+
### Thanks
|
92
|
+
|
93
|
+
* NAITOH Jun
|
94
|
+
|
95
|
+
* tomoya ishida
|
96
|
+
|
97
|
+
* James Coleman
|
98
|
+
|
99
|
+
* pboling
|
100
|
+
|
101
|
+
* Sutou Kouhei
|
102
|
+
|
103
|
+
* Sofi Aberegg
|
104
|
+
|
3
105
|
## 3.4.1 - 2025-02-16 {#version-3-4-1}
|
4
106
|
|
5
107
|
### Improvement
|
@@ -386,7 +488,7 @@
|
|
386
488
|
|
387
489
|
* Patch by NAITOH Jun.
|
388
490
|
|
389
|
-
* Improved parse performance when an attribute has many
|
491
|
+
* Improved parse performance when an attribute has many `>`s.
|
390
492
|
|
391
493
|
* GH-126
|
392
494
|
|
data/lib/rexml/attribute.rb
CHANGED
@@ -130,10 +130,7 @@ module REXML
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def doctype
|
133
|
-
|
134
|
-
doc = @element.document
|
135
|
-
doc.doctype if doc
|
136
|
-
end
|
133
|
+
@element&.document&.doctype
|
137
134
|
end
|
138
135
|
|
139
136
|
# Returns the attribute value, with entities replaced
|
@@ -173,7 +170,7 @@ module REXML
|
|
173
170
|
@element = element
|
174
171
|
|
175
172
|
if @normalized
|
176
|
-
Text.check( @normalized, NEEDS_A_SECOND_CHECK
|
173
|
+
Text.check( @normalized, NEEDS_A_SECOND_CHECK )
|
177
174
|
end
|
178
175
|
|
179
176
|
self
|
@@ -202,9 +199,11 @@ module REXML
|
|
202
199
|
end
|
203
200
|
|
204
201
|
def xpath
|
205
|
-
|
206
|
-
|
207
|
-
|
202
|
+
@element.xpath + "/@#{self.expanded_name}"
|
203
|
+
end
|
204
|
+
|
205
|
+
def document
|
206
|
+
@element&.document
|
208
207
|
end
|
209
208
|
end
|
210
209
|
end
|
data/lib/rexml/cdata.rb
CHANGED
@@ -58,7 +58,7 @@ module REXML
|
|
58
58
|
# c = CData.new( " Some text " )
|
59
59
|
# c.write( $stdout ) #-> <![CDATA[ Some text ]]>
|
60
60
|
def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
|
61
|
-
Kernel.warn( "#{self.class.name}
|
61
|
+
Kernel.warn( "#{self.class.name}#write is deprecated", uplevel: 1)
|
62
62
|
indent( output, indent )
|
63
63
|
output << START
|
64
64
|
output << @string
|
data/lib/rexml/child.rb
CHANGED
@@ -83,13 +83,12 @@ module REXML
|
|
83
83
|
# Returns:: the document this child belongs to, or nil if this child
|
84
84
|
# belongs to no document
|
85
85
|
def document
|
86
|
-
|
87
|
-
nil
|
86
|
+
parent&.document
|
88
87
|
end
|
89
88
|
|
90
89
|
# This doesn't yet handle encodings
|
91
90
|
def bytes
|
92
|
-
document
|
91
|
+
document&.encoding
|
93
92
|
|
94
93
|
to_s
|
95
94
|
end
|
data/lib/rexml/comment.rb
CHANGED
@@ -48,7 +48,7 @@ module REXML
|
|
48
48
|
# ie_hack::
|
49
49
|
# Needed for conformity to the child API, but not used by this class.
|
50
50
|
def write( output, indent=-1, transitive=false, ie_hack=false )
|
51
|
-
Kernel.warn("
|
51
|
+
Kernel.warn("#{self.class.name}#write is deprecated. See REXML::Formatters", uplevel: 1)
|
52
52
|
indent( output, indent )
|
53
53
|
output << START
|
54
54
|
output << @string
|
data/lib/rexml/doctype.rb
CHANGED
@@ -171,15 +171,11 @@ module REXML
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def context
|
174
|
-
|
175
|
-
@parent.context
|
176
|
-
else
|
177
|
-
nil
|
178
|
-
end
|
174
|
+
@parent&.context
|
179
175
|
end
|
180
176
|
|
181
177
|
def entity( name )
|
182
|
-
@entities[name]
|
178
|
+
@entities[name]&.unnormalized
|
183
179
|
end
|
184
180
|
|
185
181
|
def add child
|
@@ -288,8 +284,7 @@ module REXML
|
|
288
284
|
end
|
289
285
|
|
290
286
|
def to_s
|
291
|
-
context =
|
292
|
-
context = parent.context if parent
|
287
|
+
context = parent&.context
|
293
288
|
notation = "<!NOTATION #{@name}"
|
294
289
|
reference_writer = ReferenceWriter.new(@middle, @public, @system, context)
|
295
290
|
reference_writer.write(notation)
|
data/lib/rexml/document.rb
CHANGED
@@ -309,8 +309,8 @@ module REXML
|
|
309
309
|
end
|
310
310
|
|
311
311
|
# :call-seq:
|
312
|
-
# doc.write(output=$stdout, indent=-1,
|
313
|
-
# doc.write(options={:output => $stdout, :indent => -1, :
|
312
|
+
# doc.write(output=$stdout, indent=-1, transitive=false, ie_hack=false, encoding=nil)
|
313
|
+
# doc.write(options={:output => $stdout, :indent => -1, :transitive => false, :ie_hack => false, :encoding => nil})
|
314
314
|
#
|
315
315
|
# Write the XML tree out, optionally with indent. This writes out the
|
316
316
|
# entire XML document, including XML declarations, doctype declarations,
|
@@ -415,7 +415,7 @@ module REXML
|
|
415
415
|
#
|
416
416
|
# Deprecated. Use REXML::Security.entity_expansion_limit= instead.
|
417
417
|
def Document::entity_expansion_limit
|
418
|
-
|
418
|
+
Security.entity_expansion_limit
|
419
419
|
end
|
420
420
|
|
421
421
|
# Set the entity expansion limit. By default the limit is set to 10240.
|
@@ -429,7 +429,7 @@ module REXML
|
|
429
429
|
#
|
430
430
|
# Deprecated. Use REXML::Security.entity_expansion_text_limit instead.
|
431
431
|
def Document::entity_expansion_text_limit
|
432
|
-
|
432
|
+
Security.entity_expansion_text_limit
|
433
433
|
end
|
434
434
|
|
435
435
|
attr_reader :entity_expansion_count
|
@@ -448,6 +448,20 @@ module REXML
|
|
448
448
|
end
|
449
449
|
|
450
450
|
private
|
451
|
+
|
452
|
+
attr_accessor :namespaces_cache
|
453
|
+
|
454
|
+
# New document level cache is created and available in this block.
|
455
|
+
# This API is thread unsafe. Users can't change this document in this block.
|
456
|
+
def enable_cache
|
457
|
+
@namespaces_cache = {}
|
458
|
+
begin
|
459
|
+
yield
|
460
|
+
ensure
|
461
|
+
@namespaces_cache = nil
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
451
465
|
def build( source )
|
452
466
|
Parsers::TreeParser.new( source, self ).parse
|
453
467
|
end
|
data/lib/rexml/element.rb
CHANGED
@@ -473,8 +473,7 @@ module REXML
|
|
473
473
|
# Related: #root, #root_node.
|
474
474
|
#
|
475
475
|
def document
|
476
|
-
|
477
|
-
rt.parent if rt
|
476
|
+
root&.parent
|
478
477
|
end
|
479
478
|
|
480
479
|
# :call-seq:
|
@@ -566,7 +565,7 @@ module REXML
|
|
566
565
|
prefixes = []
|
567
566
|
prefixes = parent.prefixes if parent
|
568
567
|
prefixes |= attributes.prefixes
|
569
|
-
|
568
|
+
prefixes
|
570
569
|
end
|
571
570
|
|
572
571
|
# :call-seq:
|
@@ -589,10 +588,12 @@ module REXML
|
|
589
588
|
# d.elements['//c'].namespaces # => {"x"=>"1", "y"=>"2", "z"=>"3"}
|
590
589
|
#
|
591
590
|
def namespaces
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
591
|
+
namespaces_cache = document&.__send__(:namespaces_cache)
|
592
|
+
if namespaces_cache
|
593
|
+
namespaces_cache[self] ||= calculate_namespaces
|
594
|
+
else
|
595
|
+
calculate_namespaces
|
596
|
+
end
|
596
597
|
end
|
597
598
|
|
598
599
|
# :call-seq:
|
@@ -619,19 +620,11 @@ module REXML
|
|
619
620
|
if prefix.nil?
|
620
621
|
prefix = prefix()
|
621
622
|
end
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
prefix = "xmlns:#{prefix}" unless prefix[0,5] == 'xmlns'
|
626
|
-
end
|
627
|
-
ns = nil
|
628
|
-
target = self
|
629
|
-
while ns.nil? and target
|
630
|
-
ns = target.attributes[prefix]
|
631
|
-
target = target.parent
|
632
|
-
end
|
623
|
+
prefix = (prefix == '') ? 'xmlns' : prefix.delete_prefix("xmlns:")
|
624
|
+
ns = namespaces[prefix]
|
625
|
+
|
633
626
|
ns = '' if ns.nil? and prefix == 'xmlns'
|
634
|
-
|
627
|
+
ns
|
635
628
|
end
|
636
629
|
|
637
630
|
# :call-seq:
|
@@ -963,7 +956,7 @@ module REXML
|
|
963
956
|
def next_element
|
964
957
|
element = next_sibling
|
965
958
|
element = element.next_sibling until element.nil? or element.kind_of? Element
|
966
|
-
|
959
|
+
element
|
967
960
|
end
|
968
961
|
|
969
962
|
# :call-seq:
|
@@ -979,7 +972,7 @@ module REXML
|
|
979
972
|
def previous_element
|
980
973
|
element = previous_sibling
|
981
974
|
element = element.previous_sibling until element.nil? or element.kind_of? Element
|
982
|
-
|
975
|
+
element
|
983
976
|
end
|
984
977
|
|
985
978
|
|
@@ -1029,8 +1022,7 @@ module REXML
|
|
1029
1022
|
#
|
1030
1023
|
def text( path = nil )
|
1031
1024
|
rv = get_text(path)
|
1032
|
-
|
1033
|
-
nil
|
1025
|
+
rv&.value
|
1034
1026
|
end
|
1035
1027
|
|
1036
1028
|
# :call-seq:
|
@@ -1058,7 +1050,7 @@ module REXML
|
|
1058
1050
|
else
|
1059
1051
|
rv = @children.find { |node| node.kind_of? Text }
|
1060
1052
|
end
|
1061
|
-
|
1053
|
+
rv
|
1062
1054
|
end
|
1063
1055
|
|
1064
1056
|
# :call-seq:
|
@@ -1102,7 +1094,7 @@ module REXML
|
|
1102
1094
|
old_text.replace_with( text )
|
1103
1095
|
end
|
1104
1096
|
end
|
1105
|
-
|
1097
|
+
self
|
1106
1098
|
end
|
1107
1099
|
|
1108
1100
|
# :call-seq:
|
@@ -1153,7 +1145,7 @@ module REXML
|
|
1153
1145
|
text = Text.new( text, whitespace(), nil, raw() )
|
1154
1146
|
end
|
1155
1147
|
self << text unless text.nil?
|
1156
|
-
|
1148
|
+
self
|
1157
1149
|
end
|
1158
1150
|
|
1159
1151
|
# :call-seq:
|
@@ -1197,7 +1189,7 @@ module REXML
|
|
1197
1189
|
cur = cur.parent
|
1198
1190
|
path_elements << __to_xpath_helper( cur )
|
1199
1191
|
end
|
1200
|
-
|
1192
|
+
path_elements.reverse.join( "/" )
|
1201
1193
|
end
|
1202
1194
|
|
1203
1195
|
#################################################
|
@@ -1299,7 +1291,6 @@ module REXML
|
|
1299
1291
|
return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] )
|
1300
1292
|
|
1301
1293
|
attributes.get_attribute( name )
|
1302
|
-
|
1303
1294
|
end
|
1304
1295
|
|
1305
1296
|
# :call-seq:
|
@@ -1313,7 +1304,7 @@ module REXML
|
|
1313
1304
|
# b.has_attributes? # => false
|
1314
1305
|
#
|
1315
1306
|
def has_attributes?
|
1316
|
-
|
1307
|
+
!@attributes.empty?
|
1317
1308
|
end
|
1318
1309
|
|
1319
1310
|
# :call-seq:
|
@@ -1502,7 +1493,7 @@ module REXML
|
|
1502
1493
|
# doc.write( out ) #-> doc is written to the string 'out'
|
1503
1494
|
# doc.write( $stdout ) #-> doc written to the console
|
1504
1495
|
def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
|
1505
|
-
Kernel.warn("#{self.class.name}
|
1496
|
+
Kernel.warn("#{self.class.name}#write is deprecated. See REXML::Formatters", uplevel: 1)
|
1506
1497
|
formatter = if indent > -1
|
1507
1498
|
if transitive
|
1508
1499
|
require_relative "formatters/transitive"
|
@@ -1516,8 +1507,15 @@ module REXML
|
|
1516
1507
|
formatter.write( self, output )
|
1517
1508
|
end
|
1518
1509
|
|
1519
|
-
|
1520
1510
|
private
|
1511
|
+
def calculate_namespaces
|
1512
|
+
if parent
|
1513
|
+
parent.namespaces.merge(attributes.namespaces)
|
1514
|
+
else
|
1515
|
+
attributes.namespaces
|
1516
|
+
end
|
1517
|
+
end
|
1518
|
+
|
1521
1519
|
def __to_xpath_helper node
|
1522
1520
|
rv = node.expanded_name.clone
|
1523
1521
|
if node.parent
|
@@ -1684,11 +1682,7 @@ module REXML
|
|
1684
1682
|
(num += 1) == index
|
1685
1683
|
}
|
1686
1684
|
else
|
1687
|
-
|
1688
|
-
#{ |element|
|
1689
|
-
# return element if element.kind_of? Element
|
1690
|
-
#}
|
1691
|
-
#return nil
|
1685
|
+
XPath::first( @element, index )
|
1692
1686
|
end
|
1693
1687
|
end
|
1694
1688
|
|
@@ -1735,7 +1729,7 @@ module REXML
|
|
1735
1729
|
else
|
1736
1730
|
previous.replace_with element
|
1737
1731
|
end
|
1738
|
-
|
1732
|
+
previous
|
1739
1733
|
end
|
1740
1734
|
|
1741
1735
|
# :call-seq:
|
@@ -1774,7 +1768,7 @@ module REXML
|
|
1774
1768
|
child == element
|
1775
1769
|
end
|
1776
1770
|
return rv if found == element
|
1777
|
-
|
1771
|
+
-1
|
1778
1772
|
end
|
1779
1773
|
|
1780
1774
|
# :call-seq:
|
@@ -1853,7 +1847,7 @@ module REXML
|
|
1853
1847
|
@element.delete element
|
1854
1848
|
element.remove
|
1855
1849
|
end
|
1856
|
-
|
1850
|
+
rv
|
1857
1851
|
end
|
1858
1852
|
|
1859
1853
|
# :call-seq:
|
@@ -2180,8 +2174,7 @@ module REXML
|
|
2180
2174
|
#
|
2181
2175
|
def [](name)
|
2182
2176
|
attr = get_attribute(name)
|
2183
|
-
|
2184
|
-
return nil
|
2177
|
+
attr&.value
|
2185
2178
|
end
|
2186
2179
|
|
2187
2180
|
# :call-seq:
|
@@ -2324,11 +2317,11 @@ module REXML
|
|
2324
2317
|
return attr
|
2325
2318
|
end
|
2326
2319
|
end
|
2327
|
-
|
2328
|
-
if
|
2320
|
+
doctype = @element.document&.doctype
|
2321
|
+
if doctype
|
2329
2322
|
expn = @element.expanded_name
|
2330
|
-
expn =
|
2331
|
-
attr_val =
|
2323
|
+
expn = doctype.name if expn.size == 0
|
2324
|
+
attr_val = doctype.attribute_of(expn, name)
|
2332
2325
|
return Attribute.new( name, attr_val ) if attr_val
|
2333
2326
|
end
|
2334
2327
|
return nil
|
@@ -2336,7 +2329,7 @@ module REXML
|
|
2336
2329
|
if attr.kind_of? Hash
|
2337
2330
|
attr = attr[ @element.prefix ]
|
2338
2331
|
end
|
2339
|
-
|
2332
|
+
attr
|
2340
2333
|
end
|
2341
2334
|
|
2342
2335
|
# :call-seq:
|
@@ -2370,8 +2363,9 @@ module REXML
|
|
2370
2363
|
end
|
2371
2364
|
|
2372
2365
|
unless value.kind_of? Attribute
|
2373
|
-
|
2374
|
-
|
2366
|
+
doctype = @element.document&.doctype
|
2367
|
+
if doctype
|
2368
|
+
value = Text::normalize( value, doctype )
|
2375
2369
|
else
|
2376
2370
|
value = Text::normalize( value, nil )
|
2377
2371
|
end
|
@@ -2389,7 +2383,7 @@ module REXML
|
|
2389
2383
|
else
|
2390
2384
|
store value.name, value
|
2391
2385
|
end
|
2392
|
-
|
2386
|
+
@element
|
2393
2387
|
end
|
2394
2388
|
|
2395
2389
|
# :call-seq:
|
@@ -2408,10 +2402,11 @@ module REXML
|
|
2408
2402
|
each_attribute do |attribute|
|
2409
2403
|
ns << attribute.name if attribute.prefix == 'xmlns'
|
2410
2404
|
end
|
2411
|
-
|
2405
|
+
doctype = @element.document&.doctype
|
2406
|
+
if doctype
|
2412
2407
|
expn = @element.expanded_name
|
2413
|
-
expn =
|
2414
|
-
|
2408
|
+
expn = doctype.name if expn.size == 0
|
2409
|
+
doctype.attributes_of(expn).each {
|
2415
2410
|
|attribute|
|
2416
2411
|
ns << attribute.name if attribute.prefix == 'xmlns'
|
2417
2412
|
}
|
@@ -2433,10 +2428,11 @@ module REXML
|
|
2433
2428
|
each_attribute do |attribute|
|
2434
2429
|
namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
|
2435
2430
|
end
|
2436
|
-
|
2431
|
+
doctype = @element.document&.doctype
|
2432
|
+
if doctype
|
2437
2433
|
expn = @element.expanded_name
|
2438
|
-
expn =
|
2439
|
-
|
2434
|
+
expn = doctype.name if expn.size == 0
|
2435
|
+
doctype.attributes_of(expn).each {
|
2440
2436
|
|attribute|
|
2441
2437
|
namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
|
2442
2438
|
}
|
@@ -2491,9 +2487,7 @@ module REXML
|
|
2491
2487
|
old.each_value{|v| repl = v}
|
2492
2488
|
store name, repl
|
2493
2489
|
end
|
2494
|
-
elsif old
|
2495
|
-
return @element
|
2496
|
-
else # the supplied attribute is a top-level one
|
2490
|
+
elsif old # the supplied attribute is a top-level one
|
2497
2491
|
super(name)
|
2498
2492
|
end
|
2499
2493
|
@element
|
@@ -2547,7 +2541,7 @@ module REXML
|
|
2547
2541
|
rv << attribute if attribute.expanded_name == name
|
2548
2542
|
}
|
2549
2543
|
rv.each{ |attr| attr.remove }
|
2550
|
-
|
2544
|
+
rv
|
2551
2545
|
end
|
2552
2546
|
|
2553
2547
|
# :call-seq:
|
data/lib/rexml/encoding.rb
CHANGED
@@ -5,7 +5,7 @@ module REXML
|
|
5
5
|
# ID ---> Encoding name
|
6
6
|
attr_reader :encoding
|
7
7
|
def encoding=(encoding)
|
8
|
-
encoding = encoding.name if encoding.is_a?(Encoding)
|
8
|
+
encoding = encoding.name if encoding.is_a?(::Encoding)
|
9
9
|
if encoding.is_a?(String)
|
10
10
|
original_encoding = encoding
|
11
11
|
encoding = find_encoding(encoding)
|
@@ -13,12 +13,9 @@ module REXML
|
|
13
13
|
raise ArgumentError, "Bad encoding name #{original_encoding}"
|
14
14
|
end
|
15
15
|
end
|
16
|
+
encoding = encoding.upcase if encoding
|
16
17
|
return false if defined?(@encoding) and encoding == @encoding
|
17
|
-
|
18
|
-
@encoding = encoding.upcase
|
19
|
-
else
|
20
|
-
@encoding = 'UTF-8'
|
21
|
-
end
|
18
|
+
@encoding = encoding || "UTF-8"
|
22
19
|
true
|
23
20
|
end
|
24
21
|
|
data/lib/rexml/functions.rb
CHANGED
@@ -39,11 +39,11 @@ module REXML
|
|
39
39
|
|
40
40
|
def Functions::text( )
|
41
41
|
if @@context[:node].node_type == :element
|
42
|
-
|
42
|
+
@@context[:node].find_all{|n| n.node_type == :text}.collect{|n| n.value}
|
43
43
|
elsif @@context[:node].node_type == :text
|
44
|
-
|
44
|
+
@@context[:node].value
|
45
45
|
else
|
46
|
-
|
46
|
+
false
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
data/lib/rexml/instruction.rb
CHANGED
@@ -49,7 +49,7 @@ module REXML
|
|
49
49
|
# See the rexml/formatters package
|
50
50
|
#
|
51
51
|
def write writer, indent=-1, transitive=false, ie_hack=false
|
52
|
-
Kernel.warn( "#{self.class.name}
|
52
|
+
Kernel.warn( "#{self.class.name}#write is deprecated", uplevel: 1)
|
53
53
|
indent(writer, indent)
|
54
54
|
writer << START
|
55
55
|
writer << @target
|
data/lib/rexml/namespace.rb
CHANGED
@@ -42,11 +42,11 @@ module REXML
|
|
42
42
|
# Compares names optionally WITH namespaces
|
43
43
|
def has_name?( other, ns=nil )
|
44
44
|
if ns
|
45
|
-
|
45
|
+
namespace() == ns and name() == other
|
46
46
|
elsif other.include? ":"
|
47
|
-
|
47
|
+
fully_expanded_name == other
|
48
48
|
else
|
49
|
-
|
49
|
+
name == other
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -57,7 +57,7 @@ module REXML
|
|
57
57
|
def fully_expanded_name
|
58
58
|
ns = prefix
|
59
59
|
return "#{ns}:#@name" if ns.size > 0
|
60
|
-
|
60
|
+
@name
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/rexml/node.rb
CHANGED
@@ -26,7 +26,7 @@ module REXML
|
|
26
26
|
# REXML::Formatters package for changing the output style.
|
27
27
|
def to_s indent=nil
|
28
28
|
unless indent.nil?
|
29
|
-
Kernel.warn( "#{self.class.name}
|
29
|
+
Kernel.warn( "#{self.class.name}#to_s(indent) parameter is deprecated", uplevel: 1)
|
30
30
|
f = REXML::Formatters::Pretty.new( indent )
|
31
31
|
f.write( self, rv = "" )
|
32
32
|
else
|
@@ -68,7 +68,7 @@ module REXML
|
|
68
68
|
each_recursive {|node|
|
69
69
|
return node if block.call(node)
|
70
70
|
}
|
71
|
-
|
71
|
+
nil
|
72
72
|
end
|
73
73
|
|
74
74
|
# Returns the position that +self+ holds in its parent's array, indexed
|