Sha256: 6547c56d4d9159d6dd327ea58f928d6a251c41211e2c03d00515bb08f8a902c7

Contents?: true

Size: 1004 Bytes

Versions: 180

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

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

180 entries across 180 versions & 1 rubygems

Version Path
aws-sdk-core-3.183.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.183.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.182.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.181.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.181.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.180.3 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.180.2 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.180.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.180.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.179.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.178.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.177.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.176.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.176.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.175.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.174.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.173.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.173.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.172.0 lib/aws-sdk-core/xml/parser/engines/rexml.rb
aws-sdk-core-3.171.1 lib/aws-sdk-core/xml/parser/engines/rexml.rb