twirbet 0.1.0 → 0.1.1

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