ruby-paseto 0.1.1 → 0.2.0

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/README.md +55 -50
  4. data/lib/paseto/asn1/ecdsa_signature.rb +2 -2
  5. data/lib/paseto/asymmetric_key.rb +7 -4
  6. data/lib/paseto/configuration/decode_configuration.rb +7 -7
  7. data/lib/paseto/interface/key.rb +5 -2
  8. data/lib/paseto/interface/pbkd.rb +4 -20
  9. data/lib/paseto/interface/pie.rb +5 -26
  10. data/lib/paseto/interface/pke.rb +15 -51
  11. data/lib/paseto/interface/version.rb +30 -117
  12. data/lib/paseto/operations/id/i_dv3.rb +1 -1
  13. data/lib/paseto/operations/id/i_dv4.rb +1 -1
  14. data/lib/paseto/operations/pbkd/p_b_k_dv3.rb +4 -5
  15. data/lib/paseto/operations/pbkd/p_b_k_dv4.rb +3 -4
  16. data/lib/paseto/operations/pbkw.rb +6 -6
  17. data/lib/paseto/operations/pke/p_k_ev3.rb +23 -25
  18. data/lib/paseto/operations/pke/p_k_ev4.rb +33 -34
  19. data/lib/paseto/operations/pke.rb +9 -10
  20. data/lib/paseto/operations/wrap.rb +1 -1
  21. data/lib/paseto/paserk.rb +1 -1
  22. data/lib/paseto/paserk_types.rb +3 -3
  23. data/lib/paseto/protocol/version3.rb +17 -16
  24. data/lib/paseto/protocol/version4.rb +17 -16
  25. data/lib/paseto/symmetric_key.rb +16 -10
  26. data/lib/paseto/token.rb +17 -15
  27. data/lib/paseto/token_types.rb +2 -2
  28. data/lib/paseto/util.rb +2 -3
  29. data/lib/paseto/v3/local.rb +1 -1
  30. data/lib/paseto/v3/public.rb +8 -69
  31. data/lib/paseto/v4/local.rb +3 -3
  32. data/lib/paseto/v4/public.rb +3 -6
  33. data/lib/paseto/validator.rb +1 -1
  34. data/lib/paseto/version.rb +1 -1
  35. data/lib/paseto/versions.rb +2 -2
  36. data/lib/paseto/wrappers/pie/pie_v3.rb +18 -21
  37. data/lib/paseto/wrappers/pie/pie_v4.rb +17 -20
  38. data/lib/paseto/wrappers/pie.rb +3 -17
  39. data/lib/paseto.rb +2 -5
  40. data/paseto.gemspec +5 -17
  41. data/sorbet/rbi/annotations/.gitattributes +1 -0
  42. data/sorbet/rbi/annotations/rainbow.rbi +4 -4
  43. data/sorbet/rbi/gems/.gitattributes +1 -0
  44. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1 -1
  45. data/sorbet/rbi/gems/docile@1.4.0.rbi +1 -1
  46. data/sorbet/rbi/gems/{ffi@1.15.5.rbi → ffi@1.16.3.rbi} +260 -117
  47. data/sorbet/rbi/gems/{oj@3.13.23.rbi → oj@3.16.1.rbi} +28 -37
  48. data/sorbet/rbi/gems/{rake@13.0.6.rbi → rake@13.1.0.rbi} +75 -69
  49. data/sorbet/rbi/gems/rbnacl@7.1.1.rbi +2 -2
  50. data/sorbet/rbi/gems/{rspec-core@3.12.0.rbi → rspec-core@3.12.2.rbi} +31 -113
  51. data/sorbet/rbi/gems/{rspec-expectations@3.12.0.rbi → rspec-expectations@3.12.3.rbi} +204 -194
  52. data/sorbet/rbi/gems/{rspec-mocks@3.12.0.rbi → rspec-mocks@3.12.6.rbi} +225 -215
  53. data/sorbet/rbi/gems/{rspec-support@3.12.0.rbi → rspec-support@3.12.1.rbi} +35 -43
  54. data/sorbet/rbi/gems/rspec@3.12.0.rbi +22 -28
  55. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +41 -44
  56. data/sorbet/rbi/gems/{simplecov@0.21.2.rbi → simplecov@0.22.0.rbi} +62 -49
  57. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +232 -2
  58. data/sorbet/rbi/gems/{timecop@0.9.6.rbi → timecop@0.9.8.rbi} +13 -16
  59. data/sorbet/rbi/shims/multi_json.rbi +2 -0
  60. data/sorbet/rbi/shims/openssl.rbi +0 -8
  61. data/sorbet/rbi/todo.rbi +5 -1
  62. data/sorbet/tapioca/config.yml +1 -1
  63. metadata +20 -191
  64. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -584
  65. data/sorbet/rbi/gems/io-console@0.5.11.rbi +0 -8
  66. data/sorbet/rbi/gems/irb@1.5.1.rbi +0 -342
  67. data/sorbet/rbi/gems/json@2.6.3.rbi +0 -1541
  68. data/sorbet/rbi/gems/multi_json@1.15.0.rbi +0 -267
  69. data/sorbet/rbi/gems/netrc@0.11.0.rbi +0 -158
  70. data/sorbet/rbi/gems/openssl@3.0.1.rbi +0 -1735
  71. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -277
  72. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -407
  73. data/sorbet/rbi/gems/regexp_parser@2.6.1.rbi +0 -3481
  74. data/sorbet/rbi/gems/reline@0.3.1.rbi +0 -8
  75. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -4717
  76. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -1239
  77. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -3956
  78. data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +0 -48
  79. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -2555
  80. data/sorbet/rbi/gems/yard-sorbet@0.7.0.rbi +0 -391
  81. data/sorbet/rbi/gems/yard@0.9.28.rbi +0 -17816
  82. data/sorbet/rbi/gems/zeitwerk@2.6.6.rbi +0 -950
@@ -1,4717 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `rexml` gem.
5
- # Please instead update this file by running `bin/tapioca gem rexml`.
6
-
7
- # This class needs:
8
- # * Documentation
9
- # * Work! Not all types of attlists are intelligently parsed, so we just
10
- # spew back out what we get in. This works, but it would be better if
11
- # we formatted the output ourselves.
12
- #
13
- # AttlistDecls provide *just* enough support to allow namespace
14
- # declarations. If you need some sort of generalized support, or have an
15
- # interesting idea about how to map the hideous, terrible design of DTD
16
- # AttlistDecls onto an intuitive Ruby interface, let me know. I'm desperate
17
- # for anything to make DTDs more palateable.
18
- #
19
- # source://rexml//lib/rexml/attlistdecl.rb#18
20
- class REXML::AttlistDecl < ::REXML::Child
21
- include ::Enumerable
22
-
23
- # Create an AttlistDecl, pulling the information from a Source. Notice
24
- # that this isn't very convenient; to create an AttlistDecl, you basically
25
- # have to format it yourself, and then have the initializer parse it.
26
- # Sorry, but for the foreseeable future, DTD support in REXML is pretty
27
- # weak on convenience. Have I mentioned how much I hate DTDs?
28
- #
29
- # @return [AttlistDecl] a new instance of AttlistDecl
30
- #
31
- # source://rexml//lib/rexml/attlistdecl.rb#29
32
- def initialize(source); end
33
-
34
- # Access the attlist attribute/value pairs.
35
- # value = attlist_decl[ attribute_name ]
36
- #
37
- # source://rexml//lib/rexml/attlistdecl.rb#38
38
- def [](key); end
39
-
40
- # Iterate over the key/value pairs:
41
- # attlist_decl.each { |attribute_name, attribute_value| ... }
42
- #
43
- # source://rexml//lib/rexml/attlistdecl.rb#50
44
- def each(&block); end
45
-
46
- # What is this? Got me.
47
- #
48
- # source://rexml//lib/rexml/attlistdecl.rb#22
49
- def element_name; end
50
-
51
- # Whether an attlist declaration includes the given attribute definition
52
- # if attlist_decl.include? "xmlns:foobar"
53
- #
54
- # @return [Boolean]
55
- #
56
- # source://rexml//lib/rexml/attlistdecl.rb#44
57
- def include?(key); end
58
-
59
- # source://rexml//lib/rexml/attlistdecl.rb#59
60
- def node_type; end
61
-
62
- # Write out exactly what we got in.
63
- #
64
- # source://rexml//lib/rexml/attlistdecl.rb#55
65
- def write(out, indent = T.unsafe(nil)); end
66
- end
67
-
68
- # Defines an Element Attribute; IE, a attribute=value pair, as in:
69
- # <element attribute="value"/>. Attributes can be in their own
70
- # namespaces. General users of REXML will not interact with the
71
- # Attribute class much.
72
- #
73
- # source://rexml//lib/rexml/attribute.rb#10
74
- class REXML::Attribute
75
- include ::REXML::Node
76
- include ::REXML::XMLTokens
77
- include ::REXML::Namespace
78
-
79
- # Constructor.
80
- # FIXME: The parser doesn't catch illegal characters in attributes
81
- #
82
- # first::
83
- # Either: an Attribute, which this new attribute will become a
84
- # clone of; or a String, which is the name of this attribute
85
- # second::
86
- # If +first+ is an Attribute, then this may be an Element, or nil.
87
- # If nil, then the Element parent of this attribute is the parent
88
- # of the +first+ Attribute. If the first argument is a String,
89
- # then this must also be a String, and is the content of the attribute.
90
- # If this is the content, it must be fully normalized (contain no
91
- # illegal characters).
92
- # parent::
93
- # Ignored unless +first+ is a String; otherwise, may be the Element
94
- # parent of this attribute, or nil.
95
- #
96
- #
97
- # Attribute.new( attribute_to_clone )
98
- # Attribute.new( attribute_to_clone, parent_element )
99
- # Attribute.new( "attr", "attr_value" )
100
- # Attribute.new( "attr", "attr_value", parent_element )
101
- #
102
- # @return [Attribute] a new instance of Attribute
103
- #
104
- # source://rexml//lib/rexml/attribute.rb#45
105
- def initialize(first, second = T.unsafe(nil), parent = T.unsafe(nil)); end
106
-
107
- # Returns true if other is an Attribute and has the same name and value,
108
- # false otherwise.
109
- #
110
- # source://rexml//lib/rexml/attribute.rb#109
111
- def ==(other); end
112
-
113
- # Returns a copy of this attribute
114
- #
115
- # source://rexml//lib/rexml/attribute.rb#158
116
- def clone; end
117
-
118
- # source://rexml//lib/rexml/attribute.rb#132
119
- def doctype; end
120
-
121
- # The element to which this attribute belongs
122
- #
123
- # source://rexml//lib/rexml/attribute.rb#15
124
- def element; end
125
-
126
- # Sets the element of which this object is an attribute. Normally, this
127
- # is not directly called.
128
- #
129
- # Returns this attribute
130
- #
131
- # source://rexml//lib/rexml/attribute.rb#166
132
- def element=(element); end
133
-
134
- # Creates (and returns) a hash from both the name and value
135
- #
136
- # source://rexml//lib/rexml/attribute.rb#114
137
- def hash; end
138
-
139
- # source://rexml//lib/rexml/attribute.rb#192
140
- def inspect; end
141
-
142
- # Returns the namespace URL, if defined, or nil otherwise
143
- #
144
- # e = Element.new("el")
145
- # e.add_namespace("ns", "http://url")
146
- # e.add_attribute("ns:a", "b")
147
- # e.add_attribute("nsx:a", "c")
148
- # e.attribute("ns:a").namespace # => "http://url"
149
- # e.attribute("nsx:a").namespace # => nil
150
- #
151
- # This method always returns "" for no namespace attribute. Because
152
- # the default namespace doesn't apply to attribute names.
153
- #
154
- # From https://www.w3.org/TR/xml-names/#uniqAttrs
155
- #
156
- # > the default namespace does not apply to attribute names
157
- #
158
- # e = REXML::Element.new("el")
159
- # e.add_namespace("", "http://example.com/")
160
- # e.namespace # => "http://example.com/"
161
- # e.add_attribute("a", "b")
162
- # e.attribute("a").namespace # => ""
163
- #
164
- # source://rexml//lib/rexml/attribute.rb#98
165
- def namespace(arg = T.unsafe(nil)); end
166
-
167
- # source://rexml//lib/rexml/attribute.rb#188
168
- def node_type; end
169
-
170
- # The normalized value of this attribute. That is, the attribute with
171
- # entities intact.
172
- #
173
- # source://rexml//lib/rexml/attribute.rb#18
174
- def normalized=(_arg0); end
175
-
176
- # Returns the namespace of the attribute.
177
- #
178
- # e = Element.new( "elns:myelement" )
179
- # e.add_attribute( "nsa:a", "aval" )
180
- # e.add_attribute( "b", "bval" )
181
- # e.attributes.get_attribute( "a" ).prefix # -> "nsa"
182
- # e.attributes.get_attribute( "b" ).prefix # -> ""
183
- # a = Attribute.new( "x", "y" )
184
- # a.prefix # -> ""
185
- #
186
- # source://rexml//lib/rexml/attribute.rb#73
187
- def prefix; end
188
-
189
- # Removes this Attribute from the tree, and returns true if successful
190
- #
191
- # This method is usually not called directly.
192
- #
193
- # source://rexml//lib/rexml/attribute.rb#179
194
- def remove; end
195
-
196
- # Returns the attribute value, with entities replaced
197
- #
198
- # source://rexml//lib/rexml/attribute.rb#140
199
- def to_s; end
200
-
201
- # Returns this attribute out as XML source, expanding the name
202
- #
203
- # a = Attribute.new( "x", "y" )
204
- # a.to_string # -> "x='y'"
205
- # b = Attribute.new( "ns:x", "y" )
206
- # b.to_string # -> "ns:x='y'"
207
- #
208
- # source://rexml//lib/rexml/attribute.rb#124
209
- def to_string; end
210
-
211
- # Returns the UNNORMALIZED value of this attribute. That is, entities
212
- # have been expanded to their values
213
- #
214
- # source://rexml//lib/rexml/attribute.rb#150
215
- def value; end
216
-
217
- # Writes this attribute (EG, puts 'key="value"' to the output)
218
- #
219
- # source://rexml//lib/rexml/attribute.rb#184
220
- def write(output, indent = T.unsafe(nil)); end
221
-
222
- # source://rexml//lib/rexml/attribute.rb#198
223
- def xpath; end
224
- end
225
-
226
- # A class that defines the set of Attributes of an Element and provides
227
- # operations for accessing elements in that set.
228
- #
229
- # source://rexml//lib/rexml/element.rb#2141
230
- class REXML::Attributes < ::Hash
231
- # :call-seq:
232
- # new(element)
233
- #
234
- # Creates and returns a new \REXML::Attributes object.
235
- # The element given by argument +element+ is stored,
236
- # but its own attributes are not modified:
237
- #
238
- # ele = REXML::Element.new('foo')
239
- # attrs = REXML::Attributes.new(ele)
240
- # attrs.object_id == ele.attributes.object_id # => false
241
- #
242
- # Other instance methods in class \REXML::Attributes may refer to:
243
- #
244
- # - +element.document+.
245
- # - +element.prefix+.
246
- # - +element.expanded_name+.
247
- #
248
- # @return [Attributes] a new instance of Attributes
249
- #
250
- # source://rexml//lib/rexml/element.rb#2160
251
- def initialize(element); end
252
-
253
- # :call-seq:
254
- # add(attribute) -> attribute
255
- #
256
- # Adds attribute +attribute+, replacing the previous
257
- # attribute of the same name if it exists;
258
- # returns +attribute+:
259
- #
260
- # xml_string = <<-EOT
261
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
262
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
263
- # </root>
264
- # EOT
265
- # d = REXML::Document.new(xml_string)
266
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
267
- # attrs = ele.attributes
268
- # attrs # => {"att"=>{"foo"=>foo:att='1', "bar"=>bar:att='2', ""=>att='&lt;'}}
269
- # attrs.add(REXML::Attribute.new('foo:att', '2')) # => foo:att='2'
270
- # attrs.add(REXML::Attribute.new('baz', '3')) # => baz='3'
271
- # attrs.include?('baz') # => true
272
- #
273
- # source://rexml//lib/rexml/element.rb#2537
274
- def <<(attribute); end
275
-
276
- # :call-seq:
277
- # [name] -> attribute_value or nil
278
- #
279
- # Returns the value for the attribute given by +name+,
280
- # if it exists; otherwise +nil+.
281
- # The value returned is the unnormalized attribute value,
282
- # with entities expanded:
283
- #
284
- # xml_string = <<-EOT
285
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
286
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
287
- # </root>
288
- # EOT
289
- # d = REXML::Document.new(xml_string)
290
- # ele = d.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
291
- # ele.attributes['att'] # => "<"
292
- # ele.attributes['bar:att'] # => "2"
293
- # ele.attributes['nosuch'] # => nil
294
- #
295
- # Related: get_attribute (returns an \Attribute object).
296
- #
297
- # source://rexml//lib/rexml/element.rb#2185
298
- def [](name); end
299
-
300
- # :call-seq:
301
- # [name] = value -> value
302
- #
303
- # When +value+ is non-+nil+,
304
- # assigns that to the attribute for the given +name+,
305
- # overwriting the previous value if it exists:
306
- #
307
- # xml_string = <<-EOT
308
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
309
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
310
- # </root>
311
- # EOT
312
- # d = REXML::Document.new(xml_string)
313
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
314
- # attrs = ele.attributes
315
- # attrs['foo:att'] = '2' # => "2"
316
- # attrs['baz:att'] = '3' # => "3"
317
- #
318
- # When +value+ is +nil+, deletes the attribute if it exists:
319
- #
320
- # attrs['baz:att'] = nil
321
- # attrs.include?('baz:att') # => false
322
- #
323
- # source://rexml//lib/rexml/element.rb#2369
324
- def []=(name, value); end
325
-
326
- # :call-seq:
327
- # add(attribute) -> attribute
328
- #
329
- # Adds attribute +attribute+, replacing the previous
330
- # attribute of the same name if it exists;
331
- # returns +attribute+:
332
- #
333
- # xml_string = <<-EOT
334
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
335
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
336
- # </root>
337
- # EOT
338
- # d = REXML::Document.new(xml_string)
339
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
340
- # attrs = ele.attributes
341
- # attrs # => {"att"=>{"foo"=>foo:att='1', "bar"=>bar:att='2', ""=>att='&lt;'}}
342
- # attrs.add(REXML::Attribute.new('foo:att', '2')) # => foo:att='2'
343
- # attrs.add(REXML::Attribute.new('baz', '3')) # => baz='3'
344
- # attrs.include?('baz') # => true
345
- #
346
- # source://rexml//lib/rexml/element.rb#2537
347
- def add(attribute); end
348
-
349
- # :call-seq:
350
- # delete(name) -> element
351
- # delete(attribute) -> element
352
- #
353
- # Removes a specified attribute if it exists;
354
- # returns the attributes' element.
355
- #
356
- # When string argument +name+ is given,
357
- # removes the attribute of that name if it exists:
358
- #
359
- # xml_string = <<-EOT
360
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
361
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
362
- # </root>
363
- # EOT
364
- # d = REXML::Document.new(xml_string)
365
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
366
- # attrs = ele.attributes
367
- # attrs.delete('foo:att') # => <ele bar:att='2' att='&lt;'/>
368
- # attrs.delete('foo:att') # => <ele bar:att='2' att='&lt;'/>
369
- #
370
- # When attribute argument +attribute+ is given,
371
- # removes that attribute if it exists:
372
- #
373
- # attr = REXML::Attribute.new('bar:att', '2')
374
- # attrs.delete(attr) # => <ele att='&lt;'/> # => <ele att='&lt;'/>
375
- # attrs.delete(attr) # => <ele att='&lt;'/> # => <ele/>
376
- #
377
- # source://rexml//lib/rexml/element.rb#2490
378
- def delete(attribute); end
379
-
380
- # :call-seq:
381
- # delete_all(name) -> array_of_removed_attributes
382
- #
383
- # Removes all attributes matching the given +name+;
384
- # returns an array of the removed attributes:
385
- #
386
- # xml_string = <<-EOT
387
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
388
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
389
- # </root>
390
- # EOT
391
- # d = REXML::Document.new(xml_string)
392
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
393
- # attrs = ele.attributes
394
- # attrs.delete_all('att') # => [att='&lt;']
395
- #
396
- # source://rexml//lib/rexml/element.rb#2559
397
- def delete_all(name); end
398
-
399
- # :call-seq:
400
- # each {|expanded_name, value| ... }
401
- #
402
- # Calls the given block with each expanded-name/value pair:
403
- #
404
- # xml_string = <<-EOT
405
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
406
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
407
- # </root>
408
- # EOT
409
- # d = REXML::Document.new(xml_string)
410
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
411
- # ele.attributes.each do |expanded_name, value|
412
- # p [expanded_name, value]
413
- # end
414
- #
415
- # Output:
416
- #
417
- # ["foo:att", "1"]
418
- # ["bar:att", "2"]
419
- # ["att", "<"]
420
- #
421
- # source://rexml//lib/rexml/element.rb#2287
422
- def each; end
423
-
424
- # :call-seq:
425
- # each_attribute {|attr| ... }
426
- #
427
- # Calls the given block with each \REXML::Attribute object:
428
- #
429
- # xml_string = <<-EOT
430
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
431
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
432
- # </root>
433
- # EOT
434
- # d = REXML::Document.new(xml_string)
435
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
436
- # ele.attributes.each_attribute do |attr|
437
- # p [attr.class, attr]
438
- # end
439
- #
440
- # Output:
441
- #
442
- # [REXML::Attribute, foo:att='1']
443
- # [REXML::Attribute, bar:att='2']
444
- # [REXML::Attribute, att='&lt;']
445
- #
446
- # source://rexml//lib/rexml/element.rb#2254
447
- def each_attribute; end
448
-
449
- # :call-seq:
450
- # get_attribute(name) -> attribute_object or nil
451
- #
452
- # Returns the \REXML::Attribute object for the given +name+:
453
- #
454
- # xml_string = <<-EOT
455
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
456
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
457
- # </root>
458
- # EOT
459
- # d = REXML::Document.new(xml_string)
460
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
461
- # attrs = ele.attributes
462
- # attrs.get_attribute('foo:att') # => foo:att='1'
463
- # attrs.get_attribute('foo:att').class # => REXML::Attribute
464
- # attrs.get_attribute('bar:att') # => bar:att='2'
465
- # attrs.get_attribute('att') # => att='&lt;'
466
- # attrs.get_attribute('nosuch') # => nil
467
- #
468
- # source://rexml//lib/rexml/element.rb#2313
469
- def get_attribute(name); end
470
-
471
- # :call-seq:
472
- # get_attribute_ns(namespace, name)
473
- #
474
- # Returns the \REXML::Attribute object among the attributes
475
- # that matches the given +namespace+ and +name+:
476
- #
477
- # xml_string = <<-EOT
478
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
479
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
480
- # </root>
481
- # EOT
482
- # d = REXML::Document.new(xml_string)
483
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
484
- # attrs = ele.attributes
485
- # attrs.get_attribute_ns('http://foo', 'att') # => foo:att='1'
486
- # attrs.get_attribute_ns('http://foo', 'nosuch') # => nil
487
- #
488
- # source://rexml//lib/rexml/element.rb#2585
489
- def get_attribute_ns(namespace, name); end
490
-
491
- # :call-seq:
492
- # length
493
- #
494
- # Returns the count of attributes:
495
- #
496
- # xml_string = <<-EOT
497
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
498
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
499
- # </root>
500
- # EOT
501
- # d = REXML::Document.new(xml_string)
502
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
503
- # ele.attributes.length # => 3
504
- #
505
- # source://rexml//lib/rexml/element.rb#2225
506
- def length; end
507
-
508
- # :call-seq:
509
- # namespaces
510
- #
511
- # Returns a hash of name/value pairs for the namespaces:
512
- #
513
- # xml_string = '<a xmlns="foo" xmlns:x="bar" xmlns:y="twee" z="glorp"/>'
514
- # d = REXML::Document.new(xml_string)
515
- # d.root.attributes.namespaces # => {"xmlns"=>"foo", "x"=>"bar", "y"=>"twee"}
516
- #
517
- # source://rexml//lib/rexml/element.rb#2446
518
- def namespaces; end
519
-
520
- # :call-seq:
521
- # prefixes -> array_of_prefix_strings
522
- #
523
- # Returns an array of prefix strings in the attributes.
524
- # The array does not include the default
525
- # namespace declaration, if one exists.
526
- #
527
- # xml_string = '<a xmlns="foo" xmlns:x="bar" xmlns:y="twee" z="glorp"/>'
528
- # d = REXML::Document.new(xml_string)
529
- # d.root.attributes.prefixes # => ["x", "y"]
530
- #
531
- # source://rexml//lib/rexml/element.rb#2421
532
- def prefixes; end
533
-
534
- # :call-seq:
535
- # length
536
- #
537
- # Returns the count of attributes:
538
- #
539
- # xml_string = <<-EOT
540
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
541
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
542
- # </root>
543
- # EOT
544
- # d = REXML::Document.new(xml_string)
545
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
546
- # ele.attributes.length # => 3
547
- #
548
- # source://rexml//lib/rexml/element.rb#2225
549
- def size; end
550
-
551
- # :call-seq:
552
- # to_a -> array_of_attribute_objects
553
- #
554
- # Returns an array of \REXML::Attribute objects representing
555
- # the attributes:
556
- #
557
- # xml_string = <<-EOT
558
- # <root xmlns:foo="http://foo" xmlns:bar="http://bar">
559
- # <ele foo:att='1' bar:att='2' att='&lt;'/>
560
- # </root>
561
- # EOT
562
- # d = REXML::Document.new(xml_string)
563
- # ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
564
- # attrs = ele.attributes.to_a # => [foo:att='1', bar:att='2', att='&lt;']
565
- # attrs.first.class # => REXML::Attribute
566
- #
567
- # source://rexml//lib/rexml/element.rb#2207
568
- def to_a; end
569
- end
570
-
571
- # source://rexml//lib/rexml/cdata.rb#5
572
- class REXML::CData < ::REXML::Text
573
- # Constructor. CData is data between <![CDATA[ ... ]]>
574
- #
575
- # _Examples_
576
- # CData.new( source )
577
- # CData.new( "Here is some CDATA" )
578
- # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
579
- #
580
- # @return [CData] a new instance of CData
581
- #
582
- # source://rexml//lib/rexml/cdata.rb#16
583
- def initialize(first, whitespace = T.unsafe(nil), parent = T.unsafe(nil)); end
584
-
585
- # Make a copy of this object
586
- #
587
- # _Examples_
588
- # c = CData.new( "Some text" )
589
- # d = c.clone
590
- # d.to_s # -> "Some text"
591
- #
592
- # source://rexml//lib/rexml/cdata.rb#26
593
- def clone; end
594
-
595
- # Returns the content of this CData object
596
- #
597
- # _Examples_
598
- # c = CData.new( "Some text" )
599
- # c.to_s # -> "Some text"
600
- #
601
- # source://rexml//lib/rexml/cdata.rb#35
602
- def to_s; end
603
-
604
- # source://rexml//lib/rexml/cdata.rb#39
605
- def value; end
606
-
607
- # == DEPRECATED
608
- # See the rexml/formatters package
609
- #
610
- # Generates XML output of this object
611
- #
612
- # output::
613
- # Where to write the string. Defaults to $stdout
614
- # indent::
615
- # The amount to indent this node by
616
- # transitive::
617
- # Ignored
618
- # ie_hack::
619
- # Ignored
620
- #
621
- # _Examples_
622
- # c = CData.new( " Some text " )
623
- # c.write( $stdout ) #-> <![CDATA[ Some text ]]>
624
- #
625
- # source://rexml//lib/rexml/cdata.rb#60
626
- def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
627
- end
628
-
629
- # A Child object is something contained by a parent, and this class
630
- # contains methods to support that. Most user code will not use this
631
- # class directly.
632
- #
633
- # source://rexml//lib/rexml/child.rb#9
634
- class REXML::Child
635
- include ::REXML::Node
636
-
637
- # Constructor. Any inheritors of this class should call super to make
638
- # sure this method is called.
639
- # parent::
640
- # if supplied, the parent of this child will be set to the
641
- # supplied value, and self will be added to the parent
642
- #
643
- # @return [Child] a new instance of Child
644
- #
645
- # source://rexml//lib/rexml/child.rb#18
646
- def initialize(parent = T.unsafe(nil)); end
647
-
648
- # This doesn't yet handle encodings
649
- #
650
- # source://rexml//lib/rexml/child.rb#91
651
- def bytes; end
652
-
653
- # Returns:: the document this child belongs to, or nil if this child
654
- # belongs to no document
655
- #
656
- # source://rexml//lib/rexml/child.rb#85
657
- def document; end
658
-
659
- # source://rexml//lib/rexml/node.rb#11
660
- def next_sibling; end
661
-
662
- # Sets the next sibling of this child. This can be used to insert a child
663
- # after some other child.
664
- # a = Element.new("a")
665
- # b = a.add_element("b")
666
- # c = Element.new("c")
667
- # b.next_sibling = c
668
- # # => <a><b/><c/></a>
669
- #
670
- # source://rexml//lib/rexml/child.rb#68
671
- def next_sibling=(other); end
672
-
673
- # The Parent of this object
674
- #
675
- # source://rexml//lib/rexml/child.rb#11
676
- def parent; end
677
-
678
- # Sets the parent of this child to the supplied argument.
679
- #
680
- # other::
681
- # Must be a Parent object. If this object is the same object as the
682
- # existing parent of this child, no action is taken. Otherwise, this
683
- # child is removed from the current parent (if one exists), and is added
684
- # to the new parent.
685
- # Returns:: The parent added
686
- #
687
- # source://rexml//lib/rexml/child.rb#52
688
- def parent=(other); end
689
-
690
- # source://rexml//lib/rexml/node.rb#17
691
- def previous_sibling; end
692
-
693
- # Sets the previous sibling of this child. This can be used to insert a
694
- # child before some other child.
695
- # a = Element.new("a")
696
- # b = a.add_element("b")
697
- # c = Element.new("c")
698
- # b.previous_sibling = c
699
- # # => <a><b/><c/></a>
700
- #
701
- # source://rexml//lib/rexml/child.rb#79
702
- def previous_sibling=(other); end
703
-
704
- # Removes this child from the parent.
705
- #
706
- # Returns:: self
707
- #
708
- # source://rexml//lib/rexml/child.rb#37
709
- def remove; end
710
-
711
- # Replaces this object with another object. Basically, calls
712
- # Parent.replace_child
713
- #
714
- # Returns:: self
715
- #
716
- # source://rexml//lib/rexml/child.rb#29
717
- def replace_with(child); end
718
- end
719
-
720
- # Represents an XML comment; that is, text between \<!-- ... -->
721
- #
722
- # source://rexml//lib/rexml/comment.rb#7
723
- class REXML::Comment < ::REXML::Child
724
- include ::Comparable
725
-
726
- # Constructor. The first argument can be one of three types:
727
- # argument. If Comment, the argument is duplicated. If
728
- # Source, the argument is scanned for a comment.
729
- # should be nil, not supplied, or a Parent to be set as the parent
730
- # of this object
731
- #
732
- # @param first If String, the contents of this comment are set to the
733
- # @param second If the first argument is a Source, this argument
734
- # @return [Comment] a new instance of Comment
735
- #
736
- # source://rexml//lib/rexml/comment.rb#24
737
- def initialize(first, second = T.unsafe(nil)); end
738
-
739
- # Compares this Comment to another; the contents of the comment are used
740
- # in the comparison.
741
- #
742
- # source://rexml//lib/rexml/comment.rb#63
743
- def <=>(other); end
744
-
745
- # Compares this Comment to another; the contents of the comment are used
746
- # in the comparison.
747
- #
748
- # source://rexml//lib/rexml/comment.rb#70
749
- def ==(other); end
750
-
751
- # source://rexml//lib/rexml/comment.rb#33
752
- def clone; end
753
-
754
- # source://rexml//lib/rexml/comment.rb#75
755
- def node_type; end
756
-
757
- # The content text
758
- #
759
- # source://rexml//lib/rexml/comment.rb#14
760
- def string; end
761
-
762
- # The content text
763
- #
764
- # source://rexml//lib/rexml/comment.rb#14
765
- def string=(_arg0); end
766
-
767
- # The content text
768
- #
769
- # source://rexml//lib/rexml/comment.rb#14
770
- def to_s; end
771
-
772
- # == DEPRECATED
773
- # See REXML::Formatters
774
- #
775
- # output::
776
- # Where to write the string
777
- # indent::
778
- # An integer. If -1, no indenting will be used; otherwise, the
779
- # indentation will be this number of spaces, and children will be
780
- # indented an additional amount.
781
- # transitive::
782
- # Ignored by this class. The contents of comments are never modified.
783
- # ie_hack::
784
- # Needed for conformity to the child API, but not used by this class.
785
- #
786
- # source://rexml//lib/rexml/comment.rb#50
787
- def write(output, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
788
- end
789
-
790
- # source://rexml//lib/rexml/xpath_parser.rb#11
791
- module REXML::DClonable; end
792
-
793
- # This is an abstract class. You never use this directly; it serves as a
794
- # parent class for the specific declarations.
795
- #
796
- # source://rexml//lib/rexml/doctype.rb#242
797
- class REXML::Declaration < ::REXML::Child
798
- # @return [Declaration] a new instance of Declaration
799
- #
800
- # source://rexml//lib/rexml/doctype.rb#243
801
- def initialize(src); end
802
-
803
- # source://rexml//lib/rexml/doctype.rb#248
804
- def to_s; end
805
-
806
- # == DEPRECATED
807
- # See REXML::Formatters
808
- #
809
- # source://rexml//lib/rexml/doctype.rb#255
810
- def write(output, indent); end
811
- end
812
-
813
- # Represents an XML DOCTYPE declaration; that is, the contents of <!DOCTYPE
814
- # ... >. DOCTYPES can be used to declare the DTD of a document, as well as
815
- # being used to declare entities used in the document.
816
- #
817
- # source://rexml//lib/rexml/doctype.rb#51
818
- class REXML::DocType < ::REXML::Parent
819
- include ::REXML::XMLTokens
820
-
821
- # Constructor
822
- #
823
- # dt = DocType.new( 'foo', '-//I/Hate/External/IDs' )
824
- # # <!DOCTYPE foo '-//I/Hate/External/IDs'>
825
- # dt = DocType.new( doctype_to_clone )
826
- # # Incomplete. Shallow clone of doctype
827
- #
828
- # +Note+ that the constructor:
829
- #
830
- # Doctype.new( Source.new( "<!DOCTYPE foo 'bar'>" ) )
831
- #
832
- # is _deprecated_. Do not use it. It will probably disappear.
833
- #
834
- # @return [DocType] a new instance of DocType
835
- #
836
- # source://rexml//lib/rexml/doctype.rb#80
837
- def initialize(first, parent = T.unsafe(nil)); end
838
-
839
- # source://rexml//lib/rexml/doctype.rb#185
840
- def add(child); end
841
-
842
- # source://rexml//lib/rexml/doctype.rb#125
843
- def attribute_of(element, attribute); end
844
-
845
- # source://rexml//lib/rexml/doctype.rb#115
846
- def attributes_of(element); end
847
-
848
- # source://rexml//lib/rexml/doctype.rb#135
849
- def clone; end
850
-
851
- # source://rexml//lib/rexml/doctype.rb#173
852
- def context; end
853
-
854
- # name is the name of the doctype
855
- # external_id is the referenced DTD, if given
856
- #
857
- # source://rexml//lib/rexml/doctype.rb#66
858
- def entities; end
859
-
860
- # source://rexml//lib/rexml/doctype.rb#181
861
- def entity(name); end
862
-
863
- # name is the name of the doctype
864
- # external_id is the referenced DTD, if given
865
- #
866
- # source://rexml//lib/rexml/doctype.rb#66
867
- def external_id; end
868
-
869
- # name is the name of the doctype
870
- # external_id is the referenced DTD, if given
871
- #
872
- # source://rexml//lib/rexml/doctype.rb#66
873
- def name; end
874
-
875
- # name is the name of the doctype
876
- # external_id is the referenced DTD, if given
877
- #
878
- # source://rexml//lib/rexml/doctype.rb#66
879
- def namespaces; end
880
-
881
- # source://rexml//lib/rexml/doctype.rb#111
882
- def node_type; end
883
-
884
- # Retrieves a named notation. Only notations declared in the internal
885
- # DTD subset can be retrieved.
886
- #
887
- # Method contributed by Henrik Martensson
888
- #
889
- # source://rexml//lib/rexml/doctype.rb#229
890
- def notation(name); end
891
-
892
- # This method returns a list of notations that have been declared in the
893
- # _internal_ DTD subset. Notations in the external DTD subset are not
894
- # listed.
895
- #
896
- # Method contributed by Henrik Martensson
897
- #
898
- # source://rexml//lib/rexml/doctype.rb#221
899
- def notations; end
900
-
901
- # This method retrieves the public identifier identifying the document's
902
- # DTD.
903
- #
904
- # Method contributed by Henrik Martensson
905
- #
906
- # source://rexml//lib/rexml/doctype.rb#195
907
- def public; end
908
-
909
- # This method retrieves the system identifier identifying the document's DTD
910
- #
911
- # Method contributed by Henrik Martensson
912
- #
913
- # source://rexml//lib/rexml/doctype.rb#207
914
- def system; end
915
-
916
- # output::
917
- # Where to write the string
918
- # indent::
919
- # An integer. If -1, no indentation will be used; otherwise, the
920
- # indentation will be this number of spaces, and children will be
921
- # indented an additional amount.
922
- # transitive::
923
- # Ignored
924
- # ie_hack::
925
- # Ignored
926
- #
927
- # source://rexml//lib/rexml/doctype.rb#149
928
- def write(output, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
929
- end
930
-
931
- # Represents an XML document.
932
- #
933
- # A document may have:
934
- #
935
- # - A single child that may be accessed via method #root.
936
- # - An XML declaration.
937
- # - A document type.
938
- # - Processing instructions.
939
- #
940
- # == In a Hurry?
941
- #
942
- # If you're somewhat familiar with XML
943
- # and have a particular task in mind,
944
- # you may want to see the
945
- # {tasks pages}[../doc/rexml/tasks/tocs/master_toc_rdoc.html],
946
- # and in particular, the
947
- # {tasks page for documents}[../doc/rexml/tasks/tocs/document_toc_rdoc.html].
948
- #
949
- # source://rexml//lib/rexml/document.rb#39
950
- class REXML::Document < ::REXML::Element
951
- # :call-seq:
952
- # new(string = nil, context = {}) -> new_document
953
- # new(io_stream = nil, context = {}) -> new_document
954
- # new(document = nil, context = {}) -> new_document
955
- #
956
- # Returns a new \REXML::Document object.
957
- #
958
- # When no arguments are given,
959
- # returns an empty document:
960
- #
961
- # d = REXML::Document.new
962
- # d.to_s # => ""
963
- #
964
- # When argument +string+ is given, it must be a string
965
- # containing a valid XML document:
966
- #
967
- # xml_string = '<root><foo>Foo</foo><bar>Bar</bar></root>'
968
- # d = REXML::Document.new(xml_string)
969
- # d.to_s # => "<root><foo>Foo</foo><bar>Bar</bar></root>"
970
- #
971
- # When argument +io_stream+ is given, it must be an \IO object
972
- # that is opened for reading, and when read must return a valid XML document:
973
- #
974
- # File.write('t.xml', xml_string)
975
- # d = File.open('t.xml', 'r') do |io|
976
- # REXML::Document.new(io)
977
- # end
978
- # d.to_s # => "<root><foo>Foo</foo><bar>Bar</bar></root>"
979
- #
980
- # When argument +document+ is given, it must be an existing
981
- # document object, whose context and attributes (but not chidren)
982
- # are cloned into the new document:
983
- #
984
- # d = REXML::Document.new(xml_string)
985
- # d.children # => [<root> ... </>]
986
- # d.context = {raw: :all, compress_whitespace: :all}
987
- # d.add_attributes({'bar' => 0, 'baz' => 1})
988
- # d1 = REXML::Document.new(d)
989
- # d1.children # => []
990
- # d1.context # => {:raw=>:all, :compress_whitespace=>:all}
991
- # d1.attributes # => {"bar"=>bar='0', "baz"=>baz='1'}
992
- #
993
- # When argument +context+ is given, it must be a hash
994
- # containing context entries for the document;
995
- # see {Element Context}[../doc/rexml/context_rdoc.html]:
996
- #
997
- # context = {raw: :all, compress_whitespace: :all}
998
- # d = REXML::Document.new(xml_string, context)
999
- # d.context # => {:raw=>:all, :compress_whitespace=>:all}
1000
- #
1001
- # @return [Document] a new instance of Document
1002
- #
1003
- # source://rexml//lib/rexml/document.rb#92
1004
- def initialize(source = T.unsafe(nil), context = T.unsafe(nil)); end
1005
-
1006
- # :call-seq:
1007
- # add(xml_decl) -> self
1008
- # add(doc_type) -> self
1009
- # add(object) -> self
1010
- #
1011
- # Adds an object to the document; returns +self+.
1012
- #
1013
- # When argument +xml_decl+ is given,
1014
- # it must be an REXML::XMLDecl object,
1015
- # which becomes the XML declaration for the document,
1016
- # replacing the previous XML declaration if any:
1017
- #
1018
- # d = REXML::Document.new
1019
- # d.xml_decl.to_s # => ""
1020
- # d.add(REXML::XMLDecl.new('2.0'))
1021
- # d.xml_decl.to_s # => "<?xml version='2.0'?>"
1022
- #
1023
- # When argument +doc_type+ is given,
1024
- # it must be an REXML::DocType object,
1025
- # which becomes the document type for the document,
1026
- # replacing the previous document type, if any:
1027
- #
1028
- # d = REXML::Document.new
1029
- # d.doctype.to_s # => ""
1030
- # d.add(REXML::DocType.new('foo'))
1031
- # d.doctype.to_s # => "<!DOCTYPE foo>"
1032
- #
1033
- # When argument +object+ (not an REXML::XMLDecl or REXML::DocType object)
1034
- # is given it is added as the last child:
1035
- #
1036
- # d = REXML::Document.new
1037
- # d.add(REXML::Element.new('foo'))
1038
- # d.to_s # => "<foo/>"
1039
- #
1040
- # source://rexml//lib/rexml/document.rb#170
1041
- def <<(child); end
1042
-
1043
- # :call-seq:
1044
- # add(xml_decl) -> self
1045
- # add(doc_type) -> self
1046
- # add(object) -> self
1047
- #
1048
- # Adds an object to the document; returns +self+.
1049
- #
1050
- # When argument +xml_decl+ is given,
1051
- # it must be an REXML::XMLDecl object,
1052
- # which becomes the XML declaration for the document,
1053
- # replacing the previous XML declaration if any:
1054
- #
1055
- # d = REXML::Document.new
1056
- # d.xml_decl.to_s # => ""
1057
- # d.add(REXML::XMLDecl.new('2.0'))
1058
- # d.xml_decl.to_s # => "<?xml version='2.0'?>"
1059
- #
1060
- # When argument +doc_type+ is given,
1061
- # it must be an REXML::DocType object,
1062
- # which becomes the document type for the document,
1063
- # replacing the previous document type, if any:
1064
- #
1065
- # d = REXML::Document.new
1066
- # d.doctype.to_s # => ""
1067
- # d.add(REXML::DocType.new('foo'))
1068
- # d.doctype.to_s # => "<!DOCTYPE foo>"
1069
- #
1070
- # When argument +object+ (not an REXML::XMLDecl or REXML::DocType object)
1071
- # is given it is added as the last child:
1072
- #
1073
- # d = REXML::Document.new
1074
- # d.add(REXML::Element.new('foo'))
1075
- # d.to_s # => "<foo/>"
1076
- #
1077
- # source://rexml//lib/rexml/document.rb#170
1078
- def add(child); end
1079
-
1080
- # :call-seq:
1081
- # add_element(name_or_element = nil, attributes = nil) -> new_element
1082
- #
1083
- # Adds an element to the document by calling REXML::Element.add_element:
1084
- #
1085
- # REXML::Element.add_element(name_or_element, attributes)
1086
- #
1087
- # source://rexml//lib/rexml/document.rb#209
1088
- def add_element(arg = T.unsafe(nil), arg2 = T.unsafe(nil)); end
1089
-
1090
- # :call-seq:
1091
- # clone -> new_document
1092
- #
1093
- # Returns the new document resulting from executing
1094
- # <tt>Document.new(self)</tt>. See Document.new.
1095
- #
1096
- # source://rexml//lib/rexml/document.rb#120
1097
- def clone; end
1098
-
1099
- # :call-seq:
1100
- # doctype -> doc_type or nil
1101
- #
1102
- # Returns the DocType object for the document, if it exists, otherwise +nil+:
1103
- #
1104
- # d = REXML::Document.new('<!DOCTYPE document SYSTEM "subjects.dtd">')
1105
- # d.doctype.class # => REXML::DocType
1106
- # d = REXML::Document.new('')
1107
- # d.doctype.class # => nil
1108
- #
1109
- # source://rexml//lib/rexml/document.rb#241
1110
- def doctype; end
1111
-
1112
- # source://rexml//lib/rexml/document.rb#442
1113
- def document; end
1114
-
1115
- # :call-seq:
1116
- # encoding -> encoding_string
1117
- #
1118
- # Returns the XMLDecl encoding of the document,
1119
- #
1120
- # d = REXML::Document.new('<?xml version="1.0" encoding="UTF-16"?>')
1121
- # d.encoding # => "UTF-16"
1122
- # d = REXML::Document.new('')
1123
- # d.encoding # => "UTF-8"
1124
- #
1125
- # source://rexml//lib/rexml/document.rb#290
1126
- def encoding; end
1127
-
1128
- # Returns the value of attribute entity_expansion_count.
1129
- #
1130
- # source://rexml//lib/rexml/document.rb#433
1131
- def entity_expansion_count; end
1132
-
1133
- # :call-seq:
1134
- # expanded_name -> empty_string
1135
- #
1136
- # Returns an empty string.
1137
- #
1138
- # source://rexml//lib/rexml/document.rb#129
1139
- def expanded_name; end
1140
-
1141
- # :call-seq:
1142
- # expanded_name -> empty_string
1143
- #
1144
- # Returns an empty string.
1145
- # d = doc_type
1146
- # d ? d.name : "UNDEFINED"
1147
- #
1148
- # source://rexml//lib/rexml/document.rb#129
1149
- def name; end
1150
-
1151
- # :call-seq:
1152
- # node_type -> :document
1153
- #
1154
- # Returns the symbol +:document+.
1155
- #
1156
- # source://rexml//lib/rexml/document.rb#110
1157
- def node_type; end
1158
-
1159
- # source://rexml//lib/rexml/document.rb#435
1160
- def record_entity_expansion; end
1161
-
1162
- # :call-seq:
1163
- # root -> root_element or nil
1164
- #
1165
- # Returns the root element of the document, if it exists, otherwise +nil+:
1166
- #
1167
- # d = REXML::Document.new('<root></root>')
1168
- # d.root # => <root/>
1169
- # d = REXML::Document.new('')
1170
- # d.root # => nil
1171
- #
1172
- # source://rexml//lib/rexml/document.rb#225
1173
- def root; end
1174
-
1175
- # :call-seq:
1176
- # stand_alone?
1177
- #
1178
- # Returns the XMLDecl standalone value of the document as a string,
1179
- # if it has been set, otherwise the default standalone value:
1180
- #
1181
- # d = REXML::Document.new('<?xml standalone="yes"?>')
1182
- # d.stand_alone? # => "yes"
1183
- # d = REXML::Document.new('')
1184
- # d.stand_alone? # => nil
1185
- #
1186
- # @return [Boolean]
1187
- #
1188
- # source://rexml//lib/rexml/document.rb#305
1189
- def stand_alone?; end
1190
-
1191
- # :call-seq:
1192
- # version -> version_string
1193
- #
1194
- # Returns the XMLDecl version of this document as a string,
1195
- # if it has been set, otherwise the default version:
1196
- #
1197
- # d = REXML::Document.new('<?xml version="2.0" encoding="UTF-8"?>')
1198
- # d.version # => "2.0"
1199
- # d = REXML::Document.new('')
1200
- # d.version # => "1.0"
1201
- #
1202
- # source://rexml//lib/rexml/document.rb#275
1203
- def version; end
1204
-
1205
- # :call-seq:
1206
- # doc.write(output=$stdout, indent=-1, transtive=false, ie_hack=false, encoding=nil)
1207
- # doc.write(options={:output => $stdout, :indent => -1, :transtive => false, :ie_hack => false, :encoding => nil})
1208
- #
1209
- # Write the XML tree out, optionally with indent. This writes out the
1210
- # entire XML document, including XML declarations, doctype declarations,
1211
- # and processing instructions (if any are given).
1212
- #
1213
- # A controversial point is whether Document should always write the XML
1214
- # declaration (<?xml version='1.0'?>) whether or not one is given by the
1215
- # user (or source document). REXML does not write one if one was not
1216
- # specified, because it adds unnecessary bandwidth to applications such
1217
- # as XML-RPC.
1218
- #
1219
- # Accept Nth argument style and options Hash style as argument.
1220
- # The recommended style is options Hash style for one or more
1221
- # arguments case.
1222
- #
1223
- # _Examples_
1224
- # Document.new("<a><b/></a>").write
1225
- #
1226
- # output = ""
1227
- # Document.new("<a><b/></a>").write(output)
1228
- #
1229
- # output = ""
1230
- # Document.new("<a><b/></a>").write(:output => output, :indent => 2)
1231
- #
1232
- # See also the classes in the rexml/formatters package for the proper way
1233
- # to change the default formatting of XML output.
1234
- #
1235
- # _Examples_
1236
- #
1237
- # output = ""
1238
- # tr = Transitive.new
1239
- # tr.write(Document.new("<a><b/></a>"), output)
1240
- #
1241
- # output::
1242
- # output an object which supports '<< string'; this is where the
1243
- # document will be written.
1244
- # indent::
1245
- # An integer. If -1, no indenting will be used; otherwise, the
1246
- # indentation will be twice this number of spaces, and children will be
1247
- # indented an additional amount. For a value of 3, every item will be
1248
- # indented 3 more levels, or 6 more spaces (2 * 3). Defaults to -1
1249
- # transitive::
1250
- # If transitive is true and indent is >= 0, then the output will be
1251
- # pretty-printed in such a way that the added whitespace does not affect
1252
- # the absolute *value* of the document -- that is, it leaves the value
1253
- # and number of Text nodes in the document unchanged.
1254
- # ie_hack::
1255
- # This hack inserts a space before the /> on empty tags to address
1256
- # a limitation of Internet Explorer. Defaults to false
1257
- # Encoding name as String. Change output encoding to specified encoding
1258
- # instead of encoding in XML declaration.
1259
- # Defaults to nil. It means encoding in XML declaration is used.
1260
- #
1261
- # source://rexml//lib/rexml/document.rb#365
1262
- def write(*arguments); end
1263
-
1264
- # :call-seq:
1265
- # xml_decl -> xml_decl
1266
- #
1267
- # Returns the XMLDecl object for the document, if it exists,
1268
- # otherwise the default XMLDecl object:
1269
- #
1270
- # d = REXML::Document.new('<?xml version="1.0" encoding="UTF-8"?>')
1271
- # d.xml_decl.class # => REXML::XMLDecl
1272
- # d.xml_decl.to_s # => "<?xml version='1.0' encoding='UTF-8'?>"
1273
- # d = REXML::Document.new('')
1274
- # d.xml_decl.class # => REXML::XMLDecl
1275
- # d.xml_decl.to_s # => ""
1276
- #
1277
- # source://rexml//lib/rexml/document.rb#258
1278
- def xml_decl; end
1279
-
1280
- private
1281
-
1282
- # source://rexml//lib/rexml/document.rb#447
1283
- def build(source); end
1284
-
1285
- class << self
1286
- # Get the entity expansion limit. By default the limit is set to 10000.
1287
- #
1288
- # Deprecated. Use REXML::Security.entity_expansion_limit= instead.
1289
- #
1290
- # source://rexml//lib/rexml/document.rb#415
1291
- def entity_expansion_limit; end
1292
-
1293
- # Set the entity expansion limit. By default the limit is set to 10000.
1294
- #
1295
- # Deprecated. Use REXML::Security.entity_expansion_limit= instead.
1296
- #
1297
- # source://rexml//lib/rexml/document.rb#408
1298
- def entity_expansion_limit=(val); end
1299
-
1300
- # Get the entity expansion limit. By default the limit is set to 10240.
1301
- #
1302
- # Deprecated. Use REXML::Security.entity_expansion_text_limit instead.
1303
- #
1304
- # source://rexml//lib/rexml/document.rb#429
1305
- def entity_expansion_text_limit; end
1306
-
1307
- # Set the entity expansion limit. By default the limit is set to 10240.
1308
- #
1309
- # Deprecated. Use REXML::Security.entity_expansion_text_limit= instead.
1310
- #
1311
- # source://rexml//lib/rexml/document.rb#422
1312
- def entity_expansion_text_limit=(val); end
1313
-
1314
- # source://rexml//lib/rexml/document.rb#401
1315
- def parse_stream(source, listener); end
1316
- end
1317
- end
1318
-
1319
- # An \REXML::Element object represents an XML element.
1320
- #
1321
- # An element:
1322
- #
1323
- # - Has a name (string).
1324
- # - May have a parent (another element).
1325
- # - Has zero or more children
1326
- # (other elements, text, CDATA, processing instructions, and comments).
1327
- # - Has zero or more siblings
1328
- # (other elements, text, CDATA, processing instructions, and comments).
1329
- # - Has zero or more named attributes.
1330
- #
1331
- # == In a Hurry?
1332
- #
1333
- # If you're somewhat familiar with XML
1334
- # and have a particular task in mind,
1335
- # you may want to see the
1336
- # {tasks pages}[../doc/rexml/tasks/tocs/master_toc_rdoc.html],
1337
- # and in particular, the
1338
- # {tasks page for elements}[../doc/rexml/tasks/tocs/element_toc_rdoc.html].
1339
- #
1340
- # === Name
1341
- #
1342
- # An element has a name, which is initially set when the element is created:
1343
- #
1344
- # e = REXML::Element.new('foo')
1345
- # e.name # => "foo"
1346
- #
1347
- # The name may be changed:
1348
- #
1349
- # e.name = 'bar'
1350
- # e.name # => "bar"
1351
- #
1352
- #
1353
- # === \Parent
1354
- #
1355
- # An element may have a parent.
1356
- #
1357
- # Its parent may be assigned explicitly when the element is created:
1358
- #
1359
- # e0 = REXML::Element.new('foo')
1360
- # e1 = REXML::Element.new('bar', e0)
1361
- # e1.parent # => <foo> ... </>
1362
- #
1363
- # Note: the representation of an element always shows the element's name.
1364
- # If the element has children, the representation indicates that
1365
- # by including an ellipsis (<tt>...</tt>).
1366
- #
1367
- # The parent may be assigned explicitly at any time:
1368
- #
1369
- # e2 = REXML::Element.new('baz')
1370
- # e1.parent = e2
1371
- # e1.parent # => <baz/>
1372
- #
1373
- # When an element is added as a child, its parent is set automatically:
1374
- #
1375
- # e1.add_element(e0)
1376
- # e0.parent # => <bar> ... </>
1377
- #
1378
- # For an element that has no parent, method +parent+ returns +nil+.
1379
- #
1380
- # === Children
1381
- #
1382
- # An element has zero or more children.
1383
- # The children are an ordered collection
1384
- # of all objects whose parent is the element itself.
1385
- #
1386
- # The children may include any combination of elements, text, comments,
1387
- # processing instructions, and CDATA.
1388
- # (This example keeps things clean by controlling whitespace
1389
- # via a +context+ setting.)
1390
- #
1391
- # xml_string = <<-EOT
1392
- # <root>
1393
- # <ele_0/>
1394
- # text 0
1395
- # <!--comment 0-->
1396
- # <?target_0 pi_0?>
1397
- # <![CDATA[cdata 0]]>
1398
- # <ele_1/>
1399
- # text 1
1400
- # <!--comment 1-->
1401
- # <?target_0 pi_1?>
1402
- # <![CDATA[cdata 1]]>
1403
- # </root>
1404
- # EOT
1405
- # context = {ignore_whitespace_nodes: :all, compress_whitespace: :all}
1406
- # d = REXML::Document.new(xml_string, context)
1407
- # root = d.root
1408
- # root.children.size # => 10
1409
- # root.each {|child| p "#{child.class}: #{child}" }
1410
- #
1411
- # Output:
1412
- #
1413
- # "REXML::Element: <ele_0/>"
1414
- # "REXML::Text: \n text 0\n "
1415
- # "REXML::Comment: comment 0"
1416
- # "REXML::Instruction: <?target_0 pi_0?>"
1417
- # "REXML::CData: cdata 0"
1418
- # "REXML::Element: <ele_1/>"
1419
- # "REXML::Text: \n text 1\n "
1420
- # "REXML::Comment: comment 1"
1421
- # "REXML::Instruction: <?target_0 pi_1?>"
1422
- # "REXML::CData: cdata 1"
1423
- #
1424
- # A child may be added using inherited methods
1425
- # Parent#insert_before or Parent#insert_after:
1426
- #
1427
- # xml_string = '<root><a/><c/><d/></root>'
1428
- # d = REXML::Document.new(xml_string)
1429
- # root = d.root
1430
- # c = d.root[1] # => <c/>
1431
- # root.insert_before(c, REXML::Element.new('b'))
1432
- # root.to_a # => [<a/>, <b/>, <c/>, <d/>]
1433
- #
1434
- # A child may be replaced using Parent#replace_child:
1435
- #
1436
- # root.replace_child(c, REXML::Element.new('x'))
1437
- # root.to_a # => [<a/>, <b/>, <x/>, <d/>]
1438
- #
1439
- # A child may be removed using Parent#delete:
1440
- #
1441
- # x = root[2] # => <x/>
1442
- # root.delete(x)
1443
- # root.to_a # => [<a/>, <b/>, <d/>]
1444
- #
1445
- # === Siblings
1446
- #
1447
- # An element has zero or more siblings,
1448
- # which are the other children of the element's parent.
1449
- #
1450
- # In the example above, element +ele_1+ is between a CDATA sibling
1451
- # and a text sibling:
1452
- #
1453
- # ele_1 = root[5] # => <ele_1/>
1454
- # ele_1.previous_sibling # => "cdata 0"
1455
- # ele_1.next_sibling # => "\n text 1\n "
1456
- #
1457
- # === \Attributes
1458
- #
1459
- # An element has zero or more named attributes.
1460
- #
1461
- # A new element has no attributes:
1462
- #
1463
- # e = REXML::Element.new('foo')
1464
- # e.attributes # => {}
1465
- #
1466
- # Attributes may be added:
1467
- #
1468
- # e.add_attribute('bar', 'baz')
1469
- # e.add_attribute('bat', 'bam')
1470
- # e.attributes.size # => 2
1471
- # e['bar'] # => "baz"
1472
- # e['bat'] # => "bam"
1473
- #
1474
- # An existing attribute may be modified:
1475
- #
1476
- # e.add_attribute('bar', 'bad')
1477
- # e.attributes.size # => 2
1478
- # e['bar'] # => "bad"
1479
- #
1480
- # An existing attribute may be deleted:
1481
- #
1482
- # e.delete_attribute('bar')
1483
- # e.attributes.size # => 1
1484
- # e['bar'] # => nil
1485
- #
1486
- # == What's Here
1487
- #
1488
- # To begin with, what's elsewhere?
1489
- #
1490
- # \Class \REXML::Element inherits from its ancestor classes:
1491
- #
1492
- # - REXML::Child
1493
- # - REXML::Parent
1494
- #
1495
- # \REXML::Element itself and its ancestors also include modules:
1496
- #
1497
- # - {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html]
1498
- # - REXML::Namespace
1499
- # - REXML::Node
1500
- # - REXML::XMLTokens
1501
- #
1502
- # === Methods for Creating an \Element
1503
- #
1504
- # ::new:: Returns a new empty element.
1505
- # #clone:: Returns a clone of another element.
1506
- #
1507
- # === Methods for Attributes
1508
- #
1509
- # {[attribute_name]}[#method-i-5B-5D]:: Returns an attribute value.
1510
- # #add_attribute:: Adds a new attribute.
1511
- # #add_attributes:: Adds multiple new attributes.
1512
- # #attribute:: Returns the attribute value for a given name and optional namespace.
1513
- # #delete_attribute:: Removes an attribute.
1514
- #
1515
- # === Methods for Children
1516
- #
1517
- # {[index]}[#method-i-5B-5D]:: Returns the child at the given offset.
1518
- # #add_element:: Adds an element as the last child.
1519
- # #delete_element:: Deletes a child element.
1520
- # #each_element:: Calls the given block with each child element.
1521
- # #each_element_with_attribute:: Calls the given block with each child element
1522
- # that meets given criteria,
1523
- # which can include the attribute name.
1524
- # #each_element_with_text:: Calls the given block with each child element
1525
- # that meets given criteria,
1526
- # which can include text.
1527
- # #get_elements:: Returns an array of element children that match a given xpath.
1528
- #
1529
- # === Methods for \Text Children
1530
- #
1531
- # #add_text:: Adds a text node to the element.
1532
- # #get_text:: Returns a text node that meets specified criteria.
1533
- # #text:: Returns the text string from the first node that meets specified criteria.
1534
- # #texts:: Returns an array of the text children of the element.
1535
- # #text=:: Adds, removes, or replaces the first text child of the element
1536
- #
1537
- # === Methods for Other Children
1538
- #
1539
- # #cdatas:: Returns an array of the cdata children of the element.
1540
- # #comments:: Returns an array of the comment children of the element.
1541
- # #instructions:: Returns an array of the instruction children of the element.
1542
- #
1543
- # === Methods for Namespaces
1544
- #
1545
- # #add_namespace:: Adds a namespace to the element.
1546
- # #delete_namespace:: Removes a namespace from the element.
1547
- # #namespace:: Returns the string namespace URI for the element.
1548
- # #namespaces:: Returns a hash of all defined namespaces in the element.
1549
- # #prefixes:: Returns an array of the string prefixes (names)
1550
- # of all defined namespaces in the element
1551
- #
1552
- # === Methods for Querying
1553
- #
1554
- # #document:: Returns the document, if any, that the element belongs to.
1555
- # #root:: Returns the most distant element (not document) ancestor of the element.
1556
- # #root_node:: Returns the most distant ancestor of the element.
1557
- # #xpath:: Returns the string xpath to the element
1558
- # relative to the most distant parent
1559
- # #has_attributes?:: Returns whether the element has attributes.
1560
- # #has_elements?:: Returns whether the element has elements.
1561
- # #has_text?:: Returns whether the element has text.
1562
- # #next_element:: Returns the next sibling that is an element.
1563
- # #previous_element:: Returns the previous sibling that is an element.
1564
- # #raw:: Returns whether raw mode is set for the element.
1565
- # #whitespace:: Returns whether whitespace is respected for the element.
1566
- # #ignore_whitespace_nodes:: Returns whether whitespace nodes
1567
- # are to be ignored for the element.
1568
- # #node_type:: Returns symbol <tt>:element</tt>.
1569
- #
1570
- # === One More Method
1571
- #
1572
- # #inspect:: Returns a string representation of the element.
1573
- #
1574
- # === Accessors
1575
- #
1576
- # #elements:: Returns the REXML::Elements object for the element.
1577
- # #attributes:: Returns the REXML::Attributes object for the element.
1578
- # #context:: Returns or sets the context hash for the element.
1579
- #
1580
- # source://rexml//lib/rexml/element.rb#279
1581
- class REXML::Element < ::REXML::Parent
1582
- include ::REXML::XMLTokens
1583
- include ::REXML::Namespace
1584
-
1585
- # :call-seq:
1586
- # Element.new(name = 'UNDEFINED', parent = nil, context = nil) -> new_element
1587
- # Element.new(element, parent = nil, context = nil) -> new_element
1588
- #
1589
- # Returns a new \REXML::Element object.
1590
- #
1591
- # When no arguments are given,
1592
- # returns an element with name <tt>'UNDEFINED'</tt>:
1593
- #
1594
- # e = REXML::Element.new # => <UNDEFINED/>
1595
- # e.class # => REXML::Element
1596
- # e.name # => "UNDEFINED"
1597
- #
1598
- # When only argument +name+ is given,
1599
- # returns an element of the given name:
1600
- #
1601
- # REXML::Element.new('foo') # => <foo/>
1602
- #
1603
- # When only argument +element+ is given, it must be an \REXML::Element object;
1604
- # returns a shallow copy of the given element:
1605
- #
1606
- # e0 = REXML::Element.new('foo')
1607
- # e1 = REXML::Element.new(e0) # => <foo/>
1608
- #
1609
- # When argument +parent+ is also given, it must be an REXML::Parent object:
1610
- #
1611
- # e = REXML::Element.new('foo', REXML::Parent.new)
1612
- # e.parent # => #<REXML::Parent @parent=nil, @children=[<foo/>]>
1613
- #
1614
- # When argument +context+ is also given, it must be a hash
1615
- # representing the context for the element;
1616
- # see {Element Context}[../doc/rexml/context_rdoc.html]:
1617
- #
1618
- # e = REXML::Element.new('foo', nil, {raw: :all})
1619
- # e.context # => {:raw=>:all}
1620
- #
1621
- # @return [Element] a new instance of Element
1622
- #
1623
- # source://rexml//lib/rexml/element.rb#327
1624
- def initialize(arg = T.unsafe(nil), parent = T.unsafe(nil), context = T.unsafe(nil)); end
1625
-
1626
- # :call-seq:
1627
- # [index] -> object
1628
- # [attr_name] -> attr_value
1629
- # [attr_sym] -> attr_value
1630
- #
1631
- # With integer argument +index+ given,
1632
- # returns the child at offset +index+, or +nil+ if none:
1633
- #
1634
- # d = REXML::Document.new '><root><a/>text<b/>more<c/></root>'
1635
- # root = d.root
1636
- # (0..root.size).each do |index|
1637
- # node = root[index]
1638
- # p "#{index}: #{node} (#{node.class})"
1639
- # end
1640
- #
1641
- # Output:
1642
- #
1643
- # "0: <a/> (REXML::Element)"
1644
- # "1: text (REXML::Text)"
1645
- # "2: <b/> (REXML::Element)"
1646
- # "3: more (REXML::Text)"
1647
- # "4: <c/> (REXML::Element)"
1648
- # "5: (NilClass)"
1649
- #
1650
- # With string argument +attr_name+ given,
1651
- # returns the string value for the given attribute name if it exists,
1652
- # otherwise +nil+:
1653
- #
1654
- # d = REXML::Document.new('<root attr="value"></root>')
1655
- # root = d.root
1656
- # root['attr'] # => "value"
1657
- # root['nosuch'] # => nil
1658
- #
1659
- # With symbol argument +attr_sym+ given,
1660
- # returns <tt>[attr_sym.to_s]</tt>:
1661
- #
1662
- # root[:attr] # => "value"
1663
- # root[:nosuch] # => nil
1664
- #
1665
- # source://rexml//lib/rexml/element.rb#1245
1666
- def [](name_or_index); end
1667
-
1668
- # :call-seq:
1669
- # add_attribute(name, value) -> value
1670
- # add_attribute(attribute) -> attribute
1671
- #
1672
- # Adds an attribute to this element, overwriting any existing attribute
1673
- # by the same name.
1674
- #
1675
- # With string argument +name+ and object +value+ are given,
1676
- # adds the attribute created with that name and value:
1677
- #
1678
- # e = REXML::Element.new
1679
- # e.add_attribute('attr', 'value') # => "value"
1680
- # e['attr'] # => "value"
1681
- # e.add_attribute('attr', 'VALUE') # => "VALUE"
1682
- # e['attr'] # => "VALUE"
1683
- #
1684
- # With only attribute object +attribute+ given,
1685
- # adds the given attribute:
1686
- #
1687
- # a = REXML::Attribute.new('attr', 'value')
1688
- # e.add_attribute(a) # => attr='value'
1689
- # e['attr'] # => "value"
1690
- # a = REXML::Attribute.new('attr', 'VALUE')
1691
- # e.add_attribute(a) # => attr='VALUE'
1692
- # e['attr'] # => "VALUE"
1693
- #
1694
- # source://rexml//lib/rexml/element.rb#1349
1695
- def add_attribute(key, value = T.unsafe(nil)); end
1696
-
1697
- # :call-seq:
1698
- # add_attributes(hash) -> hash
1699
- # add_attributes(array)
1700
- #
1701
- # Adds zero or more attributes to the element;
1702
- # returns the argument.
1703
- #
1704
- # If hash argument +hash+ is given,
1705
- # each key must be a string;
1706
- # adds each attribute created with the key/value pair:
1707
- #
1708
- # e = REXML::Element.new
1709
- # h = {'foo' => 'bar', 'baz' => 'bat'}
1710
- # e.add_attributes(h)
1711
- #
1712
- # If argument +array+ is given,
1713
- # each array member must be a 2-element array <tt>[name, value];
1714
- # each name must be a string:
1715
- #
1716
- # e = REXML::Element.new
1717
- # a = [['foo' => 'bar'], ['baz' => 'bat']]
1718
- # e.add_attributes(a)
1719
- #
1720
- # source://rexml//lib/rexml/element.rb#1380
1721
- def add_attributes(hash); end
1722
-
1723
- # :call-seq:
1724
- # add_element(name, attributes = nil) -> new_element
1725
- # add_element(element, attributes = nil) -> element
1726
- #
1727
- # Adds a child element, optionally setting attributes
1728
- # on the added element; returns the added element.
1729
- #
1730
- # With string argument +name+, creates a new element with that name
1731
- # and adds the new element as a child:
1732
- #
1733
- # e0 = REXML::Element.new('foo')
1734
- # e0.add_element('bar')
1735
- # e0[0] # => <bar/>
1736
- #
1737
- #
1738
- # With argument +name+ and hash argument +attributes+,
1739
- # sets attributes on the new element:
1740
- #
1741
- # e0.add_element('baz', {'bat' => '0', 'bam' => '1'})
1742
- # e0[1] # => <baz bat='0' bam='1'/>
1743
- #
1744
- # With element argument +element+, adds that element as a child:
1745
- #
1746
- # e0 = REXML::Element.new('foo')
1747
- # e1 = REXML::Element.new('bar')
1748
- # e0.add_element(e1)
1749
- # e0[0] # => <bar/>
1750
- #
1751
- # With argument +element+ and hash argument +attributes+,
1752
- # sets attributes on the added element:
1753
- #
1754
- # e0.add_element(e1, {'bat' => '0', 'bam' => '1'})
1755
- # e0[1] # => <bar bat='0' bam='1'/>
1756
- #
1757
- # source://rexml//lib/rexml/element.rb#731
1758
- def add_element(element, attrs = T.unsafe(nil)); end
1759
-
1760
- # :call-seq:
1761
- # add_namespace(prefix, uri = nil) -> self
1762
- #
1763
- # Adds a namespace to the element; returns +self+.
1764
- #
1765
- # With the single argument +prefix+,
1766
- # adds a namespace using the given +prefix+ and the namespace URI:
1767
- #
1768
- # e = REXML::Element.new('foo')
1769
- # e.add_namespace('bar')
1770
- # e.namespaces # => {"xmlns"=>"bar"}
1771
- #
1772
- # With both arguments +prefix+ and +uri+ given,
1773
- # adds a namespace using both arguments:
1774
- #
1775
- # e.add_namespace('baz', 'bat')
1776
- # e.namespaces # => {"xmlns"=>"bar", "baz"=>"bat"}
1777
- #
1778
- # source://rexml//lib/rexml/element.rb#654
1779
- def add_namespace(prefix, uri = T.unsafe(nil)); end
1780
-
1781
- # :call-seq:
1782
- # add_text(string) -> nil
1783
- # add_text(text_node) -> self
1784
- #
1785
- # Adds text to the element.
1786
- #
1787
- # When string argument +string+ is given, returns +nil+.
1788
- #
1789
- # If the element has no child text node,
1790
- # creates a \REXML::Text object using the string,
1791
- # honoring the current settings for whitespace and raw,
1792
- # then adds that node to the element:
1793
- #
1794
- # d = REXML::Document.new('<a><b/></a>')
1795
- # a = d.root
1796
- # a.add_text('foo')
1797
- # a.to_a # => [<b/>, "foo"]
1798
- #
1799
- # If the element has child text nodes,
1800
- # appends the string to the _last_ text node:
1801
- #
1802
- # d = REXML::Document.new('<a>foo<b/>bar</a>')
1803
- # a = d.root
1804
- # a.add_text('baz')
1805
- # a.to_a # => ["foo", <b/>, "barbaz"]
1806
- # a.add_text('baz')
1807
- # a.to_a # => ["foo", <b/>, "barbazbaz"]
1808
- #
1809
- # When text node argument +text_node+ is given,
1810
- # appends the node as the last text node in the element;
1811
- # returns +self+:
1812
- #
1813
- # d = REXML::Document.new('<a>foo<b/>bar</a>')
1814
- # a = d.root
1815
- # a.add_text(REXML::Text.new('baz'))
1816
- # a.to_a # => ["foo", <b/>, "bar", "baz"]
1817
- # a.add_text(REXML::Text.new('baz'))
1818
- # a.to_a # => ["foo", <b/>, "bar", "baz", "baz"]
1819
- #
1820
- # source://rexml//lib/rexml/element.rb#1146
1821
- def add_text(text); end
1822
-
1823
- # :call-seq:
1824
- # attribute(name, namespace = nil)
1825
- #
1826
- # Returns the string value for the given attribute name.
1827
- #
1828
- # With only argument +name+ given,
1829
- # returns the value of the named attribute if it exists, otherwise +nil+:
1830
- #
1831
- # xml_string = <<-EOT
1832
- # <root xmlns="ns0">
1833
- # <a xmlns="ns1" attr="value"></a>
1834
- # <b xmlns="ns2" attr="value"></b>
1835
- # <c attr="value"/>
1836
- # </root>
1837
- # EOT
1838
- # d = REXML::Document.new(xml_string)
1839
- # root = d.root
1840
- # a = root[1] # => <a xmlns='ns1' attr='value'/>
1841
- # a.attribute('attr') # => attr='value'
1842
- # a.attribute('nope') # => nil
1843
- #
1844
- # With arguments +name+ and +namespace+ given,
1845
- # returns the value of the named attribute if it exists, otherwise +nil+:
1846
- #
1847
- # xml_string = "<root xmlns:a='a' a:x='a:x' x='x'/>"
1848
- # document = REXML::Document.new(xml_string)
1849
- # document.root.attribute("x") # => x='x'
1850
- # document.root.attribute("x", "a") # => a:x='a:x'
1851
- #
1852
- # source://rexml//lib/rexml/element.rb#1286
1853
- def attribute(name, namespace = T.unsafe(nil)); end
1854
-
1855
- # Mechanisms for accessing attributes and child elements of this
1856
- # element.
1857
- #
1858
- # source://rexml//lib/rexml/element.rb#286
1859
- def attributes; end
1860
-
1861
- # :call-seq:
1862
- # cdatas -> array_of_cdata_children
1863
- #
1864
- # Returns a frozen array of the REXML::CData children of the element:
1865
- #
1866
- # xml_string = <<-EOT
1867
- # <root>
1868
- # <![CDATA[foo]]>
1869
- # <![CDATA[bar]]>
1870
- # </root>
1871
- # EOT
1872
- # d = REXML::Document.new(xml_string)
1873
- # cds = d.root.cdatas # => ["foo", "bar"]
1874
- # cds.frozen? # => true
1875
- # cds.map {|cd| cd.class } # => [REXML::CData, REXML::CData]
1876
- #
1877
- # source://rexml//lib/rexml/element.rb#1424
1878
- def cdatas; end
1879
-
1880
- # :call-seq:
1881
- # clone -> new_element
1882
- #
1883
- # Returns a shallow copy of the element, containing the name and attributes,
1884
- # but not the parent or children:
1885
- #
1886
- # e = REXML::Element.new('foo')
1887
- # e.add_attributes({'bar' => 0, 'baz' => 1})
1888
- # e.clone # => <foo bar='0' baz='1'/>
1889
- #
1890
- # source://rexml//lib/rexml/element.rb#391
1891
- def clone; end
1892
-
1893
- # :call-seq:
1894
- # comments -> array_of_comment_children
1895
- #
1896
- # Returns a frozen array of the REXML::Comment children of the element:
1897
- #
1898
- # xml_string = <<-EOT
1899
- # <root>
1900
- # <!--foo-->
1901
- # <!--bar-->
1902
- # </root>
1903
- # EOT
1904
- # d = REXML::Document.new(xml_string)
1905
- # cs = d.root.comments
1906
- # cs.frozen? # => true
1907
- # cs.map {|c| c.class } # => [REXML::Comment, REXML::Comment]
1908
- # cs.map {|c| c.to_s } # => ["foo", "bar"]
1909
- #
1910
- # source://rexml//lib/rexml/element.rb#1445
1911
- def comments; end
1912
-
1913
- # The context holds information about the processing environment, such as
1914
- # whitespace handling.
1915
- #
1916
- # source://rexml//lib/rexml/element.rb#289
1917
- def context; end
1918
-
1919
- # The context holds information about the processing environment, such as
1920
- # whitespace handling.
1921
- #
1922
- # source://rexml//lib/rexml/element.rb#289
1923
- def context=(_arg0); end
1924
-
1925
- # :call-seq:
1926
- # delete_attribute(name) -> removed_attribute or nil
1927
- #
1928
- # Removes a named attribute if it exists;
1929
- # returns the removed attribute if found, otherwise +nil+:
1930
- #
1931
- # e = REXML::Element.new('foo')
1932
- # e.add_attribute('bar', 'baz')
1933
- # e.delete_attribute('bar') # => <bar/>
1934
- # e.delete_attribute('bar') # => nil
1935
- #
1936
- # source://rexml//lib/rexml/element.rb#1399
1937
- def delete_attribute(key); end
1938
-
1939
- # :call-seq:
1940
- # delete_element(index) -> removed_element or nil
1941
- # delete_element(element) -> removed_element or nil
1942
- # delete_element(xpath) -> removed_element or nil
1943
- #
1944
- # Deletes a child element.
1945
- #
1946
- # When 1-based integer argument +index+ is given,
1947
- # removes and returns the child element at that offset if it exists;
1948
- # indexing does not include text nodes;
1949
- # returns +nil+ if the element does not exist:
1950
- #
1951
- # d = REXML::Document.new '<a><b/>text<c/></a>'
1952
- # a = d.root # => <a> ... </>
1953
- # a.delete_element(1) # => <b/>
1954
- # a.delete_element(1) # => <c/>
1955
- # a.delete_element(1) # => nil
1956
- #
1957
- # When element argument +element+ is given,
1958
- # removes and returns that child element if it exists,
1959
- # otherwise returns +nil+:
1960
- #
1961
- # d = REXML::Document.new '<a><b/>text<c/></a>'
1962
- # a = d.root # => <a> ... </>
1963
- # c = a[2] # => <c/>
1964
- # a.delete_element(c) # => <c/>
1965
- # a.delete_element(c) # => nil
1966
- #
1967
- # When xpath argument +xpath+ is given,
1968
- # removes and returns the element at xpath if it exists,
1969
- # otherwise returns +nil+:
1970
- #
1971
- # d = REXML::Document.new '<a><b/>text<c/></a>'
1972
- # a = d.root # => <a> ... </>
1973
- # a.delete_element('//c') # => <c/>
1974
- # a.delete_element('//c') # => nil
1975
- #
1976
- # source://rexml//lib/rexml/element.rb#777
1977
- def delete_element(element); end
1978
-
1979
- # :call-seq:
1980
- # delete_namespace(namespace = 'xmlns') -> self
1981
- #
1982
- # Removes a namespace from the element.
1983
- #
1984
- # With no argument, removes the default namespace:
1985
- #
1986
- # d = REXML::Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
1987
- # d.to_s # => "<a xmlns:foo='bar' xmlns='twiddle'/>"
1988
- # d.root.delete_namespace # => <a xmlns:foo='bar'/>
1989
- # d.to_s # => "<a xmlns:foo='bar'/>"
1990
- #
1991
- # With argument +namespace+, removes the specified namespace:
1992
- #
1993
- # d.root.delete_namespace('foo')
1994
- # d.to_s # => "<a/>"
1995
- #
1996
- # Does nothing if no such namespace is found:
1997
- #
1998
- # d.root.delete_namespace('nosuch')
1999
- # d.to_s # => "<a/>"
2000
- #
2001
- # source://rexml//lib/rexml/element.rb#686
2002
- def delete_namespace(namespace = T.unsafe(nil)); end
2003
-
2004
- # :call-seq:
2005
- # document -> document or nil
2006
- #
2007
- # If the element is part of a document, returns that document:
2008
- #
2009
- # d = REXML::Document.new('<a><b><c/></b></a>')
2010
- # top_element = d.first
2011
- # child = top_element.first
2012
- # top_element.document == d # => true
2013
- # child.document == d # => true
2014
- #
2015
- # If the element is not part of a document, returns +nil+:
2016
- #
2017
- # REXML::Element.new.document # => nil
2018
- #
2019
- # For a document, returns +self+:
2020
- #
2021
- # d.document == d # => true
2022
- #
2023
- # Related: #root, #root_node.
2024
- #
2025
- # source://rexml//lib/rexml/element.rb#478
2026
- def document; end
2027
-
2028
- # :call-seq:
2029
- # each_element {|e| ... }
2030
- #
2031
- # Calls the given block with each child element:
2032
- #
2033
- # d = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
2034
- # a = d.root
2035
- # a.each_element {|e| p e }
2036
- #
2037
- # Output:
2038
- #
2039
- # <b> ... </>
2040
- # <c> ... </>
2041
- # <d> ... </>
2042
- # <e/>
2043
- #
2044
- # source://rexml//lib/rexml/element.rb#929
2045
- def each_element(xpath = T.unsafe(nil), &block); end
2046
-
2047
- # :call-seq:
2048
- # each_element_with_attribute(attr_name, value = nil, max = 0, xpath = nil) {|e| ... }
2049
- #
2050
- # Calls the given block with each child element that meets given criteria.
2051
- #
2052
- # When only string argument +attr_name+ is given,
2053
- # calls the block with each child element that has that attribute:
2054
- #
2055
- # d = REXML::Document.new '<a><b id="1"/><c id="2"/><d id="1"/><e/></a>'
2056
- # a = d.root
2057
- # a.each_element_with_attribute('id') {|e| p e }
2058
- #
2059
- # Output:
2060
- #
2061
- # <b id='1'/>
2062
- # <c id='2'/>
2063
- # <d id='1'/>
2064
- #
2065
- # With argument +attr_name+ and string argument +value+ given,
2066
- # calls the block with each child element that has that attribute
2067
- # with that value:
2068
- #
2069
- # a.each_element_with_attribute('id', '1') {|e| p e }
2070
- #
2071
- # Output:
2072
- #
2073
- # <b id='1'/>
2074
- # <d id='1'/>
2075
- #
2076
- # With arguments +attr_name+, +value+, and integer argument +max+ given,
2077
- # calls the block with at most +max+ child elements:
2078
- #
2079
- # a.each_element_with_attribute('id', '1', 1) {|e| p e }
2080
- #
2081
- # Output:
2082
- #
2083
- # <b id='1'/>
2084
- #
2085
- # With all arguments given, including +xpath+,
2086
- # calls the block with only those child elements
2087
- # that meet the first three criteria,
2088
- # and also match the given +xpath+:
2089
- #
2090
- # a.each_element_with_attribute('id', '1', 2, '//d') {|e| p e }
2091
- #
2092
- # Output:
2093
- #
2094
- # <d id='1'/>
2095
- #
2096
- # source://rexml//lib/rexml/element.rb#846
2097
- def each_element_with_attribute(key, value = T.unsafe(nil), max = T.unsafe(nil), name = T.unsafe(nil), &block); end
2098
-
2099
- # :call-seq:
2100
- # each_element_with_text(text = nil, max = 0, xpath = nil) {|e| ... }
2101
- #
2102
- # Calls the given block with each child element that meets given criteria.
2103
- #
2104
- # With no arguments, calls the block with each child element that has text:
2105
- #
2106
- # d = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
2107
- # a = d.root
2108
- # a.each_element_with_text {|e| p e }
2109
- #
2110
- # Output:
2111
- #
2112
- # <b> ... </>
2113
- # <c> ... </>
2114
- # <d> ... </>
2115
- #
2116
- # With the single string argument +text+,
2117
- # calls the block with each element that has exactly that text:
2118
- #
2119
- # a.each_element_with_text('b') {|e| p e }
2120
- #
2121
- # Output:
2122
- #
2123
- # <b> ... </>
2124
- # <c> ... </>
2125
- #
2126
- # With argument +text+ and integer argument +max+,
2127
- # calls the block with at most +max+ elements:
2128
- #
2129
- # a.each_element_with_text('b', 1) {|e| p e }
2130
- #
2131
- # Output:
2132
- #
2133
- # <b> ... </>
2134
- #
2135
- # With all arguments given, including +xpath+,
2136
- # calls the block with only those child elements
2137
- # that meet the first two criteria,
2138
- # and also match the given +xpath+:
2139
- #
2140
- # a.each_element_with_text('b', 2, '//c') {|e| p e }
2141
- #
2142
- # Output:
2143
- #
2144
- # <c> ... </>
2145
- #
2146
- # source://rexml//lib/rexml/element.rb#903
2147
- def each_element_with_text(text = T.unsafe(nil), max = T.unsafe(nil), name = T.unsafe(nil), &block); end
2148
-
2149
- # Mechanisms for accessing attributes and child elements of this
2150
- # element.
2151
- #
2152
- # source://rexml//lib/rexml/element.rb#286
2153
- def elements; end
2154
-
2155
- # :call-seq:
2156
- # get_elements(xpath)
2157
- #
2158
- # Returns an array of the elements that match the given +xpath+:
2159
- #
2160
- # xml_string = <<-EOT
2161
- # <root>
2162
- # <a level='1'>
2163
- # <a level='2'/>
2164
- # </a>
2165
- # </root>
2166
- # EOT
2167
- # d = REXML::Document.new(xml_string)
2168
- # d.root.get_elements('//a') # => [<a level='1'> ... </>, <a level='2'/>]
2169
- #
2170
- # source://rexml//lib/rexml/element.rb#948
2171
- def get_elements(xpath); end
2172
-
2173
- # :call-seq:
2174
- # get_text(xpath = nil) -> text_node or nil
2175
- #
2176
- # Returns the first text node child in a specified element, if it exists,
2177
- # +nil+ otherwise.
2178
- #
2179
- # With no argument, returns the first text node from +self+:
2180
- #
2181
- # d = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
2182
- # d.root.get_text.class # => REXML::Text
2183
- # d.root.get_text # => "some text "
2184
- #
2185
- # With argument +xpath+, returns the first text node from the element
2186
- # that matches +xpath+:
2187
- #
2188
- # d.root.get_text(1) # => "this is bold!"
2189
- #
2190
- # source://rexml//lib/rexml/element.rb#1052
2191
- def get_text(path = T.unsafe(nil)); end
2192
-
2193
- # :call-seq:
2194
- # has_attributes? -> true or false
2195
- #
2196
- # Returns +true+ if the element has attributes, +false+ otherwise:
2197
- #
2198
- # d = REXML::Document.new('<root><a attr="val"/><b/></root>')
2199
- # a, b = *d.root
2200
- # a.has_attributes? # => true
2201
- # b.has_attributes? # => false
2202
- #
2203
- # @return [Boolean]
2204
- #
2205
- # source://rexml//lib/rexml/element.rb#1319
2206
- def has_attributes?; end
2207
-
2208
- # :call-seq:
2209
- # has_elements?
2210
- #
2211
- # Returns +true+ if the element has one or more element children,
2212
- # +false+ otherwise:
2213
- #
2214
- # d = REXML::Document.new '<a><b/>text<c/></a>'
2215
- # a = d.root # => <a> ... </>
2216
- # a.has_elements? # => true
2217
- # b = a[0] # => <b/>
2218
- # b.has_elements? # => false
2219
- #
2220
- # @return [Boolean]
2221
- #
2222
- # source://rexml//lib/rexml/element.rb#793
2223
- def has_elements?; end
2224
-
2225
- # :call-seq:
2226
- # has_text? -> true or false
2227
- #
2228
- # Returns +true if the element has one or more text noded,
2229
- # +false+ otherwise:
2230
- #
2231
- # d = REXML::Document.new '<a><b/>text<c/></a>'
2232
- # a = d.root
2233
- # a.has_text? # => true
2234
- # b = a[0]
2235
- # b.has_text? # => false
2236
- #
2237
- # @return [Boolean]
2238
- #
2239
- # source://rexml//lib/rexml/element.rb#1001
2240
- def has_text?; end
2241
-
2242
- # :call-seq:
2243
- # ignore_whitespace_nodes
2244
- #
2245
- # Returns +true+ if whitespace nodes are ignored for the element.
2246
- #
2247
- # See {Element Context}[../doc/rexml/context_rdoc.html].
2248
- #
2249
- # source://rexml//lib/rexml/element.rb#516
2250
- def ignore_whitespace_nodes; end
2251
-
2252
- # :call-seq:
2253
- # inspect -> string
2254
- #
2255
- # Returns a string representation of the element.
2256
- #
2257
- # For an element with no attributes and no children, shows the element name:
2258
- #
2259
- # REXML::Element.new.inspect # => "<UNDEFINED/>"
2260
- #
2261
- # Shows attributes, if any:
2262
- #
2263
- # e = REXML::Element.new('foo')
2264
- # e.add_attributes({'bar' => 0, 'baz' => 1})
2265
- # e.inspect # => "<foo bar='0' baz='1'/>"
2266
- #
2267
- # Shows an ellipsis (<tt>...</tt>), if there are child elements:
2268
- #
2269
- # e.add_element(REXML::Element.new('bar'))
2270
- # e.add_element(REXML::Element.new('baz'))
2271
- # e.inspect # => "<foo bar='0' baz='1'> ... </>"
2272
- #
2273
- # source://rexml//lib/rexml/element.rb#366
2274
- def inspect; end
2275
-
2276
- # :call-seq:
2277
- # instructions -> array_of_instruction_children
2278
- #
2279
- # Returns a frozen array of the REXML::Instruction children of the element:
2280
- #
2281
- # xml_string = <<-EOT
2282
- # <root>
2283
- # <?target0 foo?>
2284
- # <?target1 bar?>
2285
- # </root>
2286
- # EOT
2287
- # d = REXML::Document.new(xml_string)
2288
- # is = d.root.instructions
2289
- # is.frozen? # => true
2290
- # is.map {|i| i.class } # => [REXML::Instruction, REXML::Instruction]
2291
- # is.map {|i| i.to_s } # => ["<?target0 foo?>", "<?target1 bar?>"]
2292
- #
2293
- # source://rexml//lib/rexml/element.rb#1466
2294
- def instructions; end
2295
-
2296
- # :call-seq:
2297
- # namespace(prefix = nil) -> string_uri or nil
2298
- #
2299
- # Returns the string namespace URI for the element,
2300
- # possibly deriving from one of its ancestors.
2301
- #
2302
- # xml_string = <<-EOT
2303
- # <root>
2304
- # <a xmlns='1' xmlns:y='2'>
2305
- # <b/>
2306
- # <c xmlns:z='3'/>
2307
- # </a>
2308
- # </root>
2309
- # EOT
2310
- # d = REXML::Document.new(xml_string)
2311
- # b = d.elements['//b']
2312
- # b.namespace # => "1"
2313
- # b.namespace('y') # => "2"
2314
- # b.namespace('nosuch') # => nil
2315
- #
2316
- # source://rexml//lib/rexml/element.rb#621
2317
- def namespace(prefix = T.unsafe(nil)); end
2318
-
2319
- # :call-seq:
2320
- # namespaces -> array_of_namespace_names
2321
- #
2322
- # Returns a hash of all defined namespaces
2323
- # in the element and its ancestors:
2324
- #
2325
- # xml_string = <<-EOT
2326
- # <root>
2327
- # <a xmlns:x='1' xmlns:y='2'>
2328
- # <b/>
2329
- # <c xmlns:z='3'/>
2330
- # </a>
2331
- # </root>
2332
- # EOT
2333
- # d = REXML::Document.new(xml_string)
2334
- # d.elements['//a'].namespaces # => {"x"=>"1", "y"=>"2"}
2335
- # d.elements['//b'].namespaces # => {"x"=>"1", "y"=>"2"}
2336
- # d.elements['//c'].namespaces # => {"x"=>"1", "y"=>"2", "z"=>"3"}
2337
- #
2338
- # source://rexml//lib/rexml/element.rb#594
2339
- def namespaces; end
2340
-
2341
- # :call-seq:
2342
- # next_element
2343
- #
2344
- # Returns the next sibling that is an element if it exists,
2345
- # +niL+ otherwise:
2346
- #
2347
- # d = REXML::Document.new '<a><b/>text<c/></a>'
2348
- # d.root.elements['b'].next_element #-> <c/>
2349
- # d.root.elements['c'].next_element #-> nil
2350
- #
2351
- # source://rexml//lib/rexml/element.rb#962
2352
- def next_element; end
2353
-
2354
- # :call-seq:
2355
- # node_type -> :element
2356
- #
2357
- # Returns symbol <tt>:element</tt>:
2358
- #
2359
- # d = REXML::Document.new('<a/>')
2360
- # a = d.root # => <a/>
2361
- # a.node_type # => :element
2362
- #
2363
- # source://rexml//lib/rexml/element.rb#1167
2364
- def node_type; end
2365
-
2366
- # :call-seq:
2367
- # prefixes -> array_of_namespace_prefixes
2368
- #
2369
- # Returns an array of the string prefixes (names) of all defined namespaces
2370
- # in the element and its ancestors:
2371
- #
2372
- # xml_string = <<-EOT
2373
- # <root>
2374
- # <a xmlns:x='1' xmlns:y='2'>
2375
- # <b/>
2376
- # <c xmlns:z='3'/>
2377
- # </a>
2378
- # </root>
2379
- # EOT
2380
- # d = REXML::Document.new(xml_string, {compress_whitespace: :all})
2381
- # d.elements['//a'].prefixes # => ["x", "y"]
2382
- # d.elements['//b'].prefixes # => ["x", "y"]
2383
- # d.elements['//c'].prefixes # => ["x", "y", "z"]
2384
- #
2385
- # source://rexml//lib/rexml/element.rb#568
2386
- def prefixes; end
2387
-
2388
- # :call-seq:
2389
- # previous_element
2390
- #
2391
- # Returns the previous sibling that is an element if it exists,
2392
- # +niL+ otherwise:
2393
- #
2394
- # d = REXML::Document.new '<a><b/>text<c/></a>'
2395
- # d.root.elements['c'].previous_element #-> <b/>
2396
- # d.root.elements['b'].previous_element #-> nil
2397
- #
2398
- # source://rexml//lib/rexml/element.rb#978
2399
- def previous_element; end
2400
-
2401
- # :call-seq:
2402
- # raw
2403
- #
2404
- # Returns +true+ if raw mode is set for the element.
2405
- #
2406
- # See {Element Context}[../doc/rexml/context_rdoc.html].
2407
- #
2408
- # The evaluation is tested against +expanded_name+, and so is namespace
2409
- # sensitive.
2410
- #
2411
- # source://rexml//lib/rexml/element.rb#536
2412
- def raw; end
2413
-
2414
- # :call-seq:
2415
- # root -> element
2416
- #
2417
- # Returns the most distant _element_ (not document) ancestor of the element:
2418
- #
2419
- # d = REXML::Document.new('<a><b><c/></b></a>')
2420
- # top_element = d.first
2421
- # child = top_element.first
2422
- # top_element.root == top_element # => true
2423
- # child.root == top_element # => true
2424
- #
2425
- # For a document, returns the topmost element:
2426
- #
2427
- # d.root == top_element # => true
2428
- #
2429
- # Related: #root_node, #document.
2430
- #
2431
- # source://rexml//lib/rexml/element.rb#451
2432
- def root; end
2433
-
2434
- # :call-seq:
2435
- # root_node -> document or element
2436
- #
2437
- # Returns the most distant ancestor of +self+.
2438
- #
2439
- # When the element is part of a document,
2440
- # returns the root node of the document.
2441
- # Note that the root node is different from the document element;
2442
- # in this example +a+ is document element and the root node is its parent:
2443
- #
2444
- # d = REXML::Document.new('<a><b><c/></b></a>')
2445
- # top_element = d.first # => <a> ... </>
2446
- # child = top_element.first # => <b> ... </>
2447
- # d.root_node == d # => true
2448
- # top_element.root_node == d # => true
2449
- # child.root_node == d # => true
2450
- #
2451
- # When the element is not part of a document, but does have ancestor elements,
2452
- # returns the most distant ancestor element:
2453
- #
2454
- # e0 = REXML::Element.new('foo')
2455
- # e1 = REXML::Element.new('bar')
2456
- # e1.parent = e0
2457
- # e2 = REXML::Element.new('baz')
2458
- # e2.parent = e1
2459
- # e2.root_node == e0 # => true
2460
- #
2461
- # When the element has no ancestor elements,
2462
- # returns +self+:
2463
- #
2464
- # e = REXML::Element.new('foo')
2465
- # e.root_node == e # => true
2466
- #
2467
- # Related: #root, #document.
2468
- #
2469
- # source://rexml//lib/rexml/element.rb#430
2470
- def root_node; end
2471
-
2472
- # :call-seq:
2473
- # text(xpath = nil) -> text_string or nil
2474
- #
2475
- # Returns the text string from the first text node child
2476
- # in a specified element, if it exists, # +nil+ otherwise.
2477
- #
2478
- # With no argument, returns the text from the first text node in +self+:
2479
- #
2480
- # d = REXML::Document.new "<p>some text <b>this is bold!</b> more text</p>"
2481
- # d.root.text.class # => String
2482
- # d.root.text # => "some text "
2483
- #
2484
- # With argument +xpath+, returns text from the the first text node
2485
- # in the element that matches +xpath+:
2486
- #
2487
- # d.root.text(1) # => "this is bold!"
2488
- #
2489
- # Note that an element may have multiple text nodes,
2490
- # possibly separated by other non-text children, as above.
2491
- # Even so, the returned value is the string text from the first such node.
2492
- #
2493
- # Note also that the text note is retrieved by method get_text,
2494
- # and so is always normalized text.
2495
- #
2496
- # source://rexml//lib/rexml/element.rb#1029
2497
- def text(path = T.unsafe(nil)); end
2498
-
2499
- # :call-seq:
2500
- # text = string -> string
2501
- # text = nil -> nil
2502
- #
2503
- # Adds, replaces, or removes the first text node child in the element.
2504
- #
2505
- # With string argument +string+,
2506
- # creates a new \REXML::Text node containing that string,
2507
- # honoring the current settings for whitespace and row,
2508
- # then places the node as the first text child in the element;
2509
- # returns +string+.
2510
- #
2511
- # If the element has no text child, the text node is added:
2512
- #
2513
- # d = REXML::Document.new '<a><b/></a>'
2514
- # d.root.text = 'foo' #-> '<a><b/>foo</a>'
2515
- #
2516
- # If the element has a text child, it is replaced:
2517
- #
2518
- # d.root.text = 'bar' #-> '<a><b/>bar</a>'
2519
- #
2520
- # With argument +nil+, removes the first text child:
2521
- #
2522
- # d.root.text = nil #-> '<a><b/><c/></a>'
2523
- #
2524
- # source://rexml//lib/rexml/element.rb#1088
2525
- def text=(text); end
2526
-
2527
- # :call-seq:
2528
- # texts -> array_of_text_children
2529
- #
2530
- # Returns a frozen array of the REXML::Text children of the element:
2531
- #
2532
- # xml_string = '<root><a/>text<b/>more<c/></root>'
2533
- # d = REXML::Document.new(xml_string)
2534
- # ts = d.root.texts
2535
- # ts.frozen? # => true
2536
- # ts.map {|t| t.class } # => [REXML::Text, REXML::Text]
2537
- # ts.map {|t| t.to_s } # => ["text", "more"]
2538
- #
2539
- # source://rexml//lib/rexml/element.rb#1482
2540
- def texts; end
2541
-
2542
- # :call-seq:
2543
- # whitespace
2544
- #
2545
- # Returns +true+ if whitespace is respected for this element,
2546
- # +false+ otherwise.
2547
- #
2548
- # See {Element Context}[../doc/rexml/context_rdoc.html].
2549
- #
2550
- # The evaluation is tested against the element's +expanded_name+,
2551
- # and so is namespace-sensitive.
2552
- #
2553
- # source://rexml//lib/rexml/element.rb#493
2554
- def whitespace; end
2555
-
2556
- # == DEPRECATED
2557
- # See REXML::Formatters
2558
- #
2559
- # Writes out this element, and recursively, all children.
2560
- # output::
2561
- # output an object which supports '<< string'; this is where the
2562
- # document will be written.
2563
- # indent::
2564
- # An integer. If -1, no indenting will be used; otherwise, the
2565
- # indentation will be this number of spaces, and children will be
2566
- # indented an additional amount. Defaults to -1
2567
- # transitive::
2568
- # If transitive is true and indent is >= 0, then the output will be
2569
- # pretty-printed in such a way that the added whitespace does not affect
2570
- # the parse tree of the document
2571
- # ie_hack::
2572
- # This hack inserts a space before the /> on empty tags to address
2573
- # a limitation of Internet Explorer. Defaults to false
2574
- #
2575
- # out = ''
2576
- # doc.write( out ) #-> doc is written to the string 'out'
2577
- # doc.write( $stdout ) #-> doc written to the console
2578
- #
2579
- # source://rexml//lib/rexml/element.rb#1508
2580
- def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
2581
-
2582
- # :call-seq:
2583
- # xpath -> string_xpath
2584
- #
2585
- # Returns the string xpath to the element
2586
- # relative to the most distant parent:
2587
- #
2588
- # d = REXML::Document.new('<a><b><c/></b></a>')
2589
- # a = d.root # => <a> ... </>
2590
- # b = a[0] # => <b> ... </>
2591
- # c = b[0] # => <c/>
2592
- # d.xpath # => ""
2593
- # a.xpath # => "/a"
2594
- # b.xpath # => "/a/b"
2595
- # c.xpath # => "/a/b/c"
2596
- #
2597
- # If there is no parent, returns the expanded name of the element:
2598
- #
2599
- # e = REXML::Element.new('foo')
2600
- # e.xpath # => "foo"
2601
- #
2602
- # source://rexml//lib/rexml/element.rb#1191
2603
- def xpath; end
2604
-
2605
- private
2606
-
2607
- # source://rexml//lib/rexml/element.rb#1525
2608
- def __to_xpath_helper(node); end
2609
-
2610
- # A private helper method
2611
- #
2612
- # source://rexml//lib/rexml/element.rb#1540
2613
- def each_with_something(test, max = T.unsafe(nil), name = T.unsafe(nil)); end
2614
- end
2615
-
2616
- # source://rexml//lib/rexml/doctype.rb#261
2617
- class REXML::ElementDecl < ::REXML::Declaration
2618
- # @return [ElementDecl] a new instance of ElementDecl
2619
- #
2620
- # source://rexml//lib/rexml/doctype.rb#262
2621
- def initialize(src); end
2622
- end
2623
-
2624
- # A class which provides filtering of children for Elements, and
2625
- # XPath search support. You are expected to only encounter this class as
2626
- # the <tt>element.elements</tt> object. Therefore, you are
2627
- # _not_ expected to instantiate this yourself.
2628
- #
2629
- # xml_string = <<-EOT
2630
- # <?xml version="1.0" encoding="UTF-8"?>
2631
- # <bookstore>
2632
- # <book category="cooking">
2633
- # <title lang="en">Everyday Italian</title>
2634
- # <author>Giada De Laurentiis</author>
2635
- # <year>2005</year>
2636
- # <price>30.00</price>
2637
- # </book>
2638
- # <book category="children">
2639
- # <title lang="en">Harry Potter</title>
2640
- # <author>J K. Rowling</author>
2641
- # <year>2005</year>
2642
- # <price>29.99</price>
2643
- # </book>
2644
- # <book category="web">
2645
- # <title lang="en">XQuery Kick Start</title>
2646
- # <author>James McGovern</author>
2647
- # <author>Per Bothner</author>
2648
- # <author>Kurt Cagle</author>
2649
- # <author>James Linn</author>
2650
- # <author>Vaidyanathan Nagarajan</author>
2651
- # <year>2003</year>
2652
- # <price>49.99</price>
2653
- # </book>
2654
- # <book category="web" cover="paperback">
2655
- # <title lang="en">Learning XML</title>
2656
- # <author>Erik T. Ray</author>
2657
- # <year>2003</year>
2658
- # <price>39.95</price>
2659
- # </book>
2660
- # </bookstore>
2661
- # EOT
2662
- # d = REXML::Document.new(xml_string)
2663
- # elements = d.root.elements
2664
- # elements # => #<REXML::Elements @element=<bookstore> ... </>>
2665
- #
2666
- # source://rexml//lib/rexml/element.rb#1595
2667
- class REXML::Elements
2668
- include ::Enumerable
2669
-
2670
- # :call-seq:
2671
- # new(parent) -> new_elements_object
2672
- #
2673
- # Returns a new \Elements object with the given +parent+.
2674
- # Does _not_ assign <tt>parent.elements = self</tt>:
2675
- #
2676
- # d = REXML::Document.new(xml_string)
2677
- # eles = REXML::Elements.new(d.root)
2678
- # eles # => #<REXML::Elements @element=<bookstore> ... </>>
2679
- # eles == d.root.elements # => false
2680
- #
2681
- # @return [Elements] a new instance of Elements
2682
- #
2683
- # source://rexml//lib/rexml/element.rb#1608
2684
- def initialize(parent); end
2685
-
2686
- # :call-seq:
2687
- # add -> new_element
2688
- # add(name) -> new_element
2689
- # add(element) -> element
2690
- #
2691
- # Adds an element; returns the element added.
2692
- #
2693
- # With no argument, creates and adds a new element.
2694
- # The new element has:
2695
- #
2696
- # - No name.
2697
- # - \Parent from the \Elements object.
2698
- # - Context from the that parent.
2699
- #
2700
- # Example:
2701
- #
2702
- # d = REXML::Document.new(xml_string)
2703
- # elements = d.root.elements
2704
- # parent = elements.parent # => <bookstore> ... </>
2705
- # parent.context = {raw: :all}
2706
- # elements.size # => 4
2707
- # new_element = elements.add # => </>
2708
- # elements.size # => 5
2709
- # new_element.name # => nil
2710
- # new_element.parent # => <bookstore> ... </>
2711
- # new_element.context # => {:raw=>:all}
2712
- #
2713
- # With string argument +name+, creates and adds a new element.
2714
- # The new element has:
2715
- #
2716
- # - Name +name+.
2717
- # - \Parent from the \Elements object.
2718
- # - Context from the that parent.
2719
- #
2720
- # Example:
2721
- #
2722
- # d = REXML::Document.new(xml_string)
2723
- # elements = d.root.elements
2724
- # parent = elements.parent # => <bookstore> ... </>
2725
- # parent.context = {raw: :all}
2726
- # elements.size # => 4
2727
- # new_element = elements.add('foo') # => <foo/>
2728
- # elements.size # => 5
2729
- # new_element.name # => "foo"
2730
- # new_element.parent # => <bookstore> ... </>
2731
- # new_element.context # => {:raw=>:all}
2732
- #
2733
- # With argument +element+,
2734
- # creates and adds a clone of the given +element+.
2735
- # The new element has name, parent, and context from the given +element+.
2736
- #
2737
- # d = REXML::Document.new(xml_string)
2738
- # elements = d.root.elements
2739
- # elements.size # => 4
2740
- # e0 = REXML::Element.new('foo')
2741
- # e1 = REXML::Element.new('bar', e0, {raw: :all})
2742
- # element = elements.add(e1) # => <bar/>
2743
- # elements.size # => 5
2744
- # element.name # => "bar"
2745
- # element.parent # => <bookstore> ... </>
2746
- # element.context # => {:raw=>:all}
2747
- #
2748
- # source://rexml//lib/rexml/element.rb#1925
2749
- def <<(element = T.unsafe(nil)); end
2750
-
2751
- # :call-seq:
2752
- # elements[index] -> element or nil
2753
- # elements[xpath] -> element or nil
2754
- # elements[n, name] -> element or nil
2755
- #
2756
- # Returns the first \Element object selected by the arguments,
2757
- # if any found, or +nil+ if none found.
2758
- #
2759
- # Notes:
2760
- # - The +index+ is 1-based, not 0-based, so that:
2761
- # - The first element has index <tt>1</tt>
2762
- # - The _nth_ element has index +n+.
2763
- # - The selection ignores non-\Element nodes.
2764
- #
2765
- # When the single argument +index+ is given,
2766
- # returns the element given by the index, if any; otherwise, +nil+:
2767
- #
2768
- # d = REXML::Document.new(xml_string)
2769
- # eles = d.root.elements
2770
- # eles # => #<REXML::Elements @element=<bookstore> ... </>>
2771
- # eles[1] # => <book category='cooking'> ... </>
2772
- # eles.size # => 4
2773
- # eles[4] # => <book category='web' cover='paperback'> ... </>
2774
- # eles[5] # => nil
2775
- #
2776
- # The node at this index is not an \Element, and so is not returned:
2777
- #
2778
- # eles = d.root.first.first # => <title lang='en'> ... </>
2779
- # eles.to_a # => ["Everyday Italian"]
2780
- # eles[1] # => nil
2781
- #
2782
- # When the single argument +xpath+ is given,
2783
- # returns the first element found via that +xpath+, if any; otherwise, +nil+:
2784
- #
2785
- # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
2786
- # eles['/bookstore'] # => <bookstore> ... </>
2787
- # eles['//book'] # => <book category='cooking'> ... </>
2788
- # eles['//book [@category="children"]'] # => <book category='children'> ... </>
2789
- # eles['/nosuch'] # => nil
2790
- # eles['//nosuch'] # => nil
2791
- # eles['//book [@category="nosuch"]'] # => nil
2792
- # eles['.'] # => <bookstore> ... </>
2793
- # eles['..'].class # => REXML::Document
2794
- #
2795
- # With arguments +n+ and +name+ given,
2796
- # returns the _nth_ found element that has the given +name+,
2797
- # or +nil+ if there is no such _nth_ element:
2798
- #
2799
- # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
2800
- # eles[1, 'book'] # => <book category='cooking'> ... </>
2801
- # eles[4, 'book'] # => <book category='web' cover='paperback'> ... </>
2802
- # eles[5, 'book'] # => nil
2803
- #
2804
- # source://rexml//lib/rexml/element.rb#1680
2805
- def [](index, name = T.unsafe(nil)); end
2806
-
2807
- # :call-seq:
2808
- # elements[] = index, replacement_element -> replacement_element or nil
2809
- #
2810
- # Replaces or adds an element.
2811
- #
2812
- # When <tt>eles[index]</tt> exists, replaces it with +replacement_element+
2813
- # and returns +replacement_element+:
2814
- #
2815
- # d = REXML::Document.new(xml_string)
2816
- # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
2817
- # eles[1] # => <book category='cooking'> ... </>
2818
- # eles[1] = REXML::Element.new('foo')
2819
- # eles[1] # => <foo/>
2820
- #
2821
- # Does nothing (or raises an exception)
2822
- # if +replacement_element+ is not an \Element:
2823
- # eles[2] # => <book category='web' cover='paperback'> ... </>
2824
- # eles[2] = REXML::Text.new('bar')
2825
- # eles[2] # => <book category='web' cover='paperback'> ... </>
2826
- #
2827
- # When <tt>eles[index]</tt> does not exist,
2828
- # adds +replacement_element+ to the element and returns
2829
- #
2830
- # d = REXML::Document.new(xml_string)
2831
- # eles = d.root.elements # => #<REXML::Elements @element=<bookstore> ... </>>
2832
- # eles.size # => 4
2833
- # eles[50] = REXML::Element.new('foo') # => <foo/>
2834
- # eles.size # => 5
2835
- # eles[5] # => <foo/>
2836
- #
2837
- # Does nothing (or raises an exception)
2838
- # if +replacement_element+ is not an \Element:
2839
- #
2840
- # eles[50] = REXML::Text.new('bar') # => "bar"
2841
- # eles.size # => 5
2842
- #
2843
- # source://rexml//lib/rexml/element.rb#1735
2844
- def []=(index, element); end
2845
-
2846
- # :call-seq:
2847
- # add -> new_element
2848
- # add(name) -> new_element
2849
- # add(element) -> element
2850
- #
2851
- # Adds an element; returns the element added.
2852
- #
2853
- # With no argument, creates and adds a new element.
2854
- # The new element has:
2855
- #
2856
- # - No name.
2857
- # - \Parent from the \Elements object.
2858
- # - Context from the that parent.
2859
- #
2860
- # Example:
2861
- #
2862
- # d = REXML::Document.new(xml_string)
2863
- # elements = d.root.elements
2864
- # parent = elements.parent # => <bookstore> ... </>
2865
- # parent.context = {raw: :all}
2866
- # elements.size # => 4
2867
- # new_element = elements.add # => </>
2868
- # elements.size # => 5
2869
- # new_element.name # => nil
2870
- # new_element.parent # => <bookstore> ... </>
2871
- # new_element.context # => {:raw=>:all}
2872
- #
2873
- # With string argument +name+, creates and adds a new element.
2874
- # The new element has:
2875
- #
2876
- # - Name +name+.
2877
- # - \Parent from the \Elements object.
2878
- # - Context from the that parent.
2879
- #
2880
- # Example:
2881
- #
2882
- # d = REXML::Document.new(xml_string)
2883
- # elements = d.root.elements
2884
- # parent = elements.parent # => <bookstore> ... </>
2885
- # parent.context = {raw: :all}
2886
- # elements.size # => 4
2887
- # new_element = elements.add('foo') # => <foo/>
2888
- # elements.size # => 5
2889
- # new_element.name # => "foo"
2890
- # new_element.parent # => <bookstore> ... </>
2891
- # new_element.context # => {:raw=>:all}
2892
- #
2893
- # With argument +element+,
2894
- # creates and adds a clone of the given +element+.
2895
- # The new element has name, parent, and context from the given +element+.
2896
- #
2897
- # d = REXML::Document.new(xml_string)
2898
- # elements = d.root.elements
2899
- # elements.size # => 4
2900
- # e0 = REXML::Element.new('foo')
2901
- # e1 = REXML::Element.new('bar', e0, {raw: :all})
2902
- # element = elements.add(e1) # => <bar/>
2903
- # elements.size # => 5
2904
- # element.name # => "bar"
2905
- # element.parent # => <bookstore> ... </>
2906
- # element.context # => {:raw=>:all}
2907
- #
2908
- # source://rexml//lib/rexml/element.rb#1925
2909
- def add(element = T.unsafe(nil)); end
2910
-
2911
- # :call-seq:
2912
- # collect(xpath = nil) {|element| ... } -> array
2913
- #
2914
- # Iterates over the elements; returns the array of block return values.
2915
- #
2916
- # With no argument, iterates over all elements:
2917
- #
2918
- # d = REXML::Document.new(xml_string)
2919
- # elements = d.root.elements
2920
- # elements.collect {|element| element.size } # => [9, 9, 17, 9]
2921
- #
2922
- # With argument +xpath+, iterates over elements that match
2923
- # the given +xpath+:
2924
- #
2925
- # xpath = '//book [@category="web"]'
2926
- # elements.collect(xpath) {|element| element.size } # => [17, 9]
2927
- #
2928
- # source://rexml//lib/rexml/element.rb#1988
2929
- def collect(xpath = T.unsafe(nil)); end
2930
-
2931
- # :call-seq:
2932
- # delete(index) -> removed_element or nil
2933
- # delete(element) -> removed_element or nil
2934
- # delete(xpath) -> removed_element or nil
2935
- #
2936
- # Removes an element; returns the removed element, or +nil+ if none removed.
2937
- #
2938
- # With integer argument +index+ given,
2939
- # removes the child element at that offset:
2940
- #
2941
- # d = REXML::Document.new(xml_string)
2942
- # elements = d.root.elements
2943
- # elements.size # => 4
2944
- # elements[2] # => <book category='children'> ... </>
2945
- # elements.delete(2) # => <book category='children'> ... </>
2946
- # elements.size # => 3
2947
- # elements[2] # => <book category='web'> ... </>
2948
- # elements.delete(50) # => nil
2949
- #
2950
- # With element argument +element+ given,
2951
- # removes that child element:
2952
- #
2953
- # d = REXML::Document.new(xml_string)
2954
- # elements = d.root.elements
2955
- # ele_1, ele_2, ele_3, ele_4 = *elements
2956
- # elements.size # => 4
2957
- # elements[2] # => <book category='children'> ... </>
2958
- # elements.delete(ele_2) # => <book category='children'> ... </>
2959
- # elements.size # => 3
2960
- # elements[2] # => <book category='web'> ... </>
2961
- # elements.delete(ele_2) # => nil
2962
- #
2963
- # With string argument +xpath+ given,
2964
- # removes the first element found via that xpath:
2965
- #
2966
- # d = REXML::Document.new(xml_string)
2967
- # elements = d.root.elements
2968
- # elements.delete('//book') # => <book category='cooking'> ... </>
2969
- # elements.delete('//book [@category="children"]') # => <book category='children'> ... </>
2970
- # elements.delete('//nosuch') # => nil
2971
- #
2972
- # source://rexml//lib/rexml/element.rb#1825
2973
- def delete(element); end
2974
-
2975
- # :call-seq:
2976
- # delete_all(xpath)
2977
- #
2978
- # Removes all elements found via the given +xpath+;
2979
- # returns the array of removed elements, if any, else +nil+.
2980
- #
2981
- # d = REXML::Document.new(xml_string)
2982
- # elements = d.root.elements
2983
- # elements.size # => 4
2984
- # deleted_elements = elements.delete_all('//book [@category="web"]')
2985
- # deleted_elements.size # => 2
2986
- # elements.size # => 2
2987
- # deleted_elements = elements.delete_all('//book')
2988
- # deleted_elements.size # => 2
2989
- # elements.size # => 0
2990
- # elements.delete_all('//book') # => []
2991
- #
2992
- # source://rexml//lib/rexml/element.rb#1851
2993
- def delete_all(xpath); end
2994
-
2995
- # :call-seq:
2996
- # each(xpath = nil) {|element| ... } -> self
2997
- #
2998
- # Iterates over the elements.
2999
- #
3000
- # With no argument, calls the block with each element:
3001
- #
3002
- # d = REXML::Document.new(xml_string)
3003
- # elements = d.root.elements
3004
- # elements.each {|element| p element }
3005
- #
3006
- # Output:
3007
- #
3008
- # <book category='cooking'> ... </>
3009
- # <book category='children'> ... </>
3010
- # <book category='web'> ... </>
3011
- # <book category='web' cover='paperback'> ... </>
3012
- #
3013
- # With argument +xpath+, calls the block with each element
3014
- # that matches the given +xpath+:
3015
- #
3016
- # elements.each('//book [@category="web"]') {|element| p element }
3017
- #
3018
- # Output:
3019
- #
3020
- # <book category='web'> ... </>
3021
- # <book category='web' cover='paperback'> ... </>
3022
- #
3023
- # source://rexml//lib/rexml/element.rb#1967
3024
- def each(xpath = T.unsafe(nil)); end
3025
-
3026
- # :call-seq:
3027
- # empty? -> true or false
3028
- #
3029
- # Returns +true+ if there are no children, +false+ otherwise.
3030
- #
3031
- # d = REXML::Document.new('')
3032
- # d.elements.empty? # => true
3033
- # d = REXML::Document.new(xml_string)
3034
- # d.elements.empty? # => false
3035
- #
3036
- # @return [Boolean]
3037
- #
3038
- # source://rexml//lib/rexml/element.rb#1755
3039
- def empty?; end
3040
-
3041
- # :call-seq:
3042
- # index(element)
3043
- #
3044
- # Returns the 1-based index of the given +element+, if found;
3045
- # otherwise, returns -1:
3046
- #
3047
- # d = REXML::Document.new(xml_string)
3048
- # elements = d.root.elements
3049
- # ele_1, ele_2, ele_3, ele_4 = *elements
3050
- # elements.index(ele_4) # => 4
3051
- # elements.delete(ele_3)
3052
- # elements.index(ele_4) # => 3
3053
- # elements.index(ele_3) # => -1
3054
- #
3055
- # source://rexml//lib/rexml/element.rb#1773
3056
- def index(element); end
3057
-
3058
- # :call-seq:
3059
- # inject(xpath = nil, initial = nil) -> object
3060
- #
3061
- # Calls the block with elements; returns the last block return value.
3062
- #
3063
- # With no argument, iterates over the elements, calling the block
3064
- # <tt>elements.size - 1</tt> times.
3065
- #
3066
- # - The first call passes the first and second elements.
3067
- # - The second call passes the first block return value and the third element.
3068
- # - The third call passes the second block return value and the fourth element.
3069
- # - And so on.
3070
- #
3071
- # In this example, the block returns the passed element,
3072
- # which is then the object argument to the next call:
3073
- #
3074
- # d = REXML::Document.new(xml_string)
3075
- # elements = d.root.elements
3076
- # elements.inject do |object, element|
3077
- # p [elements.index(object), elements.index(element)]
3078
- # element
3079
- # end
3080
- #
3081
- # Output:
3082
- #
3083
- # [1, 2]
3084
- # [2, 3]
3085
- # [3, 4]
3086
- #
3087
- # With the single argument +xpath+, calls the block only with
3088
- # elements matching that xpath:
3089
- #
3090
- # elements.inject('//book [@category="web"]') do |object, element|
3091
- # p [elements.index(object), elements.index(element)]
3092
- # element
3093
- # end
3094
- #
3095
- # Output:
3096
- #
3097
- # [3, 4]
3098
- #
3099
- # With argument +xpath+ given as +nil+
3100
- # and argument +initial+ also given,
3101
- # calls the block once for each element.
3102
- #
3103
- # - The first call passes the +initial+ and the first element.
3104
- # - The second call passes the first block return value and the second element.
3105
- # - The third call passes the second block return value and the third element.
3106
- # - And so on.
3107
- #
3108
- # In this example, the first object index is <tt>-1</tt>
3109
- #
3110
- # elements.inject(nil, 'Initial') do |object, element|
3111
- # p [elements.index(object), elements.index(element)]
3112
- # element
3113
- # end
3114
- #
3115
- # Output:
3116
- #
3117
- # [-1, 1]
3118
- # [1, 2]
3119
- # [2, 3]
3120
- # [3, 4]
3121
- #
3122
- # In this form the passed object can be used as an accumulator:
3123
- #
3124
- # elements.inject(nil, 0) do |total, element|
3125
- # total += element.size
3126
- # end # => 44
3127
- #
3128
- # With both arguments +xpath+ and +initial+ are given,
3129
- # calls the block only with elements matching that xpath:
3130
- #
3131
- # elements.inject('//book [@category="web"]', 0) do |total, element|
3132
- # total += element.size
3133
- # end # => 26
3134
- #
3135
- # source://rexml//lib/rexml/element.rb#2073
3136
- def inject(xpath = T.unsafe(nil), initial = T.unsafe(nil)); end
3137
-
3138
- # :call-seq:
3139
- # parent
3140
- #
3141
- # Returns the parent element cited in creating the \Elements object.
3142
- # This element is also the default starting point for searching
3143
- # in the \Elements object.
3144
- #
3145
- # d = REXML::Document.new(xml_string)
3146
- # elements = REXML::Elements.new(d.root)
3147
- # elements.parent == d.root # => true
3148
- #
3149
- # source://rexml//lib/rexml/element.rb#1623
3150
- def parent; end
3151
-
3152
- # :call-seq:
3153
- # size -> integer
3154
- #
3155
- # Returns the count of \Element children:
3156
- #
3157
- # d = REXML::Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
3158
- # d.root.elements.size # => 3 # Three elements.
3159
- # d.root.size # => 6 # Three elements plus three text nodes..
3160
- #
3161
- # source://rexml//lib/rexml/element.rb#2097
3162
- def size; end
3163
-
3164
- # :call-seq:
3165
- # to_a(xpath = nil) -> array_of_elements
3166
- #
3167
- # Returns an array of element children (not including non-element children).
3168
- #
3169
- # With no argument, returns an array of all element children:
3170
- #
3171
- # d = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
3172
- # elements = d.root.elements
3173
- # elements.to_a # => [<b/>, <c/>] # Omits non-element children.
3174
- # children = d.root.children
3175
- # children # => ["sean", <b/>, "elliott", <c/>] # Includes non-element children.
3176
- #
3177
- # With argument +xpath+, returns an array of element children
3178
- # that match the xpath:
3179
- #
3180
- # elements.to_a('//c') # => [<c/>]
3181
- #
3182
- # source://rexml//lib/rexml/element.rb#2121
3183
- def to_a(xpath = T.unsafe(nil)); end
3184
-
3185
- private
3186
-
3187
- # Private helper class. Removes quotes from quoted strings
3188
- #
3189
- # source://rexml//lib/rexml/element.rb#2129
3190
- def literalize(name); end
3191
- end
3192
-
3193
- # source://rexml//lib/rexml/encoding.rb#4
3194
- module REXML::Encoding
3195
- # source://rexml//lib/rexml/encoding.rb#29
3196
- def decode(string); end
3197
-
3198
- # source://rexml//lib/rexml/encoding.rb#25
3199
- def encode(string); end
3200
-
3201
- # ID ---> Encoding name
3202
- #
3203
- # source://rexml//lib/rexml/encoding.rb#6
3204
- def encoding; end
3205
-
3206
- # source://rexml//lib/rexml/encoding.rb#7
3207
- def encoding=(encoding); end
3208
-
3209
- private
3210
-
3211
- # source://rexml//lib/rexml/encoding.rb#34
3212
- def find_encoding(name); end
3213
- end
3214
-
3215
- # source://rexml//lib/rexml/entity.rb#7
3216
- class REXML::Entity < ::REXML::Child
3217
- include ::REXML::XMLTokens
3218
-
3219
- # Create a new entity. Simple entities can be constructed by passing a
3220
- # name, value to the constructor; this creates a generic, plain entity
3221
- # reference. For anything more complicated, you have to pass a Source to
3222
- # the constructor with the entity definition, or use the accessor methods.
3223
- # +WARNING+: There is no validation of entity state except when the entity
3224
- # is read from a stream. If you start poking around with the accessors,
3225
- # you can easily create a non-conformant Entity.
3226
- #
3227
- # e = Entity.new( 'amp', '&' )
3228
- #
3229
- # @return [Entity] a new instance of Entity
3230
- #
3231
- # source://rexml//lib/rexml/entity.rb#33
3232
- def initialize(stream, value = T.unsafe(nil), parent = T.unsafe(nil), reference = T.unsafe(nil)); end
3233
-
3234
- # Returns the value of attribute external.
3235
- #
3236
- # source://rexml//lib/rexml/entity.rb#22
3237
- def external; end
3238
-
3239
- # Returns the value of attribute name.
3240
- #
3241
- # source://rexml//lib/rexml/entity.rb#22
3242
- def name; end
3243
-
3244
- # Returns the value of attribute ndata.
3245
- #
3246
- # source://rexml//lib/rexml/entity.rb#22
3247
- def ndata; end
3248
-
3249
- # Returns the value of this entity unprocessed -- raw. This is the
3250
- # normalized value; that is, with all %ent; and &ent; entities intact
3251
- #
3252
- # source://rexml//lib/rexml/entity.rb#85
3253
- def normalized; end
3254
-
3255
- # Returns the value of attribute pubid.
3256
- #
3257
- # source://rexml//lib/rexml/entity.rb#22
3258
- def pubid; end
3259
-
3260
- # Returns the value of attribute ref.
3261
- #
3262
- # source://rexml//lib/rexml/entity.rb#22
3263
- def ref; end
3264
-
3265
- # Returns this entity as a string. See write().
3266
- #
3267
- # source://rexml//lib/rexml/entity.rb#119
3268
- def to_s; end
3269
-
3270
- # Evaluates to the unnormalized value of this entity; that is, replacing
3271
- # all entities -- both %ent; and &ent; entities. This differs from
3272
- # +value()+ in that +value+ only replaces %ent; entities.
3273
- #
3274
- # source://rexml//lib/rexml/entity.rb#73
3275
- def unnormalized; end
3276
-
3277
- # Returns the value of this entity. At the moment, only internal entities
3278
- # are processed. If the value contains internal references (IE,
3279
- # %blah;), those are replaced with their values. IE, if the doctype
3280
- # contains:
3281
- # <!ENTITY % foo "bar">
3282
- # <!ENTITY yada "nanoo %foo; nanoo>
3283
- # then:
3284
- # doctype.entity('yada').value #-> "nanoo bar nanoo"
3285
- #
3286
- # source://rexml//lib/rexml/entity.rb#134
3287
- def value; end
3288
-
3289
- # Write out a fully formed, correct entity definition (assuming the Entity
3290
- # object itself is valid.)
3291
- #
3292
- # out::
3293
- # An object implementing <TT>&lt;&lt;</TT> to which the entity will be
3294
- # output
3295
- # indent::
3296
- # *DEPRECATED* and ignored
3297
- #
3298
- # source://rexml//lib/rexml/entity.rb#97
3299
- def write(out, indent = T.unsafe(nil)); end
3300
-
3301
- class << self
3302
- # Evaluates whether the given string matches an entity definition,
3303
- # returning true if so, and false otherwise.
3304
- #
3305
- # @return [Boolean]
3306
- #
3307
- # source://rexml//lib/rexml/entity.rb#66
3308
- def matches?(string); end
3309
- end
3310
- end
3311
-
3312
- # source://rexml//lib/rexml/doctype.rb#267
3313
- class REXML::ExternalEntity < ::REXML::Child
3314
- # @return [ExternalEntity] a new instance of ExternalEntity
3315
- #
3316
- # source://rexml//lib/rexml/doctype.rb#268
3317
- def initialize(src); end
3318
-
3319
- # source://rexml//lib/rexml/doctype.rb#272
3320
- def to_s; end
3321
-
3322
- # source://rexml//lib/rexml/doctype.rb#275
3323
- def write(output, indent); end
3324
- end
3325
-
3326
- # source://rexml//lib/rexml/formatters/default.rb#5
3327
- class REXML::Formatters::Default
3328
- # Prints out the XML document with no formatting -- except if ie_hack is
3329
- # set.
3330
- #
3331
- # ie_hack::
3332
- # If set to true, then inserts whitespace before the close of an empty
3333
- # tag, so that IE's bad XML parser doesn't choke.
3334
- #
3335
- # @return [Default] a new instance of Default
3336
- #
3337
- # source://rexml//lib/rexml/formatters/default.rb#12
3338
- def initialize(ie_hack = T.unsafe(nil)); end
3339
-
3340
- # Writes the node to some output.
3341
- #
3342
- # node::
3343
- # The node to write
3344
- # output::
3345
- # A class implementing <TT>&lt;&lt;</TT>. Pass in an Output object to
3346
- # change the output encoding.
3347
- #
3348
- # source://rexml//lib/rexml/formatters/default.rb#23
3349
- def write(node, output); end
3350
-
3351
- protected
3352
-
3353
- # source://rexml//lib/rexml/formatters/default.rb#98
3354
- def write_cdata(node, output); end
3355
-
3356
- # source://rexml//lib/rexml/formatters/default.rb#92
3357
- def write_comment(node, output); end
3358
-
3359
- # source://rexml//lib/rexml/formatters/default.rb#61
3360
- def write_document(node, output); end
3361
-
3362
- # source://rexml//lib/rexml/formatters/default.rb#65
3363
- def write_element(node, output); end
3364
-
3365
- # source://rexml//lib/rexml/formatters/default.rb#104
3366
- def write_instruction(node, output); end
3367
-
3368
- # source://rexml//lib/rexml/formatters/default.rb#88
3369
- def write_text(node, output); end
3370
- end
3371
-
3372
- # Pretty-prints an XML document. This destroys whitespace in text nodes
3373
- # and will insert carriage returns and indentations.
3374
- #
3375
- # TODO: Add an option to print attributes on new lines
3376
- #
3377
- # source://rexml//lib/rexml/formatters/pretty.rb#10
3378
- class REXML::Formatters::Pretty < ::REXML::Formatters::Default
3379
- # Create a new pretty printer.
3380
- #
3381
- # output::
3382
- # An object implementing '<<(String)', to which the output will be written.
3383
- # indentation::
3384
- # An integer greater than 0. The indentation of each level will be
3385
- # this number of spaces. If this is < 1, the behavior of this object
3386
- # is undefined. Defaults to 2.
3387
- # ie_hack::
3388
- # If true, the printer will insert whitespace before closing empty
3389
- # tags, thereby allowing Internet Explorer's XML parser to
3390
- # function. Defaults to false.
3391
- #
3392
- # @return [Pretty] a new instance of Pretty
3393
- #
3394
- # source://rexml//lib/rexml/formatters/pretty.rb#30
3395
- def initialize(indentation = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
3396
-
3397
- # If compact is set to true, then the formatter will attempt to use as
3398
- # little space as possible
3399
- #
3400
- # source://rexml//lib/rexml/formatters/pretty.rb#14
3401
- def compact; end
3402
-
3403
- # If compact is set to true, then the formatter will attempt to use as
3404
- # little space as possible
3405
- #
3406
- # source://rexml//lib/rexml/formatters/pretty.rb#14
3407
- def compact=(_arg0); end
3408
-
3409
- # The width of a page. Used for formatting text
3410
- #
3411
- # source://rexml//lib/rexml/formatters/pretty.rb#16
3412
- def width; end
3413
-
3414
- # The width of a page. Used for formatting text
3415
- #
3416
- # source://rexml//lib/rexml/formatters/pretty.rb#16
3417
- def width=(_arg0); end
3418
-
3419
- protected
3420
-
3421
- # source://rexml//lib/rexml/formatters/pretty.rb#102
3422
- def write_cdata(node, output); end
3423
-
3424
- # source://rexml//lib/rexml/formatters/pretty.rb#97
3425
- def write_comment(node, output); end
3426
-
3427
- # source://rexml//lib/rexml/formatters/pretty.rb#107
3428
- def write_document(node, output); end
3429
-
3430
- # source://rexml//lib/rexml/formatters/pretty.rb#39
3431
- def write_element(node, output); end
3432
-
3433
- # source://rexml//lib/rexml/formatters/pretty.rb#88
3434
- def write_text(node, output); end
3435
-
3436
- private
3437
-
3438
- # source://rexml//lib/rexml/formatters/pretty.rb#124
3439
- def indent_text(string, level = T.unsafe(nil), style = T.unsafe(nil), indentfirstline = T.unsafe(nil)); end
3440
-
3441
- # source://rexml//lib/rexml/formatters/pretty.rb#129
3442
- def wrap(string, width); end
3443
- end
3444
-
3445
- # A Source that wraps an IO. See the Source class for method
3446
- # documentation
3447
- #
3448
- # source://rexml//lib/rexml/source.rb#160
3449
- class REXML::IOSource < ::REXML::Source
3450
- # block_size has been deprecated
3451
- #
3452
- # @return [IOSource] a new instance of IOSource
3453
- #
3454
- # source://rexml//lib/rexml/source.rb#163
3455
- def initialize(arg, block_size = T.unsafe(nil), encoding = T.unsafe(nil)); end
3456
-
3457
- # source://rexml//lib/rexml/source.rb#215
3458
- def consume(pattern); end
3459
-
3460
- # @return the current line in the source
3461
- #
3462
- # source://rexml//lib/rexml/source.rb#244
3463
- def current_line; end
3464
-
3465
- # @return [Boolean]
3466
- #
3467
- # source://rexml//lib/rexml/source.rb#235
3468
- def empty?; end
3469
-
3470
- # source://rexml//lib/rexml/source.rb#219
3471
- def match(pattern, cons = T.unsafe(nil)); end
3472
-
3473
- # source://rexml//lib/rexml/source.rb#239
3474
- def position; end
3475
-
3476
- # source://rexml//lib/rexml/source.rb#207
3477
- def read; end
3478
-
3479
- # source://rexml//lib/rexml/source.rb#184
3480
- def scan(pattern, cons = T.unsafe(nil)); end
3481
-
3482
- private
3483
-
3484
- # source://rexml//lib/rexml/source.rb#286
3485
- def encoding_updated; end
3486
-
3487
- # source://rexml//lib/rexml/source.rb#266
3488
- def readline; end
3489
- end
3490
-
3491
- # Represents an XML Instruction; IE, <? ... ?>
3492
- # TODO: Add parent arg (3rd arg) to constructor
3493
- #
3494
- # source://rexml//lib/rexml/instruction.rb#9
3495
- class REXML::Instruction < ::REXML::Child
3496
- # Constructs a new Instruction
3497
- # the target of this instruction is set to this. If an Instruction,
3498
- # then the Instruction is shallowly cloned (target and content are
3499
- # copied).
3500
- # be a Parent if the target argument is a Source. Otherwise, this
3501
- # String is set as the content of this instruction.
3502
- #
3503
- # @param target can be one of a number of things. If String, then
3504
- # @param content Must be either a String, or a Parent. Can only
3505
- # @return [Instruction] a new instance of Instruction
3506
- #
3507
- # source://rexml//lib/rexml/instruction.rb#25
3508
- def initialize(target, content = T.unsafe(nil)); end
3509
-
3510
- # of the other matches the target and content of this object.
3511
- #
3512
- # @return true if other is an Instruction, and the content and target
3513
- #
3514
- # source://rexml//lib/rexml/instruction.rb#65
3515
- def ==(other); end
3516
-
3517
- # source://rexml//lib/rexml/instruction.rb#44
3518
- def clone; end
3519
-
3520
- # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
3521
- # content is everything else.
3522
- #
3523
- # source://rexml//lib/rexml/instruction.rb#15
3524
- def content; end
3525
-
3526
- # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
3527
- # content is everything else.
3528
- #
3529
- # source://rexml//lib/rexml/instruction.rb#15
3530
- def content=(_arg0); end
3531
-
3532
- # source://rexml//lib/rexml/instruction.rb#75
3533
- def inspect; end
3534
-
3535
- # source://rexml//lib/rexml/instruction.rb#71
3536
- def node_type; end
3537
-
3538
- # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
3539
- # content is everything else.
3540
- #
3541
- # source://rexml//lib/rexml/instruction.rb#15
3542
- def target; end
3543
-
3544
- # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
3545
- # content is everything else.
3546
- #
3547
- # source://rexml//lib/rexml/instruction.rb#15
3548
- def target=(_arg0); end
3549
-
3550
- # == DEPRECATED
3551
- # See the rexml/formatters package
3552
- #
3553
- # source://rexml//lib/rexml/instruction.rb#51
3554
- def write(writer, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
3555
- end
3556
-
3557
- # source://rexml//lib/rexml/doctype.rb#280
3558
- class REXML::NotationDecl < ::REXML::Child
3559
- # @return [NotationDecl] a new instance of NotationDecl
3560
- #
3561
- # source://rexml//lib/rexml/doctype.rb#282
3562
- def initialize(name, middle, pub, sys); end
3563
-
3564
- # This method retrieves the name of the notation.
3565
- #
3566
- # Method contributed by Henrik Martensson
3567
- #
3568
- # source://rexml//lib/rexml/doctype.rb#307
3569
- def name; end
3570
-
3571
- # Returns the value of attribute public.
3572
- #
3573
- # source://rexml//lib/rexml/doctype.rb#281
3574
- def public; end
3575
-
3576
- # Sets the attribute public
3577
- #
3578
- # @param value the value to set the attribute public to.
3579
- #
3580
- # source://rexml//lib/rexml/doctype.rb#281
3581
- def public=(_arg0); end
3582
-
3583
- # Returns the value of attribute system.
3584
- #
3585
- # source://rexml//lib/rexml/doctype.rb#281
3586
- def system; end
3587
-
3588
- # Sets the attribute system
3589
- #
3590
- # @param value the value to set the attribute system to.
3591
- #
3592
- # source://rexml//lib/rexml/doctype.rb#281
3593
- def system=(_arg0); end
3594
-
3595
- # source://rexml//lib/rexml/doctype.rb#290
3596
- def to_s; end
3597
-
3598
- # source://rexml//lib/rexml/doctype.rb#300
3599
- def write(output, indent = T.unsafe(nil)); end
3600
- end
3601
-
3602
- # source://rexml//lib/rexml/output.rb#5
3603
- class REXML::Output
3604
- include ::REXML::Encoding
3605
-
3606
- # @return [Output] a new instance of Output
3607
- #
3608
- # source://rexml//lib/rexml/output.rb#10
3609
- def initialize(real_IO, encd = T.unsafe(nil)); end
3610
-
3611
- # source://rexml//lib/rexml/output.rb#22
3612
- def <<(content); end
3613
-
3614
- # Returns the value of attribute encoding.
3615
- #
3616
- # source://rexml//lib/rexml/output.rb#8
3617
- def encoding; end
3618
-
3619
- # source://rexml//lib/rexml/output.rb#26
3620
- def to_s; end
3621
- end
3622
-
3623
- # A parent has children, and has methods for accessing them. The Parent
3624
- # class is never encountered except as the superclass for some other
3625
- # object.
3626
- #
3627
- # source://rexml//lib/rexml/parent.rb#8
3628
- class REXML::Parent < ::REXML::Child
3629
- include ::Enumerable
3630
-
3631
- # Constructor
3632
- #
3633
- # @param parent if supplied, will be set as the parent of this object
3634
- # @return [Parent] a new instance of Parent
3635
- #
3636
- # source://rexml//lib/rexml/parent.rb#13
3637
- def initialize(parent = T.unsafe(nil)); end
3638
-
3639
- # source://rexml//lib/rexml/parent.rb#18
3640
- def <<(object); end
3641
-
3642
- # Fetches a child at a given index
3643
- #
3644
- # @param index the Integer index of the child to fetch
3645
- #
3646
- # source://rexml//lib/rexml/parent.rb#57
3647
- def [](index); end
3648
-
3649
- # Set an index entry. See Array.[]=
3650
- #
3651
- # @param index the index of the element to set
3652
- # @param opt either the object to set, or an Integer length
3653
- # @param child if opt is an Integer, this is the child to set
3654
- # @return the parent (self)
3655
- #
3656
- # source://rexml//lib/rexml/parent.rb#70
3657
- def []=(*args); end
3658
-
3659
- # source://rexml//lib/rexml/parent.rb#18
3660
- def add(object); end
3661
-
3662
- # source://rexml//lib/rexml/parent.rb#115
3663
- def children; end
3664
-
3665
- # Deeply clones this object. This creates a complete duplicate of this
3666
- # Parent, including all descendants.
3667
- #
3668
- # source://rexml//lib/rexml/parent.rb#148
3669
- def deep_clone; end
3670
-
3671
- # source://rexml//lib/rexml/parent.rb#32
3672
- def delete(object); end
3673
-
3674
- # source://rexml//lib/rexml/parent.rb#47
3675
- def delete_at(index); end
3676
-
3677
- # source://rexml//lib/rexml/parent.rb#43
3678
- def delete_if(&block); end
3679
-
3680
- # source://rexml//lib/rexml/parent.rb#39
3681
- def each(&block); end
3682
-
3683
- # source://rexml//lib/rexml/parent.rb#39
3684
- def each_child(&block); end
3685
-
3686
- # source://rexml//lib/rexml/parent.rb#51
3687
- def each_index(&block); end
3688
-
3689
- # Fetches the index of a given child
3690
- # of this parent.
3691
- #
3692
- # @param child the child to get the index of
3693
- # @return the index of the child, or nil if the object is not a child
3694
- #
3695
- # source://rexml//lib/rexml/parent.rb#123
3696
- def index(child); end
3697
-
3698
- # Inserts an child after another child
3699
- # child2 will be inserted after child1 in the child list of the parent.
3700
- # If an xpath, child2 will be inserted after the first child to match
3701
- # the xpath.
3702
- #
3703
- # @param child1 this is either an xpath or an Element. If an Element,
3704
- # @param child2 the child to insert
3705
- # @return the parent (self)
3706
- #
3707
- # source://rexml//lib/rexml/parent.rb#102
3708
- def insert_after(child1, child2); end
3709
-
3710
- # Inserts an child before another child
3711
- # child2 will be inserted before child1 in the child list of the parent.
3712
- # If an xpath, child2 will be inserted before the first child to match
3713
- # the xpath.
3714
- #
3715
- # @param child1 this is either an xpath or an Element. If an Element,
3716
- # @param child2 the child to insert
3717
- # @return the parent (self)
3718
- #
3719
- # source://rexml//lib/rexml/parent.rb#82
3720
- def insert_before(child1, child2); end
3721
-
3722
- # @return the number of children of this parent
3723
- #
3724
- # source://rexml//lib/rexml/parent.rb#130
3725
- def length; end
3726
-
3727
- # @return [Boolean]
3728
- #
3729
- # source://rexml//lib/rexml/parent.rb#162
3730
- def parent?; end
3731
-
3732
- # source://rexml//lib/rexml/parent.rb#18
3733
- def push(object); end
3734
-
3735
- # Replaces one child with another, making sure the nodelist is correct
3736
- # Child)
3737
- #
3738
- # @param to_replace the child to replace (must be a Child)
3739
- # @param replacement the child to insert into the nodelist (must be a
3740
- #
3741
- # source://rexml//lib/rexml/parent.rb#140
3742
- def replace_child(to_replace, replacement); end
3743
-
3744
- # @return the number of children of this parent
3745
- #
3746
- # source://rexml//lib/rexml/parent.rb#130
3747
- def size; end
3748
-
3749
- # source://rexml//lib/rexml/parent.rb#115
3750
- def to_a; end
3751
-
3752
- # source://rexml//lib/rexml/parent.rb#27
3753
- def unshift(object); end
3754
- end
3755
-
3756
- # source://rexml//lib/rexml/parseexception.rb#3
3757
- class REXML::ParseException < ::RuntimeError
3758
- # @return [ParseException] a new instance of ParseException
3759
- #
3760
- # source://rexml//lib/rexml/parseexception.rb#6
3761
- def initialize(message, source = T.unsafe(nil), parser = T.unsafe(nil), exception = T.unsafe(nil)); end
3762
-
3763
- # source://rexml//lib/rexml/parseexception.rb#48
3764
- def context; end
3765
-
3766
- # Returns the value of attribute continued_exception.
3767
- #
3768
- # source://rexml//lib/rexml/parseexception.rb#4
3769
- def continued_exception; end
3770
-
3771
- # Sets the attribute continued_exception
3772
- #
3773
- # @param value the value to set the attribute continued_exception to.
3774
- #
3775
- # source://rexml//lib/rexml/parseexception.rb#4
3776
- def continued_exception=(_arg0); end
3777
-
3778
- # source://rexml//lib/rexml/parseexception.rb#43
3779
- def line; end
3780
-
3781
- # Returns the value of attribute parser.
3782
- #
3783
- # source://rexml//lib/rexml/parseexception.rb#4
3784
- def parser; end
3785
-
3786
- # Sets the attribute parser
3787
- #
3788
- # @param value the value to set the attribute parser to.
3789
- #
3790
- # source://rexml//lib/rexml/parseexception.rb#4
3791
- def parser=(_arg0); end
3792
-
3793
- # source://rexml//lib/rexml/parseexception.rb#38
3794
- def position; end
3795
-
3796
- # Returns the value of attribute source.
3797
- #
3798
- # source://rexml//lib/rexml/parseexception.rb#4
3799
- def source; end
3800
-
3801
- # Sets the attribute source
3802
- #
3803
- # @param value the value to set the attribute source to.
3804
- #
3805
- # source://rexml//lib/rexml/parseexception.rb#4
3806
- def source=(_arg0); end
3807
-
3808
- # source://rexml//lib/rexml/parseexception.rb#13
3809
- def to_s; end
3810
- end
3811
-
3812
- # = Using the Pull Parser
3813
- # <em>This API is experimental, and subject to change.</em>
3814
- # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
3815
- # while parser.has_next?
3816
- # res = parser.next
3817
- # puts res[1]['att'] if res.start_tag? and res[0] == 'b'
3818
- # end
3819
- # See the PullEvent class for information on the content of the results.
3820
- # The data is identical to the arguments passed for the various events to
3821
- # the StreamListener API.
3822
- #
3823
- # Notice that:
3824
- # parser = PullParser.new( "<a>BAD DOCUMENT" )
3825
- # while parser.has_next?
3826
- # res = parser.next
3827
- # raise res[1] if res.error?
3828
- # end
3829
- #
3830
- # Nat Price gave me some good ideas for the API.
3831
- #
3832
- # source://rexml//lib/rexml/parsers/baseparser.rb#29
3833
- class REXML::Parsers::BaseParser
3834
- # @return [BaseParser] a new instance of BaseParser
3835
- #
3836
- # source://rexml//lib/rexml/parsers/baseparser.rb#115
3837
- def initialize(source); end
3838
-
3839
- # source://rexml//lib/rexml/parsers/baseparser.rb#120
3840
- def add_listener(listener); end
3841
-
3842
- # Returns true if there are no more events
3843
- #
3844
- # @return [Boolean]
3845
- #
3846
- # source://rexml//lib/rexml/parsers/baseparser.rb#146
3847
- def empty?; end
3848
-
3849
- # source://rexml//lib/rexml/parsers/baseparser.rb#438
3850
- def entity(reference, entities); end
3851
-
3852
- # Returns true if there are more events. Synonymous with !empty?
3853
- #
3854
- # @return [Boolean]
3855
- #
3856
- # source://rexml//lib/rexml/parsers/baseparser.rb#151
3857
- def has_next?; end
3858
-
3859
- # Escapes all possible entities
3860
- #
3861
- # source://rexml//lib/rexml/parsers/baseparser.rb#449
3862
- def normalize(input, entities = T.unsafe(nil), entity_filter = T.unsafe(nil)); end
3863
-
3864
- # Peek at the +depth+ event in the stack. The first element on the stack
3865
- # is at depth 0. If +depth+ is -1, will parse to the end of the input
3866
- # stream and return the last event, which is always :end_document.
3867
- # Be aware that this causes the stream to be parsed up to the +depth+
3868
- # event, so you can effectively pre-parse the entire document (pull the
3869
- # entire thing into memory) using this method.
3870
- #
3871
- # source://rexml//lib/rexml/parsers/baseparser.rb#167
3872
- def peek(depth = T.unsafe(nil)); end
3873
-
3874
- # source://rexml//lib/rexml/parsers/baseparser.rb#136
3875
- def position; end
3876
-
3877
- # Returns the next event. This is a +PullEvent+ object.
3878
- #
3879
- # source://rexml//lib/rexml/parsers/baseparser.rb#182
3880
- def pull; end
3881
-
3882
- # Returns the value of attribute source.
3883
- #
3884
- # source://rexml//lib/rexml/parsers/baseparser.rb#124
3885
- def source; end
3886
-
3887
- # source://rexml//lib/rexml/parsers/baseparser.rb#126
3888
- def stream=(source); end
3889
-
3890
- # Unescapes all possible entities
3891
- #
3892
- # source://rexml//lib/rexml/parsers/baseparser.rb#465
3893
- def unnormalize(string, entities = T.unsafe(nil), filter = T.unsafe(nil)); end
3894
-
3895
- # Push an event back on the head of the stream. This method
3896
- # has (theoretically) infinite depth.
3897
- #
3898
- # source://rexml//lib/rexml/parsers/baseparser.rb#157
3899
- def unshift(token); end
3900
-
3901
- private
3902
-
3903
- # @return [Boolean]
3904
- #
3905
- # source://rexml//lib/rexml/parsers/baseparser.rb#495
3906
- def need_source_encoding_update?(xml_declaration_encoding); end
3907
-
3908
- # source://rexml//lib/rexml/parsers/baseparser.rb#589
3909
- def parse_attributes(prefixes, curr_ns); end
3910
-
3911
- # source://rexml//lib/rexml/parsers/baseparser.rb#514
3912
- def parse_id(base_error_message, accept_external_id:, accept_public_id:); end
3913
-
3914
- # source://rexml//lib/rexml/parsers/baseparser.rb#542
3915
- def parse_id_invalid_details(accept_external_id:, accept_public_id:); end
3916
-
3917
- # source://rexml//lib/rexml/parsers/baseparser.rb#501
3918
- def parse_name(base_error_message); end
3919
-
3920
- # source://rexml//lib/rexml/parsers/baseparser.rb#580
3921
- def process_instruction; end
3922
-
3923
- # source://rexml//lib/rexml/parsers/baseparser.rb#190
3924
- def pull_event; end
3925
- end
3926
-
3927
- # source://rexml//lib/rexml/parsers/baseparser.rb#102
3928
- REXML::Parsers::BaseParser::EXTERNAL_ID_PUBLIC = T.let(T.unsafe(nil), Regexp)
3929
-
3930
- # source://rexml//lib/rexml/parsers/baseparser.rb#103
3931
- REXML::Parsers::BaseParser::EXTERNAL_ID_SYSTEM = T.let(T.unsafe(nil), Regexp)
3932
-
3933
- # source://rexml//lib/rexml/parsers/baseparser.rb#104
3934
- REXML::Parsers::BaseParser::PUBLIC_ID = T.let(T.unsafe(nil), Regexp)
3935
-
3936
- # source://rexml//lib/rexml/parsers/baseparser.rb#38
3937
- REXML::Parsers::BaseParser::QNAME = T.let(T.unsafe(nil), Regexp)
3938
-
3939
- # source://rexml//lib/rexml/parsers/baseparser.rb#37
3940
- REXML::Parsers::BaseParser::QNAME_STR = T.let(T.unsafe(nil), String)
3941
-
3942
- # source://rexml//lib/rexml/parsers/streamparser.rb#6
3943
- class REXML::Parsers::StreamParser
3944
- # @return [StreamParser] a new instance of StreamParser
3945
- #
3946
- # source://rexml//lib/rexml/parsers/streamparser.rb#7
3947
- def initialize(source, listener); end
3948
-
3949
- # source://rexml//lib/rexml/parsers/streamparser.rb#13
3950
- def add_listener(listener); end
3951
-
3952
- # source://rexml//lib/rexml/parsers/streamparser.rb#17
3953
- def parse; end
3954
- end
3955
-
3956
- # source://rexml//lib/rexml/parsers/treeparser.rb#7
3957
- class REXML::Parsers::TreeParser
3958
- # @return [TreeParser] a new instance of TreeParser
3959
- #
3960
- # source://rexml//lib/rexml/parsers/treeparser.rb#8
3961
- def initialize(source, build_context = T.unsafe(nil)); end
3962
-
3963
- # source://rexml//lib/rexml/parsers/treeparser.rb#13
3964
- def add_listener(listener); end
3965
-
3966
- # source://rexml//lib/rexml/parsers/treeparser.rb#17
3967
- def parse; end
3968
- end
3969
-
3970
- # You don't want to use this class. Really. Use XPath, which is a wrapper
3971
- # for this class. Believe me. You don't want to poke around in here.
3972
- # There is strange, dark magic at work in this code. Beware. Go back! Go
3973
- # back while you still can!
3974
- #
3975
- # source://rexml//lib/rexml/parsers/xpathparser.rb#11
3976
- class REXML::Parsers::XPathParser
3977
- include ::REXML::XMLTokens
3978
-
3979
- # source://rexml//lib/rexml/parsers/xpathparser.rb#41
3980
- def abbreviate(path); end
3981
-
3982
- # source://rexml//lib/rexml/parsers/xpathparser.rb#99
3983
- def expand(path); end
3984
-
3985
- # source://rexml//lib/rexml/parsers/xpathparser.rb#15
3986
- def namespaces=(namespaces); end
3987
-
3988
- # source://rexml//lib/rexml/parsers/xpathparser.rb#20
3989
- def parse(path); end
3990
-
3991
- # source://rexml//lib/rexml/parsers/xpathparser.rb#35
3992
- def predicate(path); end
3993
-
3994
- # source://rexml//lib/rexml/parsers/xpathparser.rb#138
3995
- def predicate_to_string(path, &block); end
3996
-
3997
- private
3998
-
3999
- # | AdditiveExpr ('+' | '-') MultiplicativeExpr
4000
- # | MultiplicativeExpr
4001
- #
4002
- # source://rexml//lib/rexml/parsers/xpathparser.rb#455
4003
- def AdditiveExpr(path, parsed); end
4004
-
4005
- # | AndExpr S 'and' S EqualityExpr
4006
- # | EqualityExpr
4007
- #
4008
- # source://rexml//lib/rexml/parsers/xpathparser.rb#388
4009
- def AndExpr(path, parsed); end
4010
-
4011
- # | EqualityExpr ('=' | '!=') RelationalExpr
4012
- # | RelationalExpr
4013
- #
4014
- # source://rexml//lib/rexml/parsers/xpathparser.rb#407
4015
- def EqualityExpr(path, parsed); end
4016
-
4017
- # | FilterExpr Predicate
4018
- # | PrimaryExpr
4019
- #
4020
- # source://rexml//lib/rexml/parsers/xpathparser.rb#558
4021
- def FilterExpr(path, parsed); end
4022
-
4023
- # | FUNCTION_NAME '(' ( expr ( ',' expr )* )? ')'
4024
- #
4025
- # source://rexml//lib/rexml/parsers/xpathparser.rb#613
4026
- def FunctionCall(rest, parsed); end
4027
-
4028
- # LocationPath
4029
- # | RelativeLocationPath
4030
- # | '/' RelativeLocationPath?
4031
- # | '//' RelativeLocationPath
4032
- #
4033
- # source://rexml//lib/rexml/parsers/xpathparser.rb#193
4034
- def LocationPath(path, parsed); end
4035
-
4036
- # | MultiplicativeExpr ('*' | S ('div' | 'mod') S) UnaryExpr
4037
- # | UnaryExpr
4038
- #
4039
- # source://rexml//lib/rexml/parsers/xpathparser.rb#478
4040
- def MultiplicativeExpr(path, parsed); end
4041
-
4042
- # source://rexml//lib/rexml/parsers/xpathparser.rb#293
4043
- def NodeTest(path, parsed); end
4044
-
4045
- # | OrExpr S 'or' S AndExpr
4046
- # | AndExpr
4047
- #
4048
- # source://rexml//lib/rexml/parsers/xpathparser.rb#369
4049
- def OrExpr(path, parsed); end
4050
-
4051
- # | LocationPath
4052
- # | FilterExpr ('/' | '//') RelativeLocationPath
4053
- #
4054
- # source://rexml//lib/rexml/parsers/xpathparser.rb#540
4055
- def PathExpr(path, parsed); end
4056
-
4057
- # Filters the supplied nodeset on the predicate(s)
4058
- #
4059
- # source://rexml//lib/rexml/parsers/xpathparser.rb#345
4060
- def Predicate(path, parsed); end
4061
-
4062
- # source://rexml//lib/rexml/parsers/xpathparser.rb#576
4063
- def PrimaryExpr(path, parsed); end
4064
-
4065
- # | RelationalExpr ('<' | '>' | '<=' | '>=') AdditiveExpr
4066
- # | AdditiveExpr
4067
- #
4068
- # source://rexml//lib/rexml/parsers/xpathparser.rb#430
4069
- def RelationalExpr(path, parsed); end
4070
-
4071
- # source://rexml//lib/rexml/parsers/xpathparser.rb#217
4072
- def RelativeLocationPath(path, parsed); end
4073
-
4074
- # | '-' UnaryExpr
4075
- # | UnionExpr
4076
- #
4077
- # source://rexml//lib/rexml/parsers/xpathparser.rb#503
4078
- def UnaryExpr(path, parsed); end
4079
-
4080
- # | UnionExpr '|' PathExpr
4081
- # | PathExpr
4082
- #
4083
- # source://rexml//lib/rexml/parsers/xpathparser.rb#521
4084
- def UnionExpr(path, parsed); end
4085
-
4086
- # get_group( '[foo]bar' ) -> ['bar', '[foo]']
4087
- #
4088
- # source://rexml//lib/rexml/parsers/xpathparser.rb#626
4089
- def get_group(string); end
4090
-
4091
- # source://rexml//lib/rexml/parsers/xpathparser.rb#644
4092
- def parse_args(string); end
4093
- end
4094
-
4095
- # source://rexml//lib/rexml/parsers/xpathparser.rb#289
4096
- REXML::Parsers::XPathParser::LOCAL_NAME_WILDCARD = T.let(T.unsafe(nil), Regexp)
4097
-
4098
- # Returns a 1-1 map of the nodeset
4099
- # The contents of the resulting array are either:
4100
- # true/false, if a positive match
4101
- # String, if a name match
4102
- # NodeTest
4103
- # | ('*' | NCNAME ':' '*' | QNAME) NameTest
4104
- # | '*' ':' NCNAME NameTest since XPath 2.0
4105
- # | NODE_TYPE '(' ')' NodeType
4106
- # | PI '(' LITERAL ')' PI
4107
- # | '[' expr ']' Predicate
4108
- #
4109
- # source://rexml//lib/rexml/parsers/xpathparser.rb#288
4110
- REXML::Parsers::XPathParser::PREFIX_WILDCARD = T.let(T.unsafe(nil), Regexp)
4111
-
4112
- # source://rexml//lib/rexml/doctype.rb#10
4113
- class REXML::ReferenceWriter
4114
- # @return [ReferenceWriter] a new instance of ReferenceWriter
4115
- #
4116
- # source://rexml//lib/rexml/doctype.rb#11
4117
- def initialize(id_type, public_id_literal, system_literal, context = T.unsafe(nil)); end
4118
-
4119
- # source://rexml//lib/rexml/doctype.rb#25
4120
- def write(output); end
4121
- end
4122
-
4123
- # A Source can be searched for patterns, and wraps buffers and other
4124
- # objects and provides consumption of text
4125
- #
4126
- # source://rexml//lib/rexml/source.rb#31
4127
- class REXML::Source
4128
- include ::REXML::Encoding
4129
-
4130
- # Constructor
4131
- # value, overriding all encoding detection
4132
- #
4133
- # @param arg must be a String, and should be a valid XML document
4134
- # @param encoding if non-null, sets the encoding of the source to this
4135
- # @return [Source] a new instance of Source
4136
- #
4137
- # source://rexml//lib/rexml/source.rb#43
4138
- def initialize(arg, encoding = T.unsafe(nil)); end
4139
-
4140
- # The current buffer (what we're going to read next)
4141
- #
4142
- # source://rexml//lib/rexml/source.rb#34
4143
- def buffer; end
4144
-
4145
- # source://rexml//lib/rexml/source.rb#87
4146
- def consume(pattern); end
4147
-
4148
- # @return the current line in the source
4149
- #
4150
- # source://rexml//lib/rexml/source.rb#117
4151
- def current_line; end
4152
-
4153
- # @return [Boolean] true if the Source is exhausted
4154
- #
4155
- # source://rexml//lib/rexml/source.rb#108
4156
- def empty?; end
4157
-
4158
- # Returns the value of attribute encoding.
4159
- #
4160
- # source://rexml//lib/rexml/source.rb#37
4161
- def encoding; end
4162
-
4163
- # Inherited from Encoding
4164
- # Overridden to support optimized en/decoding
4165
- #
4166
- # source://rexml//lib/rexml/source.rb#56
4167
- def encoding=(enc); end
4168
-
4169
- # The line number of the last consumed text
4170
- #
4171
- # source://rexml//lib/rexml/source.rb#36
4172
- def line; end
4173
-
4174
- # source://rexml//lib/rexml/source.rb#101
4175
- def match(pattern, cons = T.unsafe(nil)); end
4176
-
4177
- # source://rexml//lib/rexml/source.rb#91
4178
- def match_to(char, pattern); end
4179
-
4180
- # source://rexml//lib/rexml/source.rb#95
4181
- def match_to_consume(char, pattern); end
4182
-
4183
- # source://rexml//lib/rexml/source.rb#112
4184
- def position; end
4185
-
4186
- # source://rexml//lib/rexml/source.rb#84
4187
- def read; end
4188
-
4189
- # Scans the source for a given pattern. Note, that this is not your
4190
- # usual scan() method. For one thing, the pattern argument has some
4191
- # requirements; for another, the source can be consumed. You can easily
4192
- # confuse this method. Originally, the patterns were easier
4193
- # to construct and this method more robust, because this method
4194
- # generated search regexps on the fly; however, this was
4195
- # computationally expensive and slowed down the entire REXML package
4196
- # considerably, since this is by far the most commonly called method.
4197
- # /^\s*(#{your pattern, with no groups})(.*)/. The first group
4198
- # will be returned; the second group is used if the consume flag is
4199
- # set.
4200
- # everything after it in the Source.
4201
- # pattern is not found.
4202
- #
4203
- # @param pattern must be a Regexp, and must be in the form of
4204
- # @param consume if true, the pattern returned will be consumed, leaving
4205
- # @return the pattern, if found, or nil if the Source is empty or the
4206
- #
4207
- # source://rexml//lib/rexml/source.rb#77
4208
- def scan(pattern, cons = T.unsafe(nil)); end
4209
-
4210
- private
4211
-
4212
- # source://rexml//lib/rexml/source.rb#125
4213
- def detect_encoding; end
4214
-
4215
- # source://rexml//lib/rexml/source.rb#146
4216
- def encoding_updated; end
4217
- end
4218
-
4219
- # Represents text nodes in an XML document
4220
- #
4221
- # source://rexml//lib/rexml/text.rb#11
4222
- class REXML::Text < ::REXML::Child
4223
- include ::Comparable
4224
-
4225
- # Constructor
4226
- # +arg+ if a String, the content is set to the String. If a Text,
4227
- # the object is shallowly cloned.
4228
- #
4229
- # +respect_whitespace+ (boolean, false) if true, whitespace is
4230
- # respected
4231
- #
4232
- # +parent+ (nil) if this is a Parent object, the parent
4233
- # will be set to this.
4234
- #
4235
- # +raw+ (nil) This argument can be given three values.
4236
- # If true, then the value of used to construct this object is expected to
4237
- # contain no unescaped XML markup, and REXML will not change the text. If
4238
- # this value is false, the string may contain any characters, and REXML will
4239
- # escape any and all defined entities whose values are contained in the
4240
- # text. If this value is nil (the default), then the raw value of the
4241
- # parent will be used as the raw value for this node. If there is no raw
4242
- # value for the parent, and no value is supplied, the default is false.
4243
- # Use this field if you have entities defined for some text, and you don't
4244
- # want REXML to escape that text in output.
4245
- # Text.new( "<&", false, nil, false ) #-> "&lt;&amp;"
4246
- # Text.new( "&lt;&amp;", false, nil, false ) #-> "&amp;lt;&amp;amp;"
4247
- # Text.new( "<&", false, nil, true ) #-> Parse exception
4248
- # Text.new( "&lt;&amp;", false, nil, true ) #-> "&lt;&amp;"
4249
- # # Assume that the entity "s" is defined to be "sean"
4250
- # # and that the entity "r" is defined to be "russell"
4251
- # Text.new( "sean russell" ) #-> "&s; &r;"
4252
- # Text.new( "sean russell", false, nil, true ) #-> "sean russell"
4253
- #
4254
- # +entity_filter+ (nil) This can be an array of entities to match in the
4255
- # supplied text. This argument is only useful if +raw+ is set to false.
4256
- # Text.new( "sean russell", false, nil, false, ["s"] ) #-> "&s; russell"
4257
- # Text.new( "sean russell", false, nil, true, ["s"] ) #-> "sean russell"
4258
- # In the last example, the +entity_filter+ argument is ignored.
4259
- #
4260
- # +illegal+ INTERNAL USE ONLY
4261
- #
4262
- # @return [Text] a new instance of Text
4263
- #
4264
- # source://rexml//lib/rexml/text.rb#94
4265
- def initialize(arg, respect_whitespace = T.unsafe(nil), parent = T.unsafe(nil), raw = T.unsafe(nil), entity_filter = T.unsafe(nil), illegal = T.unsafe(nil)); end
4266
-
4267
- # Appends text to this text node. The text is appended in the +raw+ mode
4268
- # of this text node.
4269
- #
4270
- # +returns+ the text itself to enable method chain like
4271
- # 'text << "XXX" << "YYY"'.
4272
- #
4273
- # source://rexml//lib/rexml/text.rb#194
4274
- def <<(to_append); end
4275
-
4276
- # +other+ a String or a Text
4277
- # +returns+ the result of (to_s <=> arg.to_s)
4278
- #
4279
- # source://rexml//lib/rexml/text.rb#203
4280
- def <=>(other); end
4281
-
4282
- # source://rexml//lib/rexml/text.rb#184
4283
- def clone; end
4284
-
4285
- # source://rexml//lib/rexml/text.rb#207
4286
- def doctype; end
4287
-
4288
- # @return [Boolean]
4289
- #
4290
- # source://rexml//lib/rexml/text.rb#179
4291
- def empty?; end
4292
-
4293
- # source://rexml//lib/rexml/text.rb#278
4294
- def indent_text(string, level = T.unsafe(nil), style = T.unsafe(nil), indentfirstline = T.unsafe(nil)); end
4295
-
4296
- # source://rexml//lib/rexml/text.rb#233
4297
- def inspect; end
4298
-
4299
- # source://rexml//lib/rexml/text.rb#175
4300
- def node_type; end
4301
-
4302
- # source://rexml//lib/rexml/text.rb#125
4303
- def parent=(parent); end
4304
-
4305
- # If +raw+ is true, then REXML leaves the value alone
4306
- #
4307
- # source://rexml//lib/rexml/text.rb#21
4308
- def raw; end
4309
-
4310
- # If +raw+ is true, then REXML leaves the value alone
4311
- #
4312
- # source://rexml//lib/rexml/text.rb#21
4313
- def raw=(_arg0); end
4314
-
4315
- # Returns the string value of this text node. This string is always
4316
- # escaped, meaning that it is a valid XML text node string, and all
4317
- # entities that can be escaped, have been inserted. This method respects
4318
- # the entity filter set in the constructor.
4319
- #
4320
- # # Assume that the entity "s" is defined to be "sean", and that the
4321
- # # entity "r" is defined to be "russell"
4322
- # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
4323
- # t.to_s #-> "&lt; &amp; &s; russell"
4324
- # t = Text.new( "< & &s; russell", false, nil, false )
4325
- # t.to_s #-> "&lt; &amp; &s; russell"
4326
- # u = Text.new( "sean russell", false, nil, true )
4327
- # u.to_s #-> "sean russell"
4328
- #
4329
- # source://rexml//lib/rexml/text.rb#228
4330
- def to_s; end
4331
-
4332
- # Returns the string value of this text. This is the text without
4333
- # entities, as it might be used programmatically, or printed to the
4334
- # console. This ignores the 'raw' attribute setting, and any
4335
- # entity_filter.
4336
- #
4337
- # # Assume that the entity "s" is defined to be "sean", and that the
4338
- # # entity "r" is defined to be "russell"
4339
- # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
4340
- # t.value #-> "< & sean russell"
4341
- # t = Text.new( "< & &s; russell", false, nil, false )
4342
- # t.value #-> "< & sean russell"
4343
- # u = Text.new( "sean russell", false, nil, true )
4344
- # u.value #-> "sean russell"
4345
- #
4346
- # source://rexml//lib/rexml/text.rb#250
4347
- def value; end
4348
-
4349
- # Sets the contents of this text node. This expects the text to be
4350
- # unnormalized. It returns self.
4351
- #
4352
- # e = Element.new( "a" )
4353
- # e.add_text( "foo" ) # <a>foo</a>
4354
- # e[0].value = "bar" # <a>bar</a>
4355
- # e[0].value = "<a>" # <a>&lt;a&gt;</a>
4356
- #
4357
- # source://rexml//lib/rexml/text.rb#261
4358
- def value=(val); end
4359
-
4360
- # source://rexml//lib/rexml/text.rb#267
4361
- def wrap(string, width, addnewline = T.unsafe(nil)); end
4362
-
4363
- # == DEPRECATED
4364
- # See REXML::Formatters
4365
- #
4366
- # source://rexml//lib/rexml/text.rb#293
4367
- def write(writer, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
4368
-
4369
- # Writes out text, substituting special characters beforehand.
4370
- # +out+ A String, IO, or any other object supporting <<( String )
4371
- # +input+ the text to substitute and the write out
4372
- #
4373
- # z=utf8.unpack("U*")
4374
- # ascOut=""
4375
- # z.each{|r|
4376
- # if r < 0x100
4377
- # ascOut.concat(r.chr)
4378
- # else
4379
- # ascOut.concat(sprintf("&#x%x;", r))
4380
- # end
4381
- # }
4382
- # puts ascOut
4383
- #
4384
- # source://rexml//lib/rexml/text.rb#325
4385
- def write_with_substitution(out, input); end
4386
-
4387
- # FIXME
4388
- # This probably won't work properly
4389
- #
4390
- # source://rexml//lib/rexml/text.rb#305
4391
- def xpath; end
4392
-
4393
- private
4394
-
4395
- # source://rexml//lib/rexml/text.rb#338
4396
- def clear_cache; end
4397
-
4398
- class << self
4399
- # check for illegal characters
4400
- #
4401
- # source://rexml//lib/rexml/text.rb#131
4402
- def check(string, pattern, doctype); end
4403
-
4404
- # source://rexml//lib/rexml/text.rb#405
4405
- def expand(ref, doctype, filter); end
4406
-
4407
- # Escapes all possible entities
4408
- #
4409
- # source://rexml//lib/rexml/text.rb#370
4410
- def normalize(input, doctype = T.unsafe(nil), entity_filter = T.unsafe(nil)); end
4411
-
4412
- # Reads text, substituting entities
4413
- #
4414
- # source://rexml//lib/rexml/text.rb#344
4415
- def read_with_substitution(input, illegal = T.unsafe(nil)); end
4416
-
4417
- # Unescapes all possible entities
4418
- #
4419
- # source://rexml//lib/rexml/text.rb#392
4420
- def unnormalize(string, doctype = T.unsafe(nil), filter = T.unsafe(nil), illegal = T.unsafe(nil)); end
4421
- end
4422
- end
4423
-
4424
- # source://rexml//lib/rexml/undefinednamespaceexception.rb#4
4425
- class REXML::UndefinedNamespaceException < ::REXML::ParseException
4426
- # @return [UndefinedNamespaceException] a new instance of UndefinedNamespaceException
4427
- #
4428
- # source://rexml//lib/rexml/undefinednamespaceexception.rb#5
4429
- def initialize(prefix, source, parser); end
4430
- end
4431
-
4432
- # source://rexml//lib/rexml/validation/validationexception.rb#4
4433
- class REXML::Validation::ValidationException < ::RuntimeError
4434
- # @return [ValidationException] a new instance of ValidationException
4435
- #
4436
- # source://rexml//lib/rexml/validation/validationexception.rb#5
4437
- def initialize(msg); end
4438
- end
4439
-
4440
- # NEEDS DOCUMENTATION
4441
- #
4442
- # source://rexml//lib/rexml/xmldecl.rb#8
4443
- class REXML::XMLDecl < ::REXML::Child
4444
- include ::REXML::Encoding
4445
-
4446
- # @return [XMLDecl] a new instance of XMLDecl
4447
- #
4448
- # source://rexml//lib/rexml/xmldecl.rb#20
4449
- def initialize(version = T.unsafe(nil), encoding = T.unsafe(nil), standalone = T.unsafe(nil)); end
4450
-
4451
- # source://rexml//lib/rexml/xmldecl.rb#56
4452
- def ==(other); end
4453
-
4454
- # source://rexml//lib/rexml/xmldecl.rb#39
4455
- def clone; end
4456
-
4457
- # source://rexml//lib/rexml/xmldecl.rb#102
4458
- def dowrite; end
4459
-
4460
- # source://rexml//lib/rexml/xmldecl.rb#76
4461
- def encoding=(enc); end
4462
-
4463
- # source://rexml//lib/rexml/xmldecl.rb#106
4464
- def inspect; end
4465
-
4466
- # source://rexml//lib/rexml/xmldecl.rb#69
4467
- def node_type; end
4468
-
4469
- # source://rexml//lib/rexml/xmldecl.rb#98
4470
- def nowrite; end
4471
-
4472
- # source://rexml//lib/rexml/encoding.rb#7
4473
- def old_enc=(encoding); end
4474
-
4475
- # Returns the value of attribute standalone.
4476
- #
4477
- # source://rexml//lib/rexml/xmldecl.rb#17
4478
- def stand_alone?; end
4479
-
4480
- # Returns the value of attribute standalone.
4481
- #
4482
- # source://rexml//lib/rexml/xmldecl.rb#17
4483
- def standalone; end
4484
-
4485
- # Sets the attribute standalone
4486
- #
4487
- # @param value the value to set the attribute standalone to.
4488
- #
4489
- # source://rexml//lib/rexml/xmldecl.rb#17
4490
- def standalone=(_arg0); end
4491
-
4492
- # Returns the value of attribute version.
4493
- #
4494
- # source://rexml//lib/rexml/xmldecl.rb#17
4495
- def version; end
4496
-
4497
- # Sets the attribute version
4498
- #
4499
- # @param value the value to set the attribute version to.
4500
- #
4501
- # source://rexml//lib/rexml/xmldecl.rb#17
4502
- def version=(_arg0); end
4503
-
4504
- # indent::
4505
- # Ignored. There must be no whitespace before an XML declaration
4506
- # transitive::
4507
- # Ignored
4508
- # ie_hack::
4509
- # Ignored
4510
- #
4511
- # source://rexml//lib/rexml/xmldecl.rb#49
4512
- def write(writer, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end
4513
-
4514
- # Returns the value of attribute writeencoding.
4515
- #
4516
- # source://rexml//lib/rexml/xmldecl.rb#18
4517
- def writeencoding; end
4518
-
4519
- # Returns the value of attribute writethis.
4520
- #
4521
- # source://rexml//lib/rexml/xmldecl.rb#18
4522
- def writethis; end
4523
-
4524
- # source://rexml//lib/rexml/xmldecl.rb#63
4525
- def xmldecl(version, encoding, standalone); end
4526
-
4527
- private
4528
-
4529
- # source://rexml//lib/rexml/xmldecl.rb#111
4530
- def content(enc); end
4531
-
4532
- class << self
4533
- # Only use this if you do not want the XML declaration to be written;
4534
- # this object is ignored by the XML writer. Otherwise, instantiate your
4535
- # own XMLDecl and add it to the document.
4536
- #
4537
- # Note that XML 1.1 documents *must* include an XML declaration
4538
- #
4539
- # source://rexml//lib/rexml/xmldecl.rb#92
4540
- def default; end
4541
- end
4542
- end
4543
-
4544
- # @private
4545
- #
4546
- # source://rexml//lib/rexml/xpath_parser.rb#959
4547
- class REXML::XPathNode
4548
- # @return [XPathNode] a new instance of XPathNode
4549
- #
4550
- # source://rexml//lib/rexml/xpath_parser.rb#961
4551
- def initialize(node, context = T.unsafe(nil)); end
4552
-
4553
- # Returns the value of attribute context.
4554
- #
4555
- # source://rexml//lib/rexml/xpath_parser.rb#960
4556
- def context; end
4557
-
4558
- # source://rexml//lib/rexml/xpath_parser.rb#970
4559
- def position; end
4560
-
4561
- # Returns the value of attribute raw_node.
4562
- #
4563
- # source://rexml//lib/rexml/xpath_parser.rb#960
4564
- def raw_node; end
4565
- end
4566
-
4567
- # You don't want to use this class. Really. Use XPath, which is a wrapper
4568
- # for this class. Believe me. You don't want to poke around in here.
4569
- # There is strange, dark magic at work in this code. Beware. Go back! Go
4570
- # back while you still can!
4571
- #
4572
- # source://rexml//lib/rexml/xpath_parser.rb#54
4573
- class REXML::XPathParser
4574
- include ::REXML::XMLTokens
4575
-
4576
- # @return [XPathParser] a new instance of XPathParser
4577
- #
4578
- # source://rexml//lib/rexml/xpath_parser.rb#60
4579
- def initialize(strict: T.unsafe(nil)); end
4580
-
4581
- # source://rexml//lib/rexml/xpath_parser.rb#94
4582
- def []=(variable_name, value); end
4583
-
4584
- # Performs a depth-first (document order) XPath search, and returns the
4585
- # first match. This is the fastest, lightest way to return a single result.
4586
- #
4587
- # FIXME: This method is incomplete!
4588
- #
4589
- # source://rexml//lib/rexml/xpath_parser.rb#103
4590
- def first(path_stack, node); end
4591
-
4592
- # source://rexml//lib/rexml/xpath_parser.rb#84
4593
- def get_first(path, nodeset); end
4594
-
4595
- # source://rexml//lib/rexml/xpath_parser.rb#139
4596
- def match(path_stack, nodeset); end
4597
-
4598
- # source://rexml//lib/rexml/xpath_parser.rb#69
4599
- def namespaces=(namespaces = T.unsafe(nil)); end
4600
-
4601
- # source://rexml//lib/rexml/xpath_parser.rb#79
4602
- def parse(path, nodeset); end
4603
-
4604
- # source://rexml//lib/rexml/xpath_parser.rb#89
4605
- def predicate(path, nodeset); end
4606
-
4607
- # source://rexml//lib/rexml/xpath_parser.rb#74
4608
- def variables=(vars = T.unsafe(nil)); end
4609
-
4610
- private
4611
-
4612
- # source://rexml//lib/rexml/xpath_parser.rb#775
4613
- def child(nodeset); end
4614
-
4615
- # source://rexml//lib/rexml/xpath_parser.rb#916
4616
- def compare(a, operator, b); end
4617
-
4618
- # source://rexml//lib/rexml/xpath_parser.rb#678
4619
- def descendant(nodeset, include_self); end
4620
-
4621
- # source://rexml//lib/rexml/xpath_parser.rb#689
4622
- def descendant_recursive(raw_node, new_nodeset, new_nodes, include_self); end
4623
-
4624
- # source://rexml//lib/rexml/xpath_parser.rb#938
4625
- def each_unnode(nodeset); end
4626
-
4627
- # source://rexml//lib/rexml/xpath_parser.rb#637
4628
- def enter(tag, *args); end
4629
-
4630
- # source://rexml//lib/rexml/xpath_parser.rb#815
4631
- def equality_relational_compare(set1, op, set2); end
4632
-
4633
- # source://rexml//lib/rexml/xpath_parser.rb#591
4634
- def evaluate_predicate(expression, nodesets); end
4635
-
4636
- # Expr takes a stack of path elements and a set of nodes (either a Parent
4637
- # or an Array and returns an Array of matching nodes
4638
- #
4639
- # source://rexml//lib/rexml/xpath_parser.rb#175
4640
- def expr(path_stack, nodeset, context = T.unsafe(nil)); end
4641
-
4642
- # source://rexml//lib/rexml/xpath_parser.rb#582
4643
- def filter_nodeset(nodeset); end
4644
-
4645
- # source://rexml//lib/rexml/xpath_parser.rb#745
4646
- def following(node); end
4647
-
4648
- # source://rexml//lib/rexml/xpath_parser.rb#756
4649
- def following_node_of(node); end
4650
-
4651
- # Returns a String namespace for a node, given a prefix
4652
- # The rules are:
4653
- #
4654
- # 1. Use the supplied namespace mapping first.
4655
- # 2. If no mapping was supplied, use the context node to look up the namespace
4656
- #
4657
- # source://rexml//lib/rexml/xpath_parser.rb#163
4658
- def get_namespace(node, prefix); end
4659
-
4660
- # source://rexml//lib/rexml/xpath_parser.rb#642
4661
- def leave(tag, *args); end
4662
-
4663
- # source://rexml//lib/rexml/xpath_parser.rb#763
4664
- def next_sibling_node(node); end
4665
-
4666
- # source://rexml//lib/rexml/xpath_parser.rb#477
4667
- def node_test(path_stack, nodesets, any_type: T.unsafe(nil)); end
4668
-
4669
- # source://rexml//lib/rexml/xpath_parser.rb#802
4670
- def norm(b); end
4671
-
4672
- # source://rexml//lib/rexml/xpath_parser.rb#890
4673
- def normalize_compare_values(a, operator, b); end
4674
-
4675
- # Builds a nodeset of all of the preceding nodes of the supplied node,
4676
- # in reverse document order
4677
- # preceding:: includes every element in the document that precedes this node,
4678
- # except for ancestors
4679
- #
4680
- # source://rexml//lib/rexml/xpath_parser.rb#708
4681
- def preceding(node); end
4682
-
4683
- # source://rexml//lib/rexml/xpath_parser.rb#730
4684
- def preceding_node_of(node); end
4685
-
4686
- # Reorders an array of nodes so that they are in document order
4687
- # It tries to do this efficiently.
4688
- #
4689
- # FIXME: I need to get rid of this, but the issue is that most of the XPath
4690
- # interpreter functions as a filter, which means that we lose context going
4691
- # in and out of function calls. If I knew what the index of the nodes was,
4692
- # I wouldn't have to do this. Maybe add a document IDX for each node?
4693
- # Problems with mutable documents. Or, rewrite everything.
4694
- #
4695
- # source://rexml//lib/rexml/xpath_parser.rb#655
4696
- def sort(array_of_nodes, order); end
4697
-
4698
- # source://rexml//lib/rexml/xpath_parser.rb#441
4699
- def step(path_stack, any_type: T.unsafe(nil), order: T.unsafe(nil)); end
4700
-
4701
- # @return [Boolean]
4702
- #
4703
- # source://rexml//lib/rexml/xpath_parser.rb#154
4704
- def strict?; end
4705
-
4706
- # source://rexml//lib/rexml/xpath_parser.rb#630
4707
- def trace(*args); end
4708
-
4709
- # source://rexml//lib/rexml/xpath_parser.rb#950
4710
- def unnode(nodeset); end
4711
-
4712
- # source://rexml//lib/rexml/xpath_parser.rb#877
4713
- def value_type(value); end
4714
- end
4715
-
4716
- # source://rexml//lib/rexml/xpath_parser.rb#58
4717
- REXML::XPathParser::DEBUG = T.let(T.unsafe(nil), FalseClass)