ruby-lsp 0.0.1 → 0.0.4

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