# 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
# 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
# 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
# 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
# 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
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.