Class: Aws::Xml::Parser Private

Inherits:
Object
  • Object
show all
Includes:
Seahorse::Model::Shapes
Defined in:
lib/aws-sdk-core/xml/parser.rb,
lib/aws-sdk-core/xml/parser/frame.rb,
lib/aws-sdk-core/xml/parser/stack.rb,
lib/aws-sdk-core/xml/parser/engines/ox.rb,
lib/aws-sdk-core/xml/parser/engines/oga.rb,
lib/aws-sdk-core/xml/parser/engines/rexml.rb,
lib/aws-sdk-core/xml/parser/parsing_error.rb,
lib/aws-sdk-core/xml/parser/engines/libxml.rb,
lib/aws-sdk-core/xml/parser/engines/nokogiri.rb

Overview

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.

A SAX-style XML parser that uses a shape context to handle types.

Defined Under Namespace

Classes: BlobFrame, BooleanFrame, FlatListFrame, FloatFrame, Frame, IntegerFrame, LibxmlEngine, ListFrame, MapEntryFrame, MapFrame, NokogiriEngine, NullFrame, OgaEngine, OxEngine, ParsingError, RexmlEngine, Stack, StringFrame, StructureFrame, TimestampFrame

Constant Summary collapse

FRAME_CLASSES =

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

{
  NilClass => NullFrame,
  BlobShape => BlobFrame,
  BooleanShape => BooleanFrame,
  FloatShape => FloatFrame,
  IntegerShape => IntegerFrame,
  ListShape => ListFrame,
  MapShape => MapFrame,
  StringShape => StringFrame,
  StructureShape => StructureFrame,
  TimestampShape => TimestampFrame,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules, options = {}) ⇒ Parser

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 Parser.

Parameters:

  • rules (Seahorse::Model::ShapeRef)


18
19
20
21
# File 'lib/aws-sdk-core/xml/parser.rb', line 18

def initialize(rules, options = {})
  @rules = rules
  @engine = options[:engine] || self.class.engine
end

Class Method Details

.engineClass

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 the default parsing engine. One of:

Returns:



57
58
59
# File 'lib/aws-sdk-core/xml/parser.rb', line 57

def engine
  @engine
end

.engine=(engine) ⇒ 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.

Parameters:

  • engine (Symbol, Class)

    Must be one of the following values:

    • :ox

    • :oga

    • :libxml

    • :nokogiri

    • :rexml



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

def engine= engine
  @engine = Class === engine ? engine : load_engine(engine)
end

Instance Method Details

#parse(xml, target = nil) ⇒ Structure

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.

Parameters:

  • xml (String)

    An XML document string to parse.

  • target (Structure) (defaults to: nil)

    (nil)

Returns:



26
27
28
29
30
31
# File 'lib/aws-sdk-core/xml/parser.rb', line 26

def parse(xml, target = nil)
  xml = '<xml/>' if xml.nil? or xml.empty?
  stack = Stack.new(@rules, target)
  @engine.new(stack).parse(xml.to_s)
  stack.result
end