Class: SOAP::Parser

Class | SOAP::Parser
In: | soap/parser.rb
Parent: | Object

### Methods

characters charset end_element new parse start_element

### Included Modules

SOAP

### Classes and Modules

Class SOAP::Parser::FormatDecodeError
Class SOAP::Parser::ParseError
Class SOAP::Parser::ParseFrame
Class SOAP::Parser::UnexpectedElementError

### Attributes

allow_unqualified_element | [RW] |
decode_typemap | [RW] |
default_encodingstyle | [RW] |
envelopenamespace | [RW] |

### Public Class methods

new(opt = {})

[Source]

    # File soap/parser.rb, line 68
      def initialize(opt = {})
        @opt = opt
        @parser = XSD::XMLParser.create_parser(self, opt)
        @parsestack = nil
        @lastnode = nil
        @handlers = {}
        @envelopenamespace = opt[:envelopenamespace] || EnvelopeNamespace
        @default_encodingstyle = opt[:default_encodingstyle] || EncodingNamespace
        @decode_typemap = opt[:decode_typemap] || nil
        @allow_unqualified_element = opt[:allow_unqualified_element] || false
      end

### Public Instance methods

characters(text)

[Source]

    # File soap/parser.rb, line 135
      def characters(text)
        lastframe = @parsestack.last
        if lastframe
          # Need not to be cloned because character does not have attr.
          decode_text(lastframe.ns, text, lastframe.encodingstyle)
        else
          # Ignore Text outside of SOAP Envelope.
          p text if $DEBUG
        end
      end

charset()

[Source]

    # File soap/parser.rb, line 80
      def charset
        @parser.charset
      end

end_element(name)

[Source]

    # File soap/parser.rb, line 146
      def end_element(name)
        lastframe = @parsestack.pop
        unless name == lastframe.name
          raise UnexpectedElementError.new("Closing element name '#{ name }' does not match with opening element '#{ lastframe.name }'.")
        end
        decode_tag_end(lastframe.ns, lastframe.node, lastframe.encodingstyle)
        @lastnode = lastframe.node.node
      end

parse(string_or_readable)

[Source]

    # File soap/parser.rb, line 84
      def parse(string_or_readable)
        @parsestack = []
        @lastnode = nil

        @handlers.each do |uri, handler|
          handler.decode_prologue
        end

        @parser.do_parse(string_or_readable)

        unless @parsestack.empty?
          raise FormatDecodeError.new("Unbalanced tag in XML.")
        end

        @handlers.each do |uri, handler|
          handler.decode_epilogue
        end

        @lastnode
      end

start_element(name, attrs)

[Source]

    # File soap/parser.rb, line 105
      def start_element(name, attrs)
        lastframe = @parsestack.last
        ns = parent = parent_encodingstyle = nil
        if lastframe
          ns = lastframe.ns.clone_ns
          parent = lastframe.node
          parent_encodingstyle = lastframe.encodingstyle
        else
          ns = XSD::NS.new
          parent = ParseFrame::NodeContainer.new(nil)
          parent_encodingstyle = nil
        end

        attrs = XSD::XMLParser.filter_ns(ns, attrs)
        encodingstyle = find_encodingstyle(ns, attrs)

        # Children's encodingstyle is derived from its parent.
        if encodingstyle.nil?
          if parent.node.is_a?(SOAPHeader)
            encodingstyle = LiteralNamespace
          else
            encodingstyle = parent_encodingstyle || @default_encodingstyle
          end
        end

        node = decode_tag(ns, name, attrs, parent, encodingstyle)

        @parsestack << ParseFrame.new(ns, name, node, encodingstyle)
      end

[Validate]