Class: Aws::Xml::Parser::LibxmlEngine Private

Inherits:
Object
  • Object
show all
Includes:
LibXML::XML::SaxParser::Callbacks
Defined in:
lib/aws-sdk-core/xml/parser/engines/libxml.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(stack) ⇒ LibxmlEngine

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LibxmlEngine



10
11
12
# File 'lib/aws-sdk-core/xml/parser/engines/libxml.rb', line 10

def initialize(stack)
  @stack = stack
end

Instance Method Details

#on_characters(chars) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/aws-sdk-core/xml/parser/engines/libxml.rb', line 40

def on_characters(chars)
  @stack.text(chars)
end

#on_end_element_ns(*ignored) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/aws-sdk-core/xml/parser/engines/libxml.rb', line 36

def on_end_element_ns(*ignored)
  @stack.end_element
end

#on_error(msg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/aws-sdk-core/xml/parser/engines/libxml.rb', line 44

def on_error(msg)
  @stack.error(msg)
end

#on_start_element_ns(element_name, attributes, prefix = nil, uri = nil, ns = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aws-sdk-core/xml/parser/engines/libxml.rb', line 20

def on_start_element_ns(element_name, attributes, prefix = nil, uri = nil, ns = {})
  # libxml-ruby does not provide a mapping from element attribute
  # names to their qname prefixes. The following code line assumes
  # that if a attribute ns is defined it applies to all attributes.
  # This is necessary to support parsing S3 Object ACL Grantees.
  # qnames are not used by any other AWS attribute. Also, new
  # services are using JSON, limiting the possible blast radius
  # of this patch.
  attr_ns_prefix = ns.keys.first
  @stack.start_element(element_name)
  attributes.each do |attr_name, attr_value|
    attr_name = "#{attr_ns_prefix}:#{attr_name}" if attr_ns_prefix
    @stack.attr(attr_name, attr_value)
  end
end

#parse(xml) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
# File 'lib/aws-sdk-core/xml/parser/engines/libxml.rb', line 14

def parse(xml)
  parser = ::LibXML::XML::SaxParser.string(xml)
  parser.callbacks = self
  parser.parse
end