Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • soap/parser.rb

Class/Module Index [+]

Quicksearch

SOAP::Parser

Attributes

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

Public Class Methods

new(opt = {}) click to toggle 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) click to toggle 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() click to toggle source
 
               # File soap/parser.rb, line 80
def charset
  @parser.charset
end
            
end_element(name) click to toggle 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) click to toggle 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) click to toggle 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