Class: WSDL::XMLSchema::Parser

Inherits:
Object
  • Object
show all
Includes:
XSD
Defined in:
lib/action_web_service/wsdl/xmlSchema/parser.rb

Defined Under Namespace

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

Constant Summary

Constants included from XSD

XSD::AnySimpleTypeLiteral, XSD::AnySimpleTypeName, XSD::AnyTypeLiteral, XSD::AnyTypeName, XSD::AnyURILiteral, XSD::AttrNilName, XSD::AttrType, XSD::AttrTypeName, XSD::Base64BinaryLiteral, XSD::BooleanLiteral, XSD::ByteLiteral, XSD::DateLiteral, XSD::DateTimeLiteral, XSD::DecimalLiteral, XSD::DoubleLiteral, XSD::DurationLiteral, XSD::FloatLiteral, XSD::GDayLiteral, XSD::GMonthDayLiteral, XSD::GMonthLiteral, XSD::GYearLiteral, XSD::GYearMonthLiteral, XSD::HexBinaryLiteral, XSD::InstanceNamespace, XSD::IntLiteral, XSD::IntegerLiteral, XSD::LongLiteral, XSD::Namespace, XSD::NegativeIntegerLiteral, XSD::NilLiteral, XSD::NilValue, XSD::NonNegativeIntegerLiteral, XSD::NonPositiveIntegerLiteral, XSD::NormalizedStringLiteral, XSD::PositiveIntegerLiteral, XSD::QNameLiteral, XSD::ShortLiteral, XSD::StringLiteral, XSD::TimeLiteral, XSD::UnsignedByteLiteral, XSD::UnsignedIntLiteral, XSD::UnsignedLongLiteral, XSD::UnsignedShortLiteral

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ Parser

Returns a new instance of Parser.



50
51
52
53
54
55
56
57
# File 'lib/action_web_service/wsdl/xmlSchema/parser.rb', line 50

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

#characters(text) ⇒ Object



86
87
88
89
90
91
92
93
94
95
# File 'lib/action_web_service/wsdl/xmlSchema/parser.rb', line 86

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

#charsetObject



67
68
69
# File 'lib/action_web_service/wsdl/xmlSchema/parser.rb', line 67

def charset
  @parser.charset
end

#end_element(name) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/action_web_service/wsdl/xmlSchema/parser.rb', line 97

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

#parse(string_or_readable) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/action_web_service/wsdl/xmlSchema/parser.rb', line 59

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

#start_element(name, attrs) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/action_web_service/wsdl/xmlSchema/parser.rb', line 71

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