Sha256: 9abab43c7108c8f5d33baeb15ecd25f1430fde2d641e5c9ff317a54382faf172

Contents?: true

Size: 973 Bytes

Versions: 11

Compression:

Stored size: 973 Bytes

Contents

require 'rexml/document'
require 'rexml/streamlistener'

module Aws
  module Xml
    class Parser
      class RexmlEngine

        include REXML::StreamListener

        def initialize(stack)
          @stack = stack
          @depth = 0
        end

        def parse(xml)
          begin
            mutable_xml = xml.dup # REXML only accepts mutable string
            source = REXML::Source.new(mutable_xml)
            REXML::Parsers::StreamParser.new(source, self).parse
          rescue REXML::ParseException => error
            @stack.error(error.message)
          end
        end

        def tag_start(name, attrs)
          @depth += 1
          @stack.start_element(name)
          attrs.each do |attr|
            @stack.attr(*attr)
          end
        end

        def text(value)
          @stack.text(value) if @depth > 0
        end

        def tag_end(name)
          @stack.end_element
          @depth -= 1
        end

      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
aws-sdk-core-3.100.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.99.2 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.99.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.99.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.98.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.97.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.97.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.96.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.96.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.95.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.94.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb