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.
- checksums.yaml +4 -4
- data/NEWS.md +304 -0
- data/doc/rexml/tasks/rdoc/child.rdoc +1 -1
- data/doc/rexml/tasks/rdoc/document.rdoc +1 -1
- data/doc/rexml/tasks/rdoc/element.rdoc +1 -1
- data/doc/rexml/tasks/rdoc/node.rdoc +1 -1
- data/doc/rexml/tasks/rdoc/parent.rdoc +1 -1
- data/doc/rexml/tutorial.rdoc +4 -2
- data/lib/rexml/attribute.rb +11 -2
- data/lib/rexml/cdata.rb +1 -1
- data/lib/rexml/comment.rb +1 -1
- data/lib/rexml/doctype.rb +21 -18
- data/lib/rexml/document.rb +6 -21
- data/lib/rexml/element.rb +164 -158
- data/lib/rexml/entity.rb +19 -10
- data/lib/rexml/formatters/default.rb +35 -19
- data/lib/rexml/formatters/pretty.rb +2 -3
- data/lib/rexml/functions.rb +164 -147
- data/lib/rexml/instruction.rb +3 -3
- data/lib/rexml/namespace.rb +9 -1
- data/lib/rexml/output.rb +1 -1
- data/lib/rexml/parent.rb +1 -3
- data/lib/rexml/parsers/baseparser.rb +60 -73
- data/lib/rexml/parsers/sax2parser.rb +9 -20
- data/lib/rexml/parsers/xpathparser.rb +87 -58
- data/lib/rexml/rexml.rb +2 -2
- data/lib/rexml/security.rb +6 -6
- data/lib/rexml/source.rb +9 -8
- data/lib/rexml/text.rb +39 -35
- data/lib/rexml/validation/relaxng.rb +11 -0
- data/lib/rexml/xmldecl.rb +2 -2
- data/lib/rexml/xmltokens.rb +8 -8
- data/lib/rexml/xpath.rb +0 -1
- data/lib/rexml/xpath_parser.rb +745 -467
- metadata +16 -17
- data/lib/rexml/quickpath.rb +0 -267
- /data/doc/rexml/tasks/{tocs → includes}/child_toc.rdoc +0 -0
- /data/doc/rexml/tasks/{tocs → includes}/document_toc.rdoc +0 -0
- /data/doc/rexml/tasks/{tocs → includes}/element_toc.rdoc +0 -0
- /data/doc/rexml/tasks/{tocs → includes}/node_toc.rdoc +0 -0
- /data/doc/rexml/tasks/{tocs → includes}/parent_toc.rdoc +0 -0
- /data/doc/rexml/tasks/{tocs/master_toc.rdoc → rdoc/toc.rdoc} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e63fbd7cc47fed19aaee9278bc7ba61055e3ea3af03f916ee7b0b537967b475d
|
|
4
|
+
data.tar.gz: 455047e0ada70e20e058910b59c138238c3a5ab04cab836e694ec8ae13f4c34c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7de76644ab3b5b5c05f087eb487b12090bf5c88a025dbe707eac273ca3647d0e03b411abced116a8608b24e92148abe25d44c9bc46a659d870275635cd09f3d3
|
|
7
|
+
data.tar.gz: d827b1e996ccb8d0a809ee521413d8457e8651d73750abe597b4d9a0dd3dc4234ab1dbe430aed1de8908c765c0bdf8658749432281095c7aa2b9b9fa647a9228
|
data/NEWS.md
CHANGED
|
@@ -1,5 +1,309 @@
|
|
|
1
1
|
# News
|
|
2
2
|
|
|
3
|
+
## 3.4.5 - 2026-12-04 {#version-3-4-5}
|
|
4
|
+
|
|
5
|
+
### Incompatible changes
|
|
6
|
+
|
|
7
|
+
* Dropped support for Ruby 2.5 (Ruby 2.6 or later is now required)
|
|
8
|
+
* GH-271
|
|
9
|
+
* GH-347
|
|
10
|
+
* Patch by NAITOH Jun
|
|
11
|
+
* Reported by pboling
|
|
12
|
+
|
|
13
|
+
* Removed unused `REXML::QuickPath` (`rexml/quickpath`)
|
|
14
|
+
* GH-250
|
|
15
|
+
* GH-362
|
|
16
|
+
* Patch by Sutou Kouhei
|
|
17
|
+
* Reported by NAITOH Jun
|
|
18
|
+
|
|
19
|
+
* Changed `REXML::Functions` to a `REXML::FunctionsClass` instance for thread safety and removed unused `REXML::Functions.text`, `.processing_instruction`, `.variables`, and `.namespace_context`
|
|
20
|
+
* GH-327
|
|
21
|
+
* GH-329
|
|
22
|
+
* GH-368
|
|
23
|
+
* Patch by tomoya ishida
|
|
24
|
+
|
|
25
|
+
* Switched available XPath function checks from a denylist to an allowlist
|
|
26
|
+
* Monkey-patching custom XPath functions onto `REXML::Functions` is no longer supported
|
|
27
|
+
* GH-369
|
|
28
|
+
* Patch by tomoya ishida, Sutou Kouhei
|
|
29
|
+
|
|
30
|
+
* Stopped falling back to `XPath.match` for unregistered XPath functions in `FunctionsClass#send` (now returns `[]`)
|
|
31
|
+
* GH-364
|
|
32
|
+
* Patch by tomoya ishida
|
|
33
|
+
|
|
34
|
+
* Changed XPath to always return node-sets in document order
|
|
35
|
+
* Changes the returned order of `XPath.match` / `XPath.first` for reverse axes such as `ancestor::` and `preceding::` to match the XPath 1.0 specification
|
|
36
|
+
* GH-319
|
|
37
|
+
* GH-320
|
|
38
|
+
* GH-356
|
|
39
|
+
* Patch by tomoya ishida, NAITOH Jun
|
|
40
|
+
* Reported by tomoya ishida
|
|
41
|
+
|
|
42
|
+
* Stopped matching prefixed attributes by their local name only
|
|
43
|
+
* `Attributes#[]`, `#get_attribute`, and `Element#attribute` no longer return `x:b` for `"b"`; use the qualified name (`"x:b"`) or a namespace
|
|
44
|
+
* `Attributes#keys` now returns qualified names (e.g. `"xmlns:x"`, `"x:b"`)
|
|
45
|
+
* GH-335
|
|
46
|
+
* Patch by tomoya ishida
|
|
47
|
+
|
|
48
|
+
* Validated XPath variable values and fixed `id()` return value
|
|
49
|
+
* Unsupported variable value types now raise `TypeError`, predicates on non-nodeset variables return `[]`, and unimplemented `id()` returns `[]` instead of `nil`
|
|
50
|
+
* GH-15
|
|
51
|
+
* GH-342
|
|
52
|
+
* Patch by tomoya ishida
|
|
53
|
+
* Reported by Sutou Kouhei
|
|
54
|
+
|
|
55
|
+
* Removed non-working XPath `namespace::` axis handling
|
|
56
|
+
* Emits a warning and returns `[]` instead of raising `NoMethodError`
|
|
57
|
+
* GH-323
|
|
58
|
+
* Patch by tomoya ishida
|
|
59
|
+
|
|
60
|
+
* Changed XPath `mod` operator to use truncating remainder (`Numeric#remainder`) and return `NaN` for `mod 0`
|
|
61
|
+
* Matches XPath 1.0 for negative operands and no longer raises `ZeroDivisionError` for a zero divisor
|
|
62
|
+
* GH-385
|
|
63
|
+
* GH-386
|
|
64
|
+
* Patch by Sourya Singh
|
|
65
|
+
* Reported by bardrop
|
|
66
|
+
|
|
67
|
+
* Returned `Infinity` / `NaN` from XPath `string()`, `floor()`, and `ceiling()` instead of raising `FloatDomainError`
|
|
68
|
+
* GH-374
|
|
69
|
+
* Patch by KBS
|
|
70
|
+
|
|
71
|
+
### Improvements
|
|
72
|
+
|
|
73
|
+
* Improved performance
|
|
74
|
+
* GH-299
|
|
75
|
+
* GH-300
|
|
76
|
+
* GH-303
|
|
77
|
+
* GH-310
|
|
78
|
+
* GH-311
|
|
79
|
+
* GH-313
|
|
80
|
+
* GH-315
|
|
81
|
+
* GH-325
|
|
82
|
+
* GH-330
|
|
83
|
+
* GH-333
|
|
84
|
+
* GH-339
|
|
85
|
+
* GH-341
|
|
86
|
+
* GH-359
|
|
87
|
+
* GH-391
|
|
88
|
+
* Patch by NAITOH Jun, tomoya ishida, Gal Be
|
|
89
|
+
|
|
90
|
+
* Made REXML Ractor-compatible
|
|
91
|
+
* GH-344
|
|
92
|
+
* Patch by John Hawthorn
|
|
93
|
+
|
|
94
|
+
* Deprecated unused `REXML::Text.read_with_substitution` (use `REXML::Text.unnormalize` instead)
|
|
95
|
+
* GH-363
|
|
96
|
+
* Patch by Sutou Kouhei
|
|
97
|
+
|
|
98
|
+
* Supported parenthesized XPath expressions and `abbreviate` of parentheses
|
|
99
|
+
* GH-316
|
|
100
|
+
* GH-317
|
|
101
|
+
* GH-322
|
|
102
|
+
* GH-328
|
|
103
|
+
* Patch by tomoya ishida
|
|
104
|
+
* Reported by tomoya ishida
|
|
105
|
+
|
|
106
|
+
* Supported `string-length()` XPath function without an argument
|
|
107
|
+
* GH-337
|
|
108
|
+
* Patch by Sai Asish Y
|
|
109
|
+
|
|
110
|
+
* Accepted processing instructions in the internal DTD subset
|
|
111
|
+
* GH-377
|
|
112
|
+
* Patch by Wleeaf
|
|
113
|
+
|
|
114
|
+
* Accepted non-ASCII names, combining characters, and extenders in DOCTYPE, processing instructions, DTD declarations, elements, and attributes
|
|
115
|
+
* GH-378
|
|
116
|
+
* GH-379
|
|
117
|
+
* Patch by Wleeaf
|
|
118
|
+
|
|
119
|
+
* Accepted any XML whitespace around XPath operators `and`, `or`, `div`, and `mod`
|
|
120
|
+
* GH-399
|
|
121
|
+
* Patch by Moksh Upadhyay
|
|
122
|
+
|
|
123
|
+
* Rejected underscored XPath function names (e.g. `local_name()`) in strict mode (default mode keeps the alias for backward compatibility)
|
|
124
|
+
* GH-352
|
|
125
|
+
* GH-366
|
|
126
|
+
* Patch by JinHyuk Sung
|
|
127
|
+
* Reported by tomoya ishida
|
|
128
|
+
|
|
129
|
+
* Improved documentation
|
|
130
|
+
* GH-151
|
|
131
|
+
* GH-307
|
|
132
|
+
* GH-308
|
|
133
|
+
* GH-348
|
|
134
|
+
* GH-360
|
|
135
|
+
* GH-367
|
|
136
|
+
* Patch by Burdette Lamar, NAITOH Jun
|
|
137
|
+
* Reported by Hiroya Fujinami
|
|
138
|
+
|
|
139
|
+
### Fixes
|
|
140
|
+
|
|
141
|
+
* Fixed an issue when executing `REXML::Parsers::SAX2Parser#parse` without specifying `#listen`
|
|
142
|
+
* GH-302
|
|
143
|
+
* Patch by NAITOH Jun
|
|
144
|
+
|
|
145
|
+
* Fixed infinite entity expansion by detecting circular references
|
|
146
|
+
* Circular entity references now raise `REXML::ParseException` instead of `SystemStackError`
|
|
147
|
+
* GH-312
|
|
148
|
+
* Patch by NAITOH Jun
|
|
149
|
+
|
|
150
|
+
* Fixed parsing XPath expressions with string literals containing parentheses and brackets
|
|
151
|
+
* GH-318
|
|
152
|
+
* Patch by tomoya ishida
|
|
153
|
+
|
|
154
|
+
* Fixed XPath `normalize-space()` function
|
|
155
|
+
* GH-324
|
|
156
|
+
* Patch by tomoya ishida
|
|
157
|
+
|
|
158
|
+
* Fixed XPath functions not to return a primitive value wrapped in an array
|
|
159
|
+
* GH-326
|
|
160
|
+
* Patch by tomoya ishida
|
|
161
|
+
|
|
162
|
+
* Fixed XPath `self` axis nodeset position
|
|
163
|
+
* GH-336
|
|
164
|
+
* Patch by tomoya ishida
|
|
165
|
+
|
|
166
|
+
* Fixed `XMLDecl` being included in XPath `descendant::node()` results
|
|
167
|
+
* GH-331
|
|
168
|
+
* GH-341
|
|
169
|
+
* Patch by tomoya ishida
|
|
170
|
+
* Reported by tomoya ishida
|
|
171
|
+
|
|
172
|
+
* Fixed XPath name functions (`name()`, `local-name()`, `namespace-uri()`)
|
|
173
|
+
* Uses the first node in document order without skipping unnamed nodes (e.g. `name(root/node())` returns `""` instead of `"node"` when a text node comes first)
|
|
174
|
+
* GH-343
|
|
175
|
+
* Patch by tomoya ishida, NAITOH Jun
|
|
176
|
+
|
|
177
|
+
* Fixed `substring-after()` XPath function not to use Regexp match
|
|
178
|
+
* GH-355
|
|
179
|
+
* Patch by Vít Ondruch
|
|
180
|
+
|
|
181
|
+
* Fixed `REXML::Element#attribute` when a namespace URI has multiple bindings
|
|
182
|
+
* GH-346
|
|
183
|
+
* GH-357
|
|
184
|
+
* Patch by JinHyuk Sung
|
|
185
|
+
* Reported by tomoya ishida
|
|
186
|
+
|
|
187
|
+
* Avoided stack exhaustion in `REXML::Formatters::Default#write_element` for deeply nested documents
|
|
188
|
+
* GH-354
|
|
189
|
+
* GH-358
|
|
190
|
+
* Patch by NAITOH Jun
|
|
191
|
+
* Reported by Brian
|
|
192
|
+
|
|
193
|
+
* Explicitly required `"set"` in `xpath_parser.rb`
|
|
194
|
+
* GH-361
|
|
195
|
+
* Patch by tomoya ishida
|
|
196
|
+
|
|
197
|
+
* Stopped substituting entities with an empty value
|
|
198
|
+
* Entities declared with an empty value are no longer inserted between every character during text/attribute normalization
|
|
199
|
+
* GH-370
|
|
200
|
+
* Patch by NAITOH Jun
|
|
201
|
+
|
|
202
|
+
* Fixed `REXML::Formatters::Pretty` mutating text nodes while pretty printing
|
|
203
|
+
* GH-371
|
|
204
|
+
* Patch by KBS
|
|
205
|
+
|
|
206
|
+
* Rejected invalid character references in entity expansion
|
|
207
|
+
* Invalid XML character references inside entity values now raise `REXML::ParseException`
|
|
208
|
+
* GH-372
|
|
209
|
+
* Patch by Sutou Kouhei
|
|
210
|
+
|
|
211
|
+
* Fixed XPath `lang()` not to match a language prefix that is not a sublanguage
|
|
212
|
+
* GH-373
|
|
213
|
+
* Patch by KBS
|
|
214
|
+
|
|
215
|
+
* Fixed RELAX NG validation of documents with XML declarations
|
|
216
|
+
* GH-241
|
|
217
|
+
* GH-380
|
|
218
|
+
* Patch by FFspiky
|
|
219
|
+
* Reported by gemmaro
|
|
220
|
+
|
|
221
|
+
* Fixed XPath `substring()` with a start before the first character and `round()` for negative halves
|
|
222
|
+
* e.g. `substring('12345', 0)` now returns `"12345"` instead of `"1234"`, and `round(-2.5)` returns `-2` instead of `-3`
|
|
223
|
+
* GH-382
|
|
224
|
+
* Patch by bardrop
|
|
225
|
+
|
|
226
|
+
* Fixed XPath comparisons between a node-set and a boolean, number, or string
|
|
227
|
+
* Fixes reversed relational operators when the node-set is on the right (e.g. `10 > @price`), boolean comparisons, and string comparisons
|
|
228
|
+
* GH-383
|
|
229
|
+
* Patch by bardrop
|
|
230
|
+
|
|
231
|
+
* Preserved whitespace before word operators after XPath predicates
|
|
232
|
+
* GH-384
|
|
233
|
+
* GH-387
|
|
234
|
+
* Patch by FFspiky
|
|
235
|
+
* Reported by bardrop
|
|
236
|
+
|
|
237
|
+
* Fixed XPath unary minus parsing with leading or separating spaces
|
|
238
|
+
* Unary minus without an operand (e.g. `"-"`, `" - - "`) now raises `REXML::ParseException`
|
|
239
|
+
* GH-393
|
|
240
|
+
* Patch by NAITOH Jun
|
|
241
|
+
|
|
242
|
+
* Renamed the XPath test fixture `xp.tst` to `xp.txt`
|
|
243
|
+
* GH-394
|
|
244
|
+
* Patch by botamochi0x12
|
|
245
|
+
|
|
246
|
+
* Formatted small floats without scientific notation in XPath `string()`
|
|
247
|
+
* e.g. `string(0.00001)` now returns `"0.00001"` instead of `"1.0e-05"`
|
|
248
|
+
* GH-395
|
|
249
|
+
* Patch by Moksh Upadhyay
|
|
250
|
+
|
|
251
|
+
* Fixed XPath parsing of expressions and literals containing line breaks
|
|
252
|
+
* GH-397
|
|
253
|
+
* Patch by Moksh Upadhyay
|
|
254
|
+
|
|
255
|
+
* Fixed XPath matching for the predefined `xml` namespace and empty strings
|
|
256
|
+
* GH-396
|
|
257
|
+
* GH-398
|
|
258
|
+
* Patch by Akshay Kumar Sharma
|
|
259
|
+
* Reported by Dickson Wu
|
|
260
|
+
|
|
261
|
+
### Thanks
|
|
262
|
+
|
|
263
|
+
* NAITOH Jun
|
|
264
|
+
|
|
265
|
+
* Sutou Kouhei
|
|
266
|
+
|
|
267
|
+
* tomoya ishida
|
|
268
|
+
|
|
269
|
+
* Burdette Lamar
|
|
270
|
+
|
|
271
|
+
* John Hawthorn
|
|
272
|
+
|
|
273
|
+
* Sai Asish Y
|
|
274
|
+
|
|
275
|
+
* Vít Ondruch
|
|
276
|
+
|
|
277
|
+
* JinHyuk Sung
|
|
278
|
+
|
|
279
|
+
* KBS
|
|
280
|
+
|
|
281
|
+
* Wleeaf
|
|
282
|
+
|
|
283
|
+
* FFspiky
|
|
284
|
+
|
|
285
|
+
* Sourya Singh
|
|
286
|
+
|
|
287
|
+
* Gal Be
|
|
288
|
+
|
|
289
|
+
* bardrop
|
|
290
|
+
|
|
291
|
+
* Moksh Upadhyay
|
|
292
|
+
|
|
293
|
+
* Akshay Kumar Sharma
|
|
294
|
+
|
|
295
|
+
* botamochi0x12
|
|
296
|
+
|
|
297
|
+
* Hiroya Fujinami
|
|
298
|
+
|
|
299
|
+
* Brian
|
|
300
|
+
|
|
301
|
+
* pboling
|
|
302
|
+
|
|
303
|
+
* gemmaro
|
|
304
|
+
|
|
305
|
+
* Dickson Wu
|
|
306
|
+
|
|
3
307
|
## 3.4.4 - 2025-09-10 {#version-3-4-4}
|
|
4
308
|
|
|
5
309
|
### Improvement
|
data/doc/rexml/tutorial.rdoc
CHANGED
|
@@ -113,7 +113,8 @@ An REXML::Document object represents an XML document.
|
|
|
113
113
|
The object inherits from its ancestor classes:
|
|
114
114
|
|
|
115
115
|
- REXML::Child (includes module REXML::Node)
|
|
116
|
-
- REXML::Parent
|
|
116
|
+
- REXML::Parent
|
|
117
|
+
(includes module {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]).
|
|
117
118
|
- REXML::Element (includes module REXML::Namespace).
|
|
118
119
|
- REXML::Document
|
|
119
120
|
|
|
@@ -302,7 +303,8 @@ An REXML::Element object represents an XML element.
|
|
|
302
303
|
The object inherits from its ancestor classes:
|
|
303
304
|
|
|
304
305
|
- REXML::Child (includes module REXML::Node)
|
|
305
|
-
- REXML::Parent
|
|
306
|
+
- REXML::Parent
|
|
307
|
+
(includes module {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]).
|
|
306
308
|
- REXML::Element (includes module REXML::Namespace).
|
|
307
309
|
|
|
308
310
|
This section covers methods:
|
data/lib/rexml/attribute.rb
CHANGED
|
@@ -176,11 +176,11 @@ module REXML
|
|
|
176
176
|
self
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
-
# Removes this Attribute from the tree
|
|
179
|
+
# Removes this Attribute from the tree
|
|
180
180
|
#
|
|
181
181
|
# This method is usually not called directly.
|
|
182
182
|
def remove
|
|
183
|
-
@element.attributes.delete self
|
|
183
|
+
@element.attributes.delete self unless @element.nil?
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
# Writes this attribute (EG, puts 'key="value"' to the output)
|
|
@@ -205,6 +205,15 @@ module REXML
|
|
|
205
205
|
def document
|
|
206
206
|
@element&.document
|
|
207
207
|
end
|
|
208
|
+
|
|
209
|
+
# Returns true if this attribute is a namespace declaration, false otherwise.
|
|
210
|
+
# "foo" => false
|
|
211
|
+
# "xmlns" => true
|
|
212
|
+
# "xmlns:foo" => true
|
|
213
|
+
# "foo:xmlns" => false
|
|
214
|
+
def namespace_declaration?
|
|
215
|
+
prefix == 'xmlns' || (prefix.empty? && name == 'xmlns')
|
|
216
|
+
end
|
|
208
217
|
end
|
|
209
218
|
end
|
|
210
219
|
#vim:ts=2 sw=2 noexpandtab:
|
data/lib/rexml/cdata.rb
CHANGED
data/lib/rexml/comment.rb
CHANGED
data/lib/rexml/doctype.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# frozen_string_literal:
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
require_relative "parent"
|
|
3
3
|
require_relative "parseexception"
|
|
4
4
|
require_relative "namespace"
|
|
@@ -59,7 +59,7 @@ module REXML
|
|
|
59
59
|
'lt'=>EntityConst::LT,
|
|
60
60
|
'quot'=>EntityConst::QUOT,
|
|
61
61
|
"apos"=>EntityConst::APOS
|
|
62
|
-
}
|
|
62
|
+
}.freeze
|
|
63
63
|
|
|
64
64
|
# name is the name of the doctype
|
|
65
65
|
# external_id is the referenced DTD, if given
|
|
@@ -113,23 +113,26 @@ module REXML
|
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
def attributes_of element
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
rv << Attribute.new(key,val)
|
|
120
|
-
end if child.kind_of? AttlistDecl and child.element_name == element
|
|
116
|
+
raw_attributes = _attlist_mappings[element] || {}
|
|
117
|
+
raw_attributes.map do |key, value|
|
|
118
|
+
Attribute.new(key, value)
|
|
121
119
|
end
|
|
122
|
-
rv
|
|
123
120
|
end
|
|
124
121
|
|
|
125
122
|
def attribute_of element, attribute
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
_attlist_mappings[element]&.[](attribute)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def _attlist_mappings # :nodoc:
|
|
127
|
+
mapping = {}
|
|
128
|
+
grep(AttlistDecl).each do |child|
|
|
129
|
+
raw_attributes = mapping[child.element_name] ||= {}
|
|
130
|
+
child.each do |key, val|
|
|
131
|
+
# First declaration wins
|
|
132
|
+
raw_attributes[key] = val unless raw_attributes.key? key
|
|
133
|
+
end
|
|
130
134
|
end
|
|
131
|
-
|
|
132
|
-
att_decl[attribute]
|
|
135
|
+
mapping
|
|
133
136
|
end
|
|
134
137
|
|
|
135
138
|
def clone
|
|
@@ -174,13 +177,13 @@ module REXML
|
|
|
174
177
|
@parent&.context
|
|
175
178
|
end
|
|
176
179
|
|
|
177
|
-
def entity( name )
|
|
178
|
-
@entities[name]&.unnormalized
|
|
180
|
+
def entity( name, expanding: nil )
|
|
181
|
+
@entities[name]&.unnormalized(expanding: expanding)
|
|
179
182
|
end
|
|
180
183
|
|
|
181
184
|
def add child
|
|
182
185
|
super(child)
|
|
183
|
-
@entities = DEFAULT_ENTITIES.
|
|
186
|
+
@entities = DEFAULT_ENTITIES.dup if @entities == DEFAULT_ENTITIES
|
|
184
187
|
@entities[ child.name ] = child if child.kind_of? Entity
|
|
185
188
|
end
|
|
186
189
|
|
|
@@ -285,7 +288,7 @@ module REXML
|
|
|
285
288
|
|
|
286
289
|
def to_s
|
|
287
290
|
context = parent&.context
|
|
288
|
-
notation = "<!NOTATION #{@name}"
|
|
291
|
+
notation = +"<!NOTATION #{@name}"
|
|
289
292
|
reference_writer = ReferenceWriter.new(@middle, @public, @system, context)
|
|
290
293
|
reference_writer.write(notation)
|
|
291
294
|
notation << ">"
|
data/lib/rexml/document.rb
CHANGED
|
@@ -28,9 +28,9 @@ module REXML
|
|
|
28
28
|
# If you're somewhat familiar with XML
|
|
29
29
|
# and have a particular task in mind,
|
|
30
30
|
# you may want to see the
|
|
31
|
-
# {tasks pages}[../doc/rexml/tasks/
|
|
31
|
+
# {tasks pages}[../doc/rexml/tasks/rdoc/toc_rdoc.html],
|
|
32
32
|
# and in particular, the
|
|
33
|
-
# {tasks
|
|
33
|
+
# {tasks for documents}[../doc/rexml/tasks/rdoc/toc_rdoc.html#label-Document].
|
|
34
34
|
#
|
|
35
35
|
class Document < Element
|
|
36
36
|
# A convenient default XML declaration. Use:
|
|
@@ -197,9 +197,8 @@ module REXML
|
|
|
197
197
|
end
|
|
198
198
|
child.parent = self
|
|
199
199
|
else
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
rv
|
|
200
|
+
raise "attempted adding second root element to document" if child.kind_of?(Element) && root
|
|
201
|
+
super
|
|
203
202
|
end
|
|
204
203
|
end
|
|
205
204
|
alias :<< :add
|
|
@@ -211,9 +210,8 @@ module REXML
|
|
|
211
210
|
#
|
|
212
211
|
# REXML::Element.add_element(name_or_element, attributes)
|
|
213
212
|
def add_element(arg=nil, arg2=nil)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
rv
|
|
213
|
+
raise "attempted adding second root element to document" if root
|
|
214
|
+
super
|
|
217
215
|
end
|
|
218
216
|
|
|
219
217
|
# :call-seq:
|
|
@@ -451,19 +449,6 @@ module REXML
|
|
|
451
449
|
|
|
452
450
|
private
|
|
453
451
|
|
|
454
|
-
attr_accessor :namespaces_cache
|
|
455
|
-
|
|
456
|
-
# New document level cache is created and available in this block.
|
|
457
|
-
# This API is thread unsafe. Users can't change this document in this block.
|
|
458
|
-
def enable_cache
|
|
459
|
-
@namespaces_cache = {}
|
|
460
|
-
begin
|
|
461
|
-
yield
|
|
462
|
-
ensure
|
|
463
|
-
@namespaces_cache = nil
|
|
464
|
-
end
|
|
465
|
-
end
|
|
466
|
-
|
|
467
452
|
def build( source )
|
|
468
453
|
Parsers::TreeParser.new( source, self ).parse
|
|
469
454
|
end
|