Sha256: 25e6fd15326dc7df41b66877e0c20238c5cc5c70b4ed02c05e29e417e0ef55e8

Contents?: true

Size: 869 Bytes

Versions: 81

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

# Oga Java requires JRuby.runtime
require 'jruby' if RUBY_PLATFORM == 'java'
require 'oga'

module Aws
  module Xml
    class Parser
      class OgaEngine

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

        def parse(xml)
          Oga.sax_parse_xml(self, xml, strict:true)
        rescue LL::ParserError => error
          raise ParsingError.new(error.message, nil, nil)
        end

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

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

        def after_element(_, _)
          @stack.end_element
          @depth -= 1
        end

      end
    end
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
aws-sdk-core-3.169.0 lib/aws-sdk-core/xml/parser/engines/oga.rb