Class: WSDL::Parser

Inherits:
Object show all
Includes:
WSDL
Defined in:
lib/wsdl/parser.rb

Defined Under Namespace

Classes: AttributeConstraintError, ElementConstraintError, FormatDecodeError, ParseError, ParseFrame, UnexpectedElementError, UnknownAttributeError, UnknownElementError

Constant Summary

Constant Summary

Constants included from WSDL

ArrayTypeAttrName, BindingAttrName, BindingName, DefinitionsName, DocumentationName, ElementAttrName, FaultName, ImportName, InputName, LocationAttrName, MessageAttrName, MessageName, NameAttrName, Namespace, NamespaceAttrName, OperationName, OutputName, ParameterOrderAttrName, PartName, PortName, PortTypeName, SOAPAddressName, SOAPBindingName, SOAPBindingNamespace, SOAPBodyName, SOAPFaultName, SOAPHeaderName, SOAPOperationName, SchemaName, ServiceName, TargetNamespaceAttrName, TypeAttrName, TypesName, Version

Instance Method Summary (collapse)

Constructor Details

- (Parser) initialize(opt = {})



52
53
54
55
56
57
58
59
# File 'lib/wsdl/parser.rb', line 52

def initialize(opt = {})
  @parser = XSD::XMLParser.create_parser(self, opt)
  @parsestack = nil
  @lastnode = nil
  @ignored = {}
  @location = opt[:location]
  @originalroot = opt[:originalroot]
end

Instance Method Details

- (Object) characters(text)



89
90
91
92
93
94
95
96
97
98
# File 'lib/wsdl/parser.rb', line 89

def characters(text)
  lastframe = @parsestack.last
  if lastframe
    # Need not to be cloned because character does not have attr.
    ns = lastframe.ns
    decode_text(ns, text)
  else
    p text if $DEBUG
  end
end

- (Object) charset



69
70
71
# File 'lib/wsdl/parser.rb', line 69

def charset
  @parser.charset
end

- (Object) end_element(name)



100
101
102
103
104
105
106
107
# File 'lib/wsdl/parser.rb', line 100

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)
  @lastnode = lastframe.node
end

- (Object) parse(string_or_readable)



61
62
63
64
65
66
67
# File 'lib/wsdl/parser.rb', line 61

def parse(string_or_readable)
  @parsestack = []
  @lastnode = nil
  @textbuf = ''
  @parser.do_parse(string_or_readable)
  @lastnode
end

- (Object) start_element(name, attrs)



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/wsdl/parser.rb', line 73

def start_element(name, attrs)
  lastframe = @parsestack.last
  ns = parent = nil
  if lastframe
    ns = lastframe.ns
    parent = lastframe.node
  else
    ns = ::SOAP::NS.new
    parent = nil
  end
  # ns might be the same
  ns, attrs = XSD::XMLParser.filter_ns(ns, attrs)
  node = decode_tag(ns, name, attrs, parent)
  @parsestack << ParseFrame.new(ns, name, node)
end