summaryrefslogtreecommitdiff
path: root/lib/wsdl
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-20 14:41:10 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-20 14:41:10 +0000
commite8ed175fe02aecab21ce50e85e27fe79137d8c31 (patch)
tree8a6d14560604b592f177ffaaa0c146c756edb2e9 /lib/wsdl
parent330a8e51c56f5386753f55ba8e656a62471a36ba (diff)
* added files:
* lib/soap/mapping/wsdl*.rb * lib/wsdl/soap/element.rb * lib/wsdl/xmlSchema/simpleContent.rb * modified files: * lib/soap/* * lib/wsdl/* * lib/xsd/* * test/soap/* * test/wsdl/* * test/xsd/* * sample/soap/* * sample/sdl/* * summary * imported from the soap4r repository. Version: 1.5.3-ruby1.8.2 * added several XSD basetype support: nonPositiveInteger, negativeInteger, nonNegativeInteger, unsignedLong, unsignedInt, unsignedShort, unsignedByte, positiveInteger * HTTP client connection/send/receive timeout support. * HTTP client/server gzipped content encoding support. * improved WSDL schema definition support; still is far from complete, but is making step by step improovement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/wsdl')
-rw-r--r--lib/wsdl/binding.rb2
-rw-r--r--lib/wsdl/definitions.rb4
-rw-r--r--lib/wsdl/import.rb4
-rw-r--r--lib/wsdl/importer.rb9
-rw-r--r--lib/wsdl/message.rb2
-rw-r--r--lib/wsdl/operation.rb4
-rw-r--r--lib/wsdl/operationBinding.rb2
-rw-r--r--lib/wsdl/param.rb2
-rw-r--r--lib/wsdl/parser.rb24
-rw-r--r--lib/wsdl/part.rb2
-rw-r--r--lib/wsdl/port.rb2
-rw-r--r--lib/wsdl/portType.rb2
-rw-r--r--lib/wsdl/service.rb2
-rw-r--r--lib/wsdl/soap/address.rb2
-rw-r--r--lib/wsdl/soap/binding.rb9
-rw-r--r--lib/wsdl/soap/body.rb8
-rw-r--r--lib/wsdl/soap/cgiStubCreator.rb9
-rw-r--r--lib/wsdl/soap/classDefCreator.rb156
-rw-r--r--lib/wsdl/soap/classDefCreatorSupport.rb22
-rw-r--r--lib/wsdl/soap/clientSkeltonCreator.rb2
-rw-r--r--lib/wsdl/soap/complexType.rb40
-rw-r--r--lib/wsdl/soap/data.rb1
-rw-r--r--lib/wsdl/soap/driverCreator.rb11
-rw-r--r--lib/wsdl/soap/fault.rb8
-rw-r--r--lib/wsdl/soap/header.rb10
-rw-r--r--lib/wsdl/soap/headerfault.rb8
-rw-r--r--lib/wsdl/soap/methodDefCreator.rb55
-rw-r--r--lib/wsdl/soap/operation.rb9
-rw-r--r--lib/wsdl/soap/servantSkeltonCreator.rb16
-rw-r--r--lib/wsdl/soap/standaloneServerStubCreator.rb16
-rw-r--r--lib/wsdl/xmlSchema/all.rb8
-rw-r--r--lib/wsdl/xmlSchema/any.rb12
-rw-r--r--lib/wsdl/xmlSchema/attribute.rb25
-rw-r--r--lib/wsdl/xmlSchema/choice.rb8
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb30
-rw-r--r--lib/wsdl/xmlSchema/content.rb4
-rw-r--r--lib/wsdl/xmlSchema/data.rb3
-rw-r--r--lib/wsdl/xmlSchema/element.rb45
-rw-r--r--lib/wsdl/xmlSchema/enumeration.rb4
-rw-r--r--lib/wsdl/xmlSchema/import.rb4
-rw-r--r--lib/wsdl/xmlSchema/parser.rb31
-rw-r--r--lib/wsdl/xmlSchema/schema.rb8
-rw-r--r--lib/wsdl/xmlSchema/sequence.rb8
-rw-r--r--lib/wsdl/xmlSchema/simpleType.rb2
44 files changed, 382 insertions, 253 deletions
diff --git a/lib/wsdl/binding.rb b/lib/wsdl/binding.rb
index e8c9d5be9d..58a21d820d 100644
--- a/lib/wsdl/binding.rb
+++ b/lib/wsdl/binding.rb
@@ -52,7 +52,7 @@ class Binding < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
when TypeAttrName
@type = value
else
diff --git a/lib/wsdl/definitions.rb b/lib/wsdl/definitions.rb
index c530220fde..a7c71f2a93 100644
--- a/lib/wsdl/definitions.rb
+++ b/lib/wsdl/definitions.rb
@@ -216,9 +216,9 @@ class Definitions < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(@targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
when TargetNamespaceAttrName
- self.targetnamespace = value
+ self.targetnamespace = value.source
else
nil
end
diff --git a/lib/wsdl/import.rb b/lib/wsdl/import.rb
index ab244f6ca6..706cb95fe2 100644
--- a/lib/wsdl/import.rb
+++ b/lib/wsdl/import.rb
@@ -39,13 +39,13 @@ class Import < Info
def parse_attr(attr, value)
case attr
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
if @content
@content.targetnamespace = @namespace
end
@namespace
when LocationAttrName
- @location = value
+ @location = value.source
@content = import(@location)
if @content.is_a?(Definitions)
@content.root = root
diff --git a/lib/wsdl/importer.rb b/lib/wsdl/importer.rb
index fac02b51a0..873be710b5 100644
--- a/lib/wsdl/importer.rb
+++ b/lib/wsdl/importer.rb
@@ -25,6 +25,7 @@ class Importer
end
def import(location)
+ STDERR.puts("importing: #{location}") if $DEBUG
content = nil
if FileTest.exist?(location)
content = File.open(location).read
@@ -42,12 +43,8 @@ class Importer
begin
WSDL::Parser.new(opt).parse(content)
rescue WSDL::Parser::ParseError => orgexcn
- begin
- require 'wsdl/xmlSchema/parser'
- WSDL::XMLSchema::Parser.new(opt).parse(content)
- rescue
- raise orgexcn
- end
+ require 'wsdl/xmlSchema/parser'
+ WSDL::XMLSchema::Parser.new(opt).parse(content)
end
end
diff --git a/lib/wsdl/message.rb b/lib/wsdl/message.rb
index a346708cf4..cecc602da3 100644
--- a/lib/wsdl/message.rb
+++ b/lib/wsdl/message.rb
@@ -43,7 +43,7 @@ class Message < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(parent.targetnamespace, value)
+ @name = XSD::QName.new(parent.targetnamespace, value.source)
else
nil
end
diff --git a/lib/wsdl/operation.rb b/lib/wsdl/operation.rb
index be28446d34..3c1f66859f 100644
--- a/lib/wsdl/operation.rb
+++ b/lib/wsdl/operation.rb
@@ -95,11 +95,11 @@ class Operation < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
when TypeAttrName
@type = value
when ParameterOrderAttrName
- @parameter_order = value.split(/\s+/)
+ @parameter_order = value.source.split(/\s+/)
else
nil
end
diff --git a/lib/wsdl/operationBinding.rb b/lib/wsdl/operationBinding.rb
index 4c04a884ea..fb44eb9660 100644
--- a/lib/wsdl/operationBinding.rb
+++ b/lib/wsdl/operationBinding.rb
@@ -69,7 +69,7 @@ class OperationBinding < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
else
nil
end
diff --git a/lib/wsdl/param.rb b/lib/wsdl/param.rb
index 06dd3beb7e..581ecbd8d3 100644
--- a/lib/wsdl/param.rb
+++ b/lib/wsdl/param.rb
@@ -63,7 +63,7 @@ class Param < Info
when MessageAttrName
@message = value
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
else
nil
end
diff --git a/lib/wsdl/parser.rb b/lib/wsdl/parser.rb
index 6387911f79..417ea20b47 100644
--- a/lib/wsdl/parser.rb
+++ b/lib/wsdl/parser.rb
@@ -123,25 +123,11 @@ private
o.parent = parent if o.parent.nil?
end
attrs.each do |key, value|
- attr = unless /:/ =~ key
- XSD::QName.new(nil, key)
- else
- ns.parse(key)
- end
- value_ele = if /:/ !~ value
- value
- elsif /^http:\/\// =~ value # ToDo: ugly.
- value
- else
- begin
- ns.parse(value)
- rescue
- value
- end
- end
- unless o.parse_attr(attr, value_ele)
- STDERR.puts("Unknown attr #{ attr }.")
- # raise UnknownAttributeError.new("Unknown attr #{ attr }.")
+ attr_ele = ns.parse(key, true)
+ value_ele = ns.parse(value, true)
+ value_ele.source = value # for recovery; value may not be a QName
+ unless o.parse_attr(attr_ele, value_ele)
+ STDERR.puts("Unknown attr #{ attr_ele }.")
end
end
o
diff --git a/lib/wsdl/part.rb b/lib/wsdl/part.rb
index 30f71f15d9..5dafd4ee73 100644
--- a/lib/wsdl/part.rb
+++ b/lib/wsdl/part.rb
@@ -37,7 +37,7 @@ class Part < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = value
+ @name = value.source
when ElementAttrName
@element = value
when TypeAttrName
diff --git a/lib/wsdl/port.rb b/lib/wsdl/port.rb
index e6553f1287..15ba86ad7c 100644
--- a/lib/wsdl/port.rb
+++ b/lib/wsdl/port.rb
@@ -71,7 +71,7 @@ class Port < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
when BindingAttrName
@binding = value
else
diff --git a/lib/wsdl/portType.rb b/lib/wsdl/portType.rb
index e3cf9b51ec..86893ba039 100644
--- a/lib/wsdl/portType.rb
+++ b/lib/wsdl/portType.rb
@@ -61,7 +61,7 @@ class PortType < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
else
nil
end
diff --git a/lib/wsdl/service.rb b/lib/wsdl/service.rb
index 0e0843a098..652b127331 100644
--- a/lib/wsdl/service.rb
+++ b/lib/wsdl/service.rb
@@ -50,7 +50,7 @@ class Service < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
else
nil
end
diff --git a/lib/wsdl/soap/address.rb b/lib/wsdl/soap/address.rb
index e4558e4ff8..0b2b59caf0 100644
--- a/lib/wsdl/soap/address.rb
+++ b/lib/wsdl/soap/address.rb
@@ -28,7 +28,7 @@ class Address < Info
def parse_attr(attr, value)
case attr
when LocationAttrName
- @location = value
+ @location = value.source
else
nil
end
diff --git a/lib/wsdl/soap/binding.rb b/lib/wsdl/soap/binding.rb
index 1cfe9b9cc4..7e15a99701 100644
--- a/lib/wsdl/soap/binding.rb
+++ b/lib/wsdl/soap/binding.rb
@@ -30,13 +30,14 @@ class Binding < Info
def parse_attr(attr, value)
case attr
when StyleAttrName
- if ["document", "rpc"].include?(value)
- @style = value.intern
+ if ["document", "rpc"].include?(value.source)
+ @style = value.source.intern
else
- raise AttributeConstraintError.new("Unexpected value #{ value }.")
+ raise Parser::AttributeConstraintError.new(
+ "Unexpected value #{ value }.")
end
when TransportAttrName
- @transport = value
+ @transport = value.source
else
nil
end
diff --git a/lib/wsdl/soap/body.rb b/lib/wsdl/soap/body.rb
index 47de6b1e1a..47e99f381b 100644
--- a/lib/wsdl/soap/body.rb
+++ b/lib/wsdl/soap/body.rb
@@ -34,13 +34,13 @@ class Body < Info
def parse_attr(attr, value)
case attr
when PartsAttrName
- @parts = value
+ @parts = value.source
when UseAttrName
- @use = value
+ @use = value.source
when EncodingStyleAttrName
- @encodingstyle = value
+ @encodingstyle = value.source
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
else
nil
end
diff --git a/lib/wsdl/soap/cgiStubCreator.rb b/lib/wsdl/soap/cgiStubCreator.rb
index e5b64336e7..68ecfaf0a4 100644
--- a/lib/wsdl/soap/cgiStubCreator.rb
+++ b/lib/wsdl/soap/cgiStubCreator.rb
@@ -55,8 +55,13 @@ Methods = [
<<-EOD
super(*arg)
servant = #{class_name}.new
- #{class_name}::Methods.each do |name_as, name, params, soapaction, ns|
- add_method_with_namespace_as(ns, servant, name, name_as, params, soapaction)
+ #{class_name}::Methods.each do |name_as, name, param_def, soapaction, namespace, style|
+ qname = XSD::QName.new(namespace, name_as)
+ if style == :document
+ @router.add_document_method(servant, qname, soapaction, name, param_def)
+ else
+ @router.add_rpc_method(servant, qname, soapaction, name, param_def)
+ end
end
self.mapping_registry = #{class_name}::MappingRegistry
self.level = Logger::Severity::ERROR
diff --git a/lib/wsdl/soap/classDefCreator.rb b/lib/wsdl/soap/classDefCreator.rb
index 6c7d381932..13f7802b72 100644
--- a/lib/wsdl/soap/classDefCreator.rb
+++ b/lib/wsdl/soap/classDefCreator.rb
@@ -19,42 +19,71 @@ class ClassDefCreator
include ClassDefCreatorSupport
def initialize(definitions)
+ @elements = definitions.collect_elements
@simpletypes = definitions.collect_simpletypes
@complextypes = definitions.collect_complextypes
- @faulttypes = definitions.collect_faulttypes
+ @faulttypes = definitions.collect_faulttypes if definitions.respond_to?(:collect_faulttypes)
end
def dump(class_name = nil)
- result = ""
+ result = ''
if class_name
result = dump_classdef(class_name)
else
- @complextypes.each do |type|
- case type.compoundtype
- when :TYPE_STRUCT
- result << dump_classdef(type)
- when :TYPE_ARRAY
- result << dump_arraydef(type)
- else
- raise RuntimeError.new("Unknown complexContent definition...")
- end
- result << "\n"
+ str = dump_element
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ str = dump_complextype
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ str = dump_simpletype
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
end
-
- result << @simpletypes.collect { |type|
- dump_simpletypedef(type)
- }.join("\n")
end
result
end
private
+ def dump_element
+ @elements.collect { |ele|
+ ele.local_complextype ? dump_classdef(ele) : ''
+ }.join("\n")
+ end
+
+ def dump_simpletype
+ @simpletypes.collect { |type|
+ dump_simpletypedef(type)
+ }.join("\n")
+ end
+
+ def dump_complextype
+ @complextypes.collect { |type|
+ case type.compoundtype
+ when :TYPE_STRUCT
+ dump_classdef(type)
+ when :TYPE_ARRAY
+ dump_arraydef(type)
+ when :TYPE_SIMPLE
+ STDERR.puts("not implemented: ToDo")
+ else
+ raise RuntimeError.new(
+ "Unknown kind of complexContent: #{type.compoundtype}")
+ end
+ }.join("\n")
+ end
+
def dump_simpletypedef(simpletype)
qname = simpletype.name
if simpletype.restriction.enumeration.empty?
STDERR.puts("#{qname}: simpleType which is not enum type not supported.")
- return ""
+ return ''
end
c = XSD::CodeGen::ModuleDef.new(create_class_name(qname))
c.comment = "#{ qname.namespace }"
@@ -64,45 +93,98 @@ private
c.dump
end
- def dump_classdef(complextype)
- qname = complextype.name
- if @faulttypes.index(qname)
+ def dump_classdef(type_or_element)
+ qname = type_or_element.name
+ if @faulttypes and @faulttypes.index(qname)
c = XSD::CodeGen::ClassDef.new(create_class_name(qname),
- "::StandardError")
+ '::StandardError')
else
c = XSD::CodeGen::ClassDef.new(create_class_name(qname))
end
c.comment = "#{ qname.namespace }"
- c.def_classvar("schema_type", qname.name.dump)
- c.def_classvar("schema_ns", qname.namespace.dump)
- init_lines = ""
+ c.def_classvar('schema_type', qname.name.dump)
+ c.def_classvar('schema_ns', qname.namespace.dump)
+ schema_attribute = []
+ schema_element = []
+ init_lines = ''
params = []
- complextype.each_element do |element|
+ type_or_element.each_element do |element|
+ next unless element.name
name = element.name.name
+ if element.type == XSD::AnyTypeName
+ type = nil
+ elsif basetype = basetype_class(element.type)
+ type = basetype.name
+ else
+ type = create_class_name(element.type)
+ end
+ attrname = safemethodname?(name) ? name : safemethodname(name)
varname = safevarname(name)
- c.def_attr(name, true, varname)
+ c.def_attr(attrname, true, varname)
init_lines << "@#{ varname } = #{ varname }\n"
- params << "#{ varname } = nil"
+ if element.map_as_array?
+ params << "#{ varname } = []"
+ type << '[]'
+ else
+ params << "#{ varname } = nil"
+ end
+ schema_element << [name, type]
end
- complextype.attributes.each do |attribute|
- name = "attr_" + attribute.name
- varname = safevarname(name)
- c.def_attr(name, true, varname)
- init_lines << "@#{ varname } = #{ varname }\n"
- params << "#{ varname } = nil"
+ unless type_or_element.attributes.empty?
+ type_or_element.attributes.each do |attribute|
+ name = attribute.name.name
+ if basetype = basetype_class(attribute.type)
+ type = basetype_class(attribute.type).name
+ else
+ type = nil
+ end
+ varname = safevarname('attr_' + name)
+ c.def_method(varname) do <<-__EOD__
+ @__soap_attribute[#{name.dump}]
+ __EOD__
+ end
+ c.def_method(varname + '=', 'value') do <<-__EOD__
+ @__soap_attribute[#{name.dump}] = value
+ __EOD__
+ end
+ schema_attribute << [name, type]
+ end
+ init_lines << "@__soap_attribute = {}\n"
end
- c.def_method("initialize", *params) do
+ c.def_classvar('schema_attribute',
+ '{' +
+ schema_attribute.collect { |name, type|
+ name.dump + ' => ' + ndq(type)
+ }.join(', ') +
+ '}'
+ )
+ c.def_classvar('schema_element',
+ '{' +
+ schema_element.collect { |name, type|
+ name.dump + ' => ' + ndq(type)
+ }.join(', ') +
+ '}'
+ )
+ c.def_method('initialize', *params) do
init_lines
end
c.dump
end
+ def basetype_class(type)
+ if @simpletypes[type]
+ basetype_mapped_class(@simpletypes[type].base)
+ else
+ basetype_mapped_class(type)
+ end
+ end
+
def dump_arraydef(complextype)
qname = complextype.name
- c = XSD::CodeGen::ClassDef.new(create_class_name(qname), "::Array")
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array')
c.comment = "#{ qname.namespace }"
- c.def_classvar("schema_type", qname.name.dump)
- c.def_classvar("schema_ns", qname.namespace.dump)
+ c.def_classvar('schema_type', qname.name.dump)
+ c.def_classvar('schema_ns', qname.namespace.dump)
c.dump
end
end
diff --git a/lib/wsdl/soap/classDefCreatorSupport.rb b/lib/wsdl/soap/classDefCreatorSupport.rb
index dbcc55f7b9..706c00d4f6 100644
--- a/lib/wsdl/soap/classDefCreatorSupport.rb
+++ b/lib/wsdl/soap/classDefCreatorSupport.rb
@@ -59,6 +59,18 @@ __EOD__
str
end
+ def dq(ele)
+ ele.dump
+ end
+
+ def ndq(ele)
+ ele.nil? ? 'nil' : dq(ele)
+ end
+
+ def sym(ele)
+ ':' + ele
+ end
+
private
def dump_inout_type(param)
@@ -66,10 +78,14 @@ private
message = param.find_message
params = ""
message.parts.each do |part|
- next unless part.type
name = safevarname(part.name)
- typename = safeconstname(part.type.name)
- params << add_at("# #{name}", "#{typename} - #{part.type}\n", 20)
+ if part.type
+ typename = safeconstname(part.type.name)
+ params << add_at("# #{name}", "#{typename} - #{part.type}\n", 20)
+ elsif part.element
+ typename = safeconstname(part.element.name)
+ params << add_at("# #{name}", "#{typename} - #{part.element}\n", 20)
+ end
end
unless params.empty?
return params
diff --git a/lib/wsdl/soap/clientSkeltonCreator.rb b/lib/wsdl/soap/clientSkeltonCreator.rb
index 9c538dd612..0b9e79c718 100644
--- a/lib/wsdl/soap/clientSkeltonCreator.rb
+++ b/lib/wsdl/soap/clientSkeltonCreator.rb
@@ -62,7 +62,7 @@ __EOD__
def dump_input_init(input)
result = input.find_message.parts.collect { |part|
- "#{ uncapitalize(part.name) }"
+ safevarname(part.name)
}.join(" = ")
if result.empty?
""
diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb
index 34fc18f1a4..1bed059f7e 100644
--- a/lib/wsdl/soap/complexType.rb
+++ b/lib/wsdl/soap/complexType.rb
@@ -7,6 +7,7 @@
require 'wsdl/xmlSchema/complexType'
+require 'soap/mapping'
module WSDL
@@ -20,37 +21,58 @@ class ComplexType < Info
def check_type
if content
- if content.elements.size == 1 and content.elements[0].maxoccurs != 1
- :TYPE_ARRAY
+ if attributes.empty? and
+ content.elements.size == 1 and content.elements[0].maxoccurs != '1'
+ if name == ::SOAP::Mapping::MapQName
+ :TYPE_MAP
+ else
+ :TYPE_ARRAY
+ end
else
:TYPE_STRUCT
end
elsif complexcontent and complexcontent.base == ::SOAP::ValueArrayName
:TYPE_ARRAY
+ elsif simplecontent
+ :TYPE_SIMPLE
+ elsif !attributes.empty?
+ :TYPE_STRUCT
else
raise NotImplementedError.new("Unknown kind of complexType.")
end
end
def child_type(name = nil)
+ type = nil
case compoundtype
when :TYPE_STRUCT
if ele = find_element(name)
- ele.type
+ type = ele.type
elsif ele = find_element_by_name(name.name)
- ele.type
- else
- nil
+ type = ele.type
end
when :TYPE_ARRAY
- @contenttype ||= content_arytype
+ type = @contenttype ||= content_arytype
+ when :TYPE_MAP
+ item_ele = find_element_by_name("item") or
+ raise RuntimeError.new("'item' element not found in Map definition.")
+ content = item_ele.local_complextype or
+ raise RuntimeError.new("No complexType definition for 'item'.")
+ if ele = content.find_element(name)
+ type = ele.type
+ elsif ele = content.find_element_by_name(name.name)
+ type = ele.type
+ end
+ else
+ raise NotImplementedError.new("Unknown kind of complexType.")
end
+ type
end
def child_defined_complextype(name)
ele = nil
case compoundtype
- when :TYPE_STRUCT
+ when :TYPE_STRUCT, :TYPE_MAP
unless ele = find_element(name)
if name.namespace.nil?
ele = find_element_by_name(name.name)
@@ -81,7 +103,7 @@ class ComplexType < Info
return attribute.arytype
end
end
- elsif content.elements.size == 1 and content.elements[0].maxoccurs != 1
+ elsif content.elements.size == 1 and content.elements[0].maxoccurs != '1'
return content.elements[0].type
else
raise RuntimeError.new("Assert: Unknown array definition.")
diff --git a/lib/wsdl/soap/data.rb b/lib/wsdl/soap/data.rb
index 23aaff83b5..48512d3751 100644
--- a/lib/wsdl/soap/data.rb
+++ b/lib/wsdl/soap/data.rb
@@ -11,6 +11,7 @@ require 'wsdl/soap/definitions'
require 'wsdl/soap/binding'
require 'wsdl/soap/operation'
require 'wsdl/soap/body'
+require 'wsdl/soap/element'
require 'wsdl/soap/header'
require 'wsdl/soap/headerfault'
require 'wsdl/soap/fault'
diff --git a/lib/wsdl/soap/driverCreator.rb b/lib/wsdl/soap/driverCreator.rb
index 50be8ed1dc..b752ee336d 100644
--- a/lib/wsdl/soap/driverCreator.rb
+++ b/lib/wsdl/soap/driverCreator.rb
@@ -68,10 +68,15 @@ Methods = [
end
c.def_privatemethod("init_methods") do
<<-EOD
- Methods.each do |name_as, name, params, soapaction, namespace|
+ Methods.each do |name_as, name, params, soapaction, namespace, style|
qname = ::XSD::QName.new(namespace, name_as)
- @proxy.add_method(qname, soapaction, name, params)
- add_rpc_method_interface(name, params)
+ if style == :document
+ @proxy.add_document_method(qname, soapaction, name, params)
+ add_document_method_interface(name, name_as)
+ else
+ @proxy.add_rpc_method(qname, soapaction, name, params)
+ add_rpc_method_interface(name, params)
+ end
end
EOD
end
diff --git a/lib/wsdl/soap/fault.rb b/lib/wsdl/soap/fault.rb
index abd3cbe3dd..019c881f97 100644
--- a/lib/wsdl/soap/fault.rb
+++ b/lib/wsdl/soap/fault.rb
@@ -34,13 +34,13 @@ class Fault < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = value
+ @name = XSD::QName.new(targetnamespace, value.source)
when UseAttrName
- @use = value
+ @use = value.source
when EncodingStyleAttrName
- @encodingstyle = value
+ @encodingstyle = value.source
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
else
nil
end
diff --git a/lib/wsdl/soap/header.rb b/lib/wsdl/soap/header.rb
index f1dd69eafb..247531a76d 100644
--- a/lib/wsdl/soap/header.rb
+++ b/lib/wsdl/soap/header.rb
@@ -59,15 +59,15 @@ class Header < Info
def parse_attr(attr, value)
case attr
when MessageAttrName
- @message = value
+ @message = XSD::QName.new(targetnamespace, value.source)
when PartAttrName
- @part = value
+ @part = value.source
when UseAttrName
- @use = value
+ @use = value.source
when EncodingStyleAttrName
- @encodingstyle = value
+ @encodingstyle = value.source
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
else
nil
end
diff --git a/lib/wsdl/soap/headerfault.rb b/lib/wsdl/soap/headerfault.rb
index a6e86661c2..d6b14f2646 100644
--- a/lib/wsdl/soap/headerfault.rb
+++ b/lib/wsdl/soap/headerfault.rb
@@ -38,13 +38,13 @@ class HeaderFault < Info
when MessageAttrName
@message = value
when PartAttrName
- @part = value
+ @part = value.source
when UseAttrName
- @use = value
+ @use = value.source
when EncodingStyleAttrName
- @encodingstyle = value
+ @encodingstyle = value.source
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
else
nil
end
diff --git a/lib/wsdl/soap/methodDefCreator.rb b/lib/wsdl/soap/methodDefCreator.rb
index eded972cdc..59b8ee4253 100644
--- a/lib/wsdl/soap/methodDefCreator.rb
+++ b/lib/wsdl/soap/methodDefCreator.rb
@@ -45,9 +45,15 @@ private
def dump_method(operation, binding)
name = safemethodname(operation.name.name)
name_as = operation.name.name
- params = collect_parameter(operation)
- soapaction = binding.soapoperation.soapaction
- namespace = binding.input.soapbody.namespace
+ stylestr = binding.soapoperation.operation_style.id2name
+ if binding.soapoperation.operation_style == :rpc
+ soapaction = binding.soapoperation.soapaction
+ namespace = binding.input.soapbody.namespace
+ params = collect_rpcparameter(operation)
+ else
+ soapaction = namespace = nil
+ params = collect_documentparameter(operation)
+ end
paramstr = param2str(params)
if paramstr.empty?
paramstr = '[]'
@@ -57,36 +63,45 @@ private
return <<__EOD__
[#{ dq(name_as) }, #{ dq(name) },
#{ paramstr },
- #{ soapaction ? dq(soapaction) : "nil" }, #{ dq(namespace) }
+ #{ ndq(soapaction) }, #{ ndq(namespace) }, #{ sym(stylestr) }
]
__EOD__
end
- def collect_parameter(operation)
+ def collect_rpcparameter(operation)
result = operation.inputparts.collect { |part|
collect_type(part.type)
- param_set('in', definedtype(part), part.name)
+ param_set('in', rpcdefinedtype(part), part.name)
}
outparts = operation.outputparts
if outparts.size > 0
retval = outparts[0]
collect_type(retval.type)
- result << param_set('retval', definedtype(retval), retval.name)
+ result << param_set('retval', rpcdefinedtype(retval), retval.name)
cdr(outparts).each { |part|
collect_type(part.type)
- result << param_set('out', definedtype(part), part.name)
+ result << param_set('out', rpcdefinedtype(part), part.name)
}
end
result
end
- def definedtype(part)
+ def collect_documentparameter(operation)
+ input = operation.inputparts[0]
+ output = operation.outputparts[0]
+ [
+ param_set('input', documentdefinedtype(input), input.name),
+ param_set('output', documentdefinedtype(output), output.name)
+ ]
+ end
+
+ def rpcdefinedtype(part)
if mapped = basetype_mapped_class(part.type)
['::' + mapped.name]
- elsif definedelement = @elements[part.element]
- raise RuntimeError.new("Part: #{part.name} should be typed for RPC service for now.")
elsif definedtype = @simpletypes[part.type]
['::' + basetype_mapped_class(definedtype.base).name]
+ elsif definedtype = @elements[part.element]
+ ['::SOAP::SOAPStruct', part.element.namespace, part.element.name]
elsif definedtype = @complextypes[part.type]
case definedtype.compoundtype
when :TYPE_STRUCT
@@ -104,6 +119,18 @@ __EOD__
end
end
+ def documentdefinedtype(part)
+ if definedtype = @simpletypes[part.type]
+ ['::' + basetype_mapped_class(definedtype.base).name, nil, part.name]
+ elsif definedtype = @elements[part.element]
+ ['::SOAP::SOAPElement', part.element.namespace, part.element.name]
+ elsif definedtype = @complextypes[part.type]
+ ['::SOAP::SOAPElement', part.type.namespace, part.type.name]
+ else
+ raise RuntimeError.new("Part: #{part.name} cannot be resolved.")
+ end
+ end
+
def param_set(io_type, type, name)
[io_type, type, name]
end
@@ -128,14 +155,10 @@ __EOD__
if type.size == 1
"[#{ type[0] }]"
else
- "[#{ type[0] }, #{ dq(type[1]) }, #{ dq(type[2]) }]"
+ "[#{ type[0] }, #{ ndq(type[1]) }, #{ dq(type[2]) }]"
end
end
- def dq(ele)
- "\"" << ele << "\""
- end
-
def cdr(ary)
result = ary.dup
result.shift
diff --git a/lib/wsdl/soap/operation.rb b/lib/wsdl/soap/operation.rb
index bb49f2099c..51bb2e9403 100644
--- a/lib/wsdl/soap/operation.rb
+++ b/lib/wsdl/soap/operation.rb
@@ -50,13 +50,14 @@ class Operation < Info
def parse_attr(attr, value)
case attr
when StyleAttrName
- if ["document", "rpc"].include?(value)
- @style = value.intern
+ if ["document", "rpc"].include?(value.source)
+ @style = value.source.intern
else
- raise AttributeConstraintError.new("Unexpected value #{ value }.")
+ raise Parser::AttributeConstraintError.new(
+ "Unexpected value #{ value }.")
end
when SOAPActionAttrName
- @soapaction = value
+ @soapaction = value.source
else
nil
end
diff --git a/lib/wsdl/soap/servantSkeltonCreator.rb b/lib/wsdl/soap/servantSkeltonCreator.rb
index bf293949b8..12761ab5b4 100644
--- a/lib/wsdl/soap/servantSkeltonCreator.rb
+++ b/lib/wsdl/soap/servantSkeltonCreator.rb
@@ -45,14 +45,16 @@ private
c = ::XSD::CodeGen::ClassDef.new(class_name)
operations = @definitions.porttype(name).operations
operations.each do |operation|
- name = operation.name.name
+ name = safemethodname(operation.name.name)
input = operation.input
- m = ::XSD::CodeGen::MethodDef.new(name,
- input.find_message.parts.collect { |part| safevarname(part.name) }) do
- <<-EOD
- raise NotImplementedError.new
- EOD
- end
+ params = input.find_message.parts.collect { |part|
+ safevarname(part.name)
+ }
+ m = ::XSD::CodeGen::MethodDef.new(name, params) do <<-EOD
+ p [#{params.join(", ")}]
+ raise NotImplementedError.new
+ EOD
+ end
m.comment = dump_method_signature(operation)
c.add_method(m)
end
diff --git a/lib/wsdl/soap/standaloneServerStubCreator.rb b/lib/wsdl/soap/standaloneServerStubCreator.rb
index 34bcfdbba9..779139a5f4 100644
--- a/lib/wsdl/soap/standaloneServerStubCreator.rb
+++ b/lib/wsdl/soap/standaloneServerStubCreator.rb
@@ -57,9 +57,13 @@ Methods = [
<<-EOD
super(*arg)
servant = #{class_name}.new
- #{class_name}::Methods.each do |name_as, name, params, soapaction, ns|
- qname = XSD::QName.new(ns, name_as)
- @soaplet.app_scope_router.add_method(servant, qname, soapaction, name, params)
+ #{class_name}::Methods.each do |name_as, name, param_def, soapaction, namespace, style|
+ qname = XSD::QName.new(namespace, name_as)
+ if style == :document
+ @soaplet.app_scope_router.add_document_method(servant, qname, soapaction, name, param_def)
+ else
+ @soaplet.app_scope_router.add_rpc_method(servant, qname, soapaction, name, param_def)
+ end
end
self.mapping_registry = #{class_name}::MappingRegistry
EOD
@@ -68,7 +72,11 @@ Methods = [
if $0 == __FILE__
# Change listen port.
- #{class_name}App.new('app', nil, '0.0.0.0', 10080).start
+ server = #{class_name}App.new('app', nil, '0.0.0.0', 10080)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
end
EOD
end
diff --git a/lib/wsdl/xmlSchema/all.rb b/lib/wsdl/xmlSchema/all.rb
index 53f7ae82e4..1cb1ac16ea 100644
--- a/lib/wsdl/xmlSchema/all.rb
+++ b/lib/wsdl/xmlSchema/all.rb
@@ -20,8 +20,8 @@ class All < Info
def initialize
super()
- @minoccurs = 1
- @maxoccurs = 1
+ @minoccurs = '1'
+ @maxoccurs = '1'
@elements = []
end
@@ -51,9 +51,9 @@ class All < Info
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
- @maxoccurs = value
+ @maxoccurs = value.source
when MinOccursAttrName
- @minoccurs = value
+ @minoccurs = value.source
else
nil
end
diff --git a/lib/wsdl/xmlSchema/any.rb b/lib/wsdl/xmlSchema/any.rb
index 3fc3706182..72d25e8dde 100644
--- a/lib/wsdl/xmlSchema/any.rb
+++ b/lib/wsdl/xmlSchema/any.rb
@@ -21,8 +21,8 @@ class Any < Info
def initialize
super()
- @maxoccurs = 1
- @minoccurs = 1
+ @maxoccurs = '1'
+ @minoccurs = '1'
@namespace = '##any'
@process_contents = 'strict'
end
@@ -38,13 +38,13 @@ class Any < Info
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
- @maxoccurs = value
+ @maxoccurs = value.source
when MinOccursAttrName
- @minoccurs = value
+ @minoccurs = value.source
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
when ProcessContentsAttrName
- @process_contents = value
+ @process_contents = value.source
else
nil
end
diff --git a/lib/wsdl/xmlSchema/attribute.rb b/lib/wsdl/xmlSchema/attribute.rb
index e5046dd991..6861fc171e 100644
--- a/lib/wsdl/xmlSchema/attribute.rb
+++ b/lib/wsdl/xmlSchema/attribute.rb
@@ -33,10 +33,13 @@ class Attribute < Info
@type = nil
@default = nil
@fixed = nil
-
@arytype = nil
end
+ def targetnamespace
+ parent.targetnamespace
+ end
+
def parse_element(element)
nil
end
@@ -46,23 +49,23 @@ class Attribute < Info
when RefAttrName
@ref = value
when UseAttrName
- @use = value
+ @use = value.source
when FormAttrName
- @form = value
+ @form = value.source
when NameAttrName
- @name = value
+ @name = XSD::QName.new(targetnamespace, value.source)
when TypeAttrName
@type = value
when DefaultAttrName
- @default = value
+ @default = value.source
when FixedAttrName
- @fixed = value
+ @fixed = value.source
when ArrayTypeAttrName
- @arytype = if value.is_a?(XSD::QName)
- value
- else
- XSD::QName.new(XSD::Namespace, value)
- end
+ @arytype = if value.namespace.nil?
+ XSD::QName.new(XSD::Namespace, value.source)
+ else
+ value
+ end
else
nil
end
diff --git a/lib/wsdl/xmlSchema/choice.rb b/lib/wsdl/xmlSchema/choice.rb
index 4cf481ec9e..435fd48e49 100644
--- a/lib/wsdl/xmlSchema/choice.rb
+++ b/lib/wsdl/xmlSchema/choice.rb
@@ -20,8 +20,8 @@ class Choice < Info
def initialize
super()
- @minoccurs = 1
- @maxoccurs = 1
+ @minoccurs = '1'
+ @maxoccurs = '1'
@elements = []
end
@@ -51,9 +51,9 @@ class Choice < Info
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
- @maxoccurs = value
+ @maxoccurs = value.source
when MinOccursAttrName
- @minoccurs = value
+ @minoccurs = value.source
else
nil
end
diff --git a/lib/wsdl/xmlSchema/complexType.rb b/lib/wsdl/xmlSchema/complexType.rb
index 056a806dc5..0d9c622c74 100644
--- a/lib/wsdl/xmlSchema/complexType.rb
+++ b/lib/wsdl/xmlSchema/complexType.rb
@@ -19,7 +19,8 @@ module XMLSchema
class ComplexType < Info
attr_accessor :name
attr_accessor :complexcontent
- attr_accessor :content
+ attr_accessor :simplecontent
+ attr_reader :content
attr_accessor :final
attr_accessor :mixed
attr_reader :attributes
@@ -28,6 +29,7 @@ class ComplexType < Info
super()
@name = name
@complexcontent = nil
+ @simplecontent = nil
@content = nil
@final = nil
@mixed = false
@@ -35,13 +37,13 @@ class ComplexType < Info
end
def targetnamespace
- parent.targetnamespace
+ parent.is_a?(WSDL::XMLSchema::Element) ? nil : parent.targetnamespace
end
AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
def each_element
- if @content
- @content.elements.each do |element|
+ if content
+ content.elements.each do |element|
if element.is_a?(Any)
yield(AnyAsElement)
else
@@ -52,8 +54,8 @@ class ComplexType < Info
end
def find_element(name)
- if @content
- @content.elements.each do |element|
+ if content
+ content.elements.each do |element|
if element.is_a?(Any)
return AnyAsElement if name == AnyAsElement.name
else
@@ -65,8 +67,8 @@ class ComplexType < Info
end
def find_element_by_name(name)
- if @content
- @content.elements.each do |element|
+ if content
+ content.elements.each do |element|
if element.is_a?(Any)
return AnyAsElement if name == AnyAsElement.name.name
else
@@ -95,16 +97,14 @@ class ComplexType < Info
case element
when AllName
@content = All.new
- @content
when SequenceName
@content = Sequence.new
- @content
when ChoiceName
@content = Choice.new
- @content
when ComplexContentName
@complexcontent = ComplexContent.new
- @complexcontent
+ when SimpleContentName
+ @simplecontent = SimpleContent.new
when AttributeName
o = Attribute.new
@attributes << o
@@ -117,11 +117,11 @@ class ComplexType < Info
def parse_attr(attr, value)
case attr
when FinalAttrName
- @final = value
+ @final = value.source
when MixedAttrName
- @mixed = (value == 'true')
+ @mixed = (value.source == 'true')
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
else
nil
end
diff --git a/lib/wsdl/xmlSchema/content.rb b/lib/wsdl/xmlSchema/content.rb
index 3aa875e3e7..2f1dfb4b6c 100644
--- a/lib/wsdl/xmlSchema/content.rb
+++ b/lib/wsdl/xmlSchema/content.rb
@@ -67,9 +67,9 @@ class Content < Info
def parse_attr(attr, value)
case attr
when FinalAttrName
- @final = value
+ @final = value.source
when MixedAttrName
- @mixed = (value == 'true')
+ @mixed = (value.source == 'true')
else
nil
end
diff --git a/lib/wsdl/xmlSchema/data.rb b/lib/wsdl/xmlSchema/data.rb
index 1283ac2a1d..10bc343adb 100644
--- a/lib/wsdl/xmlSchema/data.rb
+++ b/lib/wsdl/xmlSchema/data.rb
@@ -13,6 +13,7 @@ require 'wsdl/xmlSchema/simpleType'
require 'wsdl/xmlSchema/simpleRestriction'
require 'wsdl/xmlSchema/complexType'
require 'wsdl/xmlSchema/complexContent'
+require 'wsdl/xmlSchema/simpleContent'
require 'wsdl/xmlSchema/any'
require 'wsdl/xmlSchema/element'
require 'wsdl/xmlSchema/all'
@@ -39,6 +40,7 @@ ImportName = XSD::QName.new(XSD::Namespace, 'import')
RestrictionName = XSD::QName.new(XSD::Namespace, 'restriction')
SequenceName = XSD::QName.new(XSD::Namespace, 'sequence')
SchemaName = XSD::QName.new(XSD::Namespace, 'schema')
+SimpleContentName = XSD::QName.new(XSD::Namespace, 'simpleContent')
SimpleTypeName = XSD::QName.new(XSD::Namespace, 'simpleType')
UniqueName = XSD::QName.new(XSD::Namespace, 'unique')
@@ -56,6 +58,7 @@ MixedAttrName = XSD::QName.new(nil, 'mixed')
NameAttrName = XSD::QName.new(nil, 'name')
NamespaceAttrName = XSD::QName.new(nil, 'namespace')
NillableAttrName = XSD::QName.new(nil, 'nillable')
+ProcessContentsAttrName = XSD::QName.new(nil, 'processContents')
RefAttrName = XSD::QName.new(nil, 'ref')
SchemaLocationAttrName = XSD::QName.new(nil, 'schemaLocation')
TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
diff --git a/lib/wsdl/xmlSchema/element.rb b/lib/wsdl/xmlSchema/element.rb
index 90e8c0d5d1..cc9d4e9ed8 100644
--- a/lib/wsdl/xmlSchema/element.rb
+++ b/lib/wsdl/xmlSchema/element.rb
@@ -28,8 +28,8 @@ class Element < Info
@type = type
@local_complextype = nil
@constraint = nil
- @maxoccurs = 1
- @minoccurs = 1
+ @maxoccurs = '1'
+ @minoccurs = '1'
@nillable = nil
end
@@ -37,6 +37,11 @@ class Element < Info
parent.targetnamespace
end
+ def elementform
+ # ToDo: must be overwritten.
+ parent.elementformdefault
+ end
+
def parse_element(element)
case element
when ComplexTypeName
@@ -54,45 +59,27 @@ class Element < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- #@name = XSD::QName.new(nil, value)
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
when TypeAttrName
- @type = if value.is_a?(XSD::QName)
- value
- else
- XSD::QName.new(XSD::Namespace, value)
- end
+ @type = value
when MaxOccursAttrName
- case parent
- when All
- if value != '1'
+ if parent.is_a?(All)
+ if value.source != '1'
raise Parser::AttrConstraintError.new(
"Cannot parse #{ value } for #{ attr }.")
end
- @maxoccurs = value
- when Sequence
- @maxoccurs = value
- else
- raise NotImplementedError.new
end
- @maxoccurs
+ @maxoccurs = value.source
when MinOccursAttrName
- case parent
- when All
- if ['0', '1'].include?(value)
- @minoccurs = value
- else
+ if parent.is_a?(All)
+ unless ['0', '1'].include?(value.source)
raise Parser::AttrConstraintError.new(
"Cannot parse #{ value } for #{ attr }.")
end
- when Sequence
- @minoccurs = value
- else
- raise NotImplementedError.new
end
- @minoccurs
+ @minoccurs = value.source
when NillableAttrName
- @nillable = (value == 'true')
+ @nillable = (value.source == 'true')
else
nil
end
diff --git a/lib/wsdl/xmlSchema/enumeration.rb b/lib/wsdl/xmlSchema/enumeration.rb
index cd61572d07..5a16476032 100644
--- a/lib/wsdl/xmlSchema/enumeration.rb
+++ b/lib/wsdl/xmlSchema/enumeration.rb
@@ -25,8 +25,8 @@ class Enumeration < Info
def parse_attr(attr, value)
case attr
when ValueAttrName
- parent.enumeration << value
- value
+ parent.enumeration << value.source
+ value.source
end
end
end
diff --git a/lib/wsdl/xmlSchema/import.rb b/lib/wsdl/xmlSchema/import.rb
index 2ef3b72ab2..e65641330d 100644
--- a/lib/wsdl/xmlSchema/import.rb
+++ b/lib/wsdl/xmlSchema/import.rb
@@ -30,9 +30,9 @@ class Import < Info
def parse_attr(attr, value)
case attr
when NamespaceAttrName
- @namespace = value
+ @namespace = value.source
when SchemaLocationAttrName
- @schemalocation = value
+ @schemalocation = value.source
else
nil
end
diff --git a/lib/wsdl/xmlSchema/parser.rb b/lib/wsdl/xmlSchema/parser.rb
index 5401c5f729..a7f1c29fd4 100644
--- a/lib/wsdl/xmlSchema/parser.rb
+++ b/lib/wsdl/xmlSchema/parser.rb
@@ -22,7 +22,7 @@ class Parser
include XSD
class ParseError < Error; end
- class FormatDecodeError < Error; end
+ class FormatDecodeError < ParseError; end
class UnknownElementError < FormatDecodeError; end
class UnknownAttributeError < FormatDecodeError; end
class UnexpectedElementError < FormatDecodeError; end
@@ -114,34 +114,21 @@ private
else
o = parent.parse_element(element)
unless o
- raise UnknownElementError.new("Unknown element #{ element }.")
+ STDERR.puts("Unknown element #{ element }.")
+ o = Documentation.new # which accepts any element.
end
# node could be a pseudo element. pseudo element has its own parent.
o.parent = parent if o.parent.nil?
end
attrs.each do |key, value|
- attr = unless /:/ =~ key
- XSD::QName.new(nil, key)
- else
- ns.parse(key)
- end
- value_ele = if /:/ !~ value
- value
- elsif /^http:\/\// =~ value # ToDo: ugly.
- value
- else
- begin
- ns.parse(value)
- rescue
- value
- end
- end
- if attr == IdAttrName
+ attr_ele = ns.parse(key, true)
+ value_ele = ns.parse(value, true)
+ value_ele.source = value # for recovery; value may not be a QName
+ if attr_ele == IdAttrName
o.id = value_ele
else
- unless o.parse_attr(attr, value_ele)
- STDERR.puts("Unknown attr #{ attr }.")
- # raise UnknownAttributeError.new("Unknown attr #{ attr }.")
+ unless o.parse_attr(attr_ele, value_ele)
+ STDERR.puts("Unknown attr #{ attr_ele }.")
end
end
end
diff --git a/lib/wsdl/xmlSchema/schema.rb b/lib/wsdl/xmlSchema/schema.rb
index b530a92556..ddd231bd97 100644
--- a/lib/wsdl/xmlSchema/schema.rb
+++ b/lib/wsdl/xmlSchema/schema.rb
@@ -32,7 +32,7 @@ class Schema < Info
@elements = XSD::NamedElements.new
@attributes = XSD::NamedElements.new
@imports = []
- @elementformdefault = nil
+ @elementformdefault = "qualified"
end
def parse_element(element)
@@ -64,11 +64,11 @@ class Schema < Info
def parse_attr(attr, value)
case attr
when TargetNamespaceAttrName
- @targetnamespace = value
+ @targetnamespace = value.source
when AttributeFormDefaultAttrName
- @attributeformdefault = value
+ @attributeformdefault = value.source
when ElementFormDefaultAttrName
- @elementformdefault = value
+ @elementformdefault = value.source
else
nil
end
diff --git a/lib/wsdl/xmlSchema/sequence.rb b/lib/wsdl/xmlSchema/sequence.rb
index 3810832ab2..bffb6a009d 100644
--- a/lib/wsdl/xmlSchema/sequence.rb
+++ b/lib/wsdl/xmlSchema/sequence.rb
@@ -20,8 +20,8 @@ class Sequence < Info
def initialize
super()
- @minoccurs = 1
- @maxoccurs = 1
+ @minoccurs = '1'
+ @maxoccurs = '1'
@elements = []
end
@@ -51,9 +51,9 @@ class Sequence < Info
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
- @maxoccurs = value
+ @maxoccurs = value.source
when MinOccursAttrName
- @minoccurs = value
+ @minoccurs = value.source
else
nil
end
diff --git a/lib/wsdl/xmlSchema/simpleType.rb b/lib/wsdl/xmlSchema/simpleType.rb
index 830086f99e..d9f76f345c 100644
--- a/lib/wsdl/xmlSchema/simpleType.rb
+++ b/lib/wsdl/xmlSchema/simpleType.rb
@@ -63,7 +63,7 @@ class SimpleType < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value)
+ @name = XSD::QName.new(targetnamespace, value.source)
end
end