summaryrefslogtreecommitdiff
path: root/lib/wsdl
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-15 14:47:07 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-15 14:47:07 +0000
commit533c24268e485c1de7d7fbe6d947681df5a48382 (patch)
tree4cc1c58ec29d3d4af8ce0e7f31802447be125221 /lib/wsdl
parentcaf6ad3a760f4fb0a27bb8e483f3f6ad9de707f0 (diff)
* lib/{soap,wsdl,xsd}, test/{soap,wsdl,xsd}: imported soap4r/1.5.5.
#nnn is a ticket number at http://dev.ctor.org/soap4r * SOAP * allow to configure an envelope namespace of SOAP request. (#124) TemporaryNamespace = 'http://www.w3.org/2003/05/soap-envelope' @client.options["soap.envelope.requestnamespace"] = TemporaryNamespace @client.options["soap.envelope.responsenamespace"] = TemporaryNamespace @client.do_proc(...) * let SOAP request XML indent space configuable. see "soap.envelope.no_indent" option. (#130) * let external CES configuable. ex. client["soap.mapping.external_ces"] = 'SJIS'. $KCODE is used by default. (#133) external CES ::= CES used in Ruby object of client and server internal CES ::= CES used in SOAP/OM * add iso-8859-1 external CES support. (#106) * fixed illegal 'qualified' handling of elements. it caused ASP.NET inteoperability problem. (#144) * added 'soap.envelope.use_numeric_character_reference' (boolean) option to let query XML use numeric character reference in XML, not plain UTF-8 character. !GoogleSearch server seems to not allow plain UTF-8 character since 2005-08-15 update. (#147) * SOAP::Header::SimpleHeader (de)serialization throws an exception on !SimpleHeader.on_(in|out)bound when header is a String. so we could not use a simple single element headerItem. fixed. thanks to emil. (#129) * out parameter of rpc operation did not work. (#132) * follow HTTP redirect only if using http-access2. (#125) (#145) * add a workaround for importing an WSDL whose path begins with drive letter. (#115) * WSDL * SOAP Data which is defined as a simpletype was not mapped correctly to Ruby obj when using wsdl2ruby.rb generated classdef file. (#123) * rpc/literal support. (#118) * re-implemented local element qualify/unqualify control. handles elementFormDefault and form in WSDL. (#119) * Array of an element which has simpleType causes a crash. (#128) * prarmeterOrder may not contain return part so it can be shorter than parts size. Thanks to Hugh. (#139) * Samples * added !BasicAuth client sample. (#117) * added Base64 client/server sample. * added Flickr SOAP interface client sample. (#122) * added !SalesForce client sample. (#135) * updated Thawte CA certificate for !GoogleAdWords sample. * updated a client script with the newer version made by Johan. thanks! * shortened long file names. (#120) * fixed typo in authheader sample. (#129) * updated deprecated method usage. (#138) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/wsdl')
-rw-r--r--lib/wsdl/operation.rb5
-rw-r--r--lib/wsdl/param.rb8
-rw-r--r--lib/wsdl/soap/body.rb6
-rw-r--r--lib/wsdl/soap/cgiStubCreator.rb10
-rw-r--r--lib/wsdl/soap/classDefCreator.rb54
-rw-r--r--lib/wsdl/soap/clientSkeltonCreator.rb4
-rw-r--r--lib/wsdl/soap/complexType.rb31
-rw-r--r--lib/wsdl/soap/driverCreator.rb22
-rw-r--r--lib/wsdl/soap/methodDefCreator.rb77
-rw-r--r--lib/wsdl/soap/standaloneServerStubCreator.rb10
-rw-r--r--lib/wsdl/xmlSchema/all.rb4
-rw-r--r--lib/wsdl/xmlSchema/attribute.rb15
-rw-r--r--lib/wsdl/xmlSchema/choice.rb4
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb8
-rw-r--r--lib/wsdl/xmlSchema/element.rb36
-rw-r--r--lib/wsdl/xmlSchema/schema.rb5
-rw-r--r--lib/wsdl/xmlSchema/sequence.rb4
17 files changed, 236 insertions, 67 deletions
diff --git a/lib/wsdl/operation.rb b/lib/wsdl/operation.rb
index 727bb9a56c..fb7f4a80f4 100644
--- a/lib/wsdl/operation.rb
+++ b/lib/wsdl/operation.rb
@@ -120,9 +120,8 @@ private
if result.length == 0
return parts.dup
end
- if parts.length != result.length
- raise RuntimeError.new("Incomplete prarmeterOrder list.")
- end
+ # result length can be shorter than parts's.
+ # return part must not be a part of the parameterOrder.
result
end
end
diff --git a/lib/wsdl/param.rb b/lib/wsdl/param.rb
index 08ba07ee9b..b6836b7def 100644
--- a/lib/wsdl/param.rb
+++ b/lib/wsdl/param.rb
@@ -36,6 +36,14 @@ class Param < Info
root.message(@message) or raise RuntimeError.new("#{@message} not found")
end
+ def soapbody_use
+ if @soapbody
+ @soapbody.use || :literal
+ else
+ raise RuntimeError.new("soap:body not found")
+ end
+ end
+
def parse_element(element)
case element
when SOAPBodyName
diff --git a/lib/wsdl/soap/body.rb b/lib/wsdl/soap/body.rb
index 47e99f381b..824f8121a2 100644
--- a/lib/wsdl/soap/body.rb
+++ b/lib/wsdl/soap/body.rb
@@ -36,7 +36,11 @@ class Body < Info
when PartsAttrName
@parts = value.source
when UseAttrName
- @use = value.source
+ if ['literal', 'encoded'].include?(value.source)
+ @use = value.source.intern
+ else
+ raise RuntimeError.new("unknown use of soap:body: #{value.source}")
+ end
when EncodingStyleAttrName
@encodingstyle = value.source
when NamespaceAttrName
diff --git a/lib/wsdl/soap/cgiStubCreator.rb b/lib/wsdl/soap/cgiStubCreator.rb
index 0a76dc43a1..2c4dff2f62 100644
--- a/lib/wsdl/soap/cgiStubCreator.rb
+++ b/lib/wsdl/soap/cgiStubCreator.rb
@@ -53,12 +53,12 @@ Methods = [
<<-EOD
super(*arg)
servant = #{class_name}.new
- #{class_name}::Methods.each do |name_as, name, param_def, soapaction, namespace, style|
- if style == :document
- @router.add_document_operation(servant, soapaction, name, param_def)
+ #{class_name}::Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
else
- qname = XSD::QName.new(namespace, name_as)
- @router.add_rpc_operation(servant, qname, soapaction, name, param_def)
+ @router.add_rpc_operation(servant, *definitions)
end
end
self.mapping_registry = #{class_name}::MappingRegistry
diff --git a/lib/wsdl/soap/classDefCreator.rb b/lib/wsdl/soap/classDefCreator.rb
index deda4f131f..aeb67c0613 100644
--- a/lib/wsdl/soap/classDefCreator.rb
+++ b/lib/wsdl/soap/classDefCreator.rb
@@ -57,7 +57,8 @@ private
def dump_element
@elements.collect { |ele|
if ele.local_complextype
- dump_classdef(ele.name, ele.local_complextype)
+ dump_classdef(ele.name, ele.local_complextype,
+ ele.elementform == 'qualified')
elsif ele.local_simpletype
dump_simpletypedef(ele.name, ele.local_simpletype)
else
@@ -117,7 +118,7 @@ private
c.dump
end
- def dump_classdef(qname, typedef)
+ def dump_classdef(qname, typedef, qualified = false)
if @faulttypes and @faulttypes.index(qname)
c = XSD::CodeGen::ClassDef.new(create_class_name(qname),
'::StandardError')
@@ -127,6 +128,7 @@ private
c.comment = "#{qname}"
c.def_classvar('schema_type', ndq(qname.name))
c.def_classvar('schema_ns', ndq(qname.namespace))
+ c.def_classvar('schema_qualified', dq('true')) if qualified
schema_element = []
init_lines = ''
params = []
@@ -158,7 +160,10 @@ private
else
params << "#{varname} = nil"
end
- eleqname = (varname == name) ? nil : element.name
+ # nil means @@schema_ns + varname
+ eleqname =
+ (varname == name && element.name.namespace == qname.namespace) ?
+ nil : element.name
schema_element << [varname, eleqname, type]
end
unless typedef.attributes.empty?
@@ -256,13 +261,50 @@ private
raise RuntimeError.new("cannot define name of #{attribute}")
end
+ DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item')
+
def dump_arraydef(complextype)
qname = complextype.name
c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array')
c.comment = "#{qname}"
- type = complextype.child_type
- c.def_classvar('schema_type', ndq(type.name))
- c.def_classvar('schema_ns', ndq(type.namespace))
+ child_type = complextype.child_type
+ c.def_classvar('schema_type', ndq(child_type.name))
+ c.def_classvar('schema_ns', ndq(child_type.namespace))
+ child_element = complextype.find_aryelement
+ schema_element = []
+ if child_type == XSD::AnyTypeName
+ type = nil
+ elsif child_element and (klass = element_basetype(child_element))
+ type = klass.name
+ elsif child_type
+ type = create_class_name(child_type)
+ else
+ type = nil
+ end
+ if child_element
+ if child_element.map_as_array?
+ type << '[]' if type
+ end
+ child_element_name = child_element.name
+ else
+ child_element_name = DEFAULT_ITEM_NAME
+ end
+ schema_element << [child_element_name.name, child_element_name, type]
+ c.def_classvar('schema_element',
+ '[' +
+ schema_element.collect { |varname, name, type|
+ '[' +
+ (
+ if name
+ varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
+ else
+ varname.dump + ', ' + ndq(type)
+ end
+ ) +
+ ']'
+ }.join(', ') +
+ ']'
+ )
c.dump
end
end
diff --git a/lib/wsdl/soap/clientSkeltonCreator.rb b/lib/wsdl/soap/clientSkeltonCreator.rb
index 0b9e79c718..916f0d4dc0 100644
--- a/lib/wsdl/soap/clientSkeltonCreator.rb
+++ b/lib/wsdl/soap/clientSkeltonCreator.rb
@@ -42,8 +42,8 @@ private
endpoint_url = ARGV.shift
obj = #{ drv_name }.new(endpoint_url)
-# Uncomment the below line to see SOAP wiredumps.
-# obj.wiredump_dev = STDERR
+# run ruby with -d to see SOAP wiredumps.
+obj.wiredump_dev = STDERR if $DEBUG
__EOD__
@definitions.porttype(name).operations.each do |operation|
diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb
index bba50fd153..b2e13d0564 100644
--- a/lib/wsdl/soap/complexType.rb
+++ b/lib/wsdl/soap/complexType.rb
@@ -106,18 +106,43 @@ class ComplexType < Info
end
end
if check_array_content(complexcontent.content)
- return complexcontent.content.elements[0].type
+ return element_simpletype(complexcontent.content.elements[0])
end
elsif check_array_content(content)
- return content.elements[0].type
+ return element_simpletype(content.elements[0])
end
raise RuntimeError.new("Assert: Unknown array definition.")
end
+ def find_aryelement
+ unless compoundtype == :TYPE_ARRAY
+ raise RuntimeError.new("Assert: not for array")
+ end
+ if complexcontent
+ if check_array_content(complexcontent.content)
+ return complexcontent.content.elements[0]
+ end
+ elsif check_array_content(content)
+ return content.elements[0]
+ end
+ nil # use default item name
+ end
+
private
+ def element_simpletype(element)
+ if element.type
+ element.type
+ elsif element.local_simpletype
+ element.local_simpletype.base
+ else
+ nil
+ end
+ end
+
def check_array_content(content)
- content.elements.size == 1 and content.elements[0].maxoccurs != '1'
+ content and content.elements.size == 1 and
+ content.elements[0].maxoccurs != '1'
end
def content_arytype
diff --git a/lib/wsdl/soap/driverCreator.rb b/lib/wsdl/soap/driverCreator.rb
index dd504210f1..eba7c158a2 100644
--- a/lib/wsdl/soap/driverCreator.rb
+++ b/lib/wsdl/soap/driverCreator.rb
@@ -69,18 +69,18 @@ Methods = [
end
c.def_privatemethod("init_methods") do
<<-EOD
- Methods.each do |name_as, name, params, soapaction, namespace, style|
- qname = XSD::QName.new(namespace, name_as)
- if style == :document
- @proxy.add_document_method(soapaction, name, params)
- add_document_method_interface(name, params)
+ Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ add_document_operation(*definitions)
else
- @proxy.add_rpc_method(qname, soapaction, name, params)
- add_rpc_method_interface(name, params)
- end
- if name_as != name and name_as.capitalize == name.capitalize
- ::SOAP::Mapping.define_singleton_method(self, name_as) do |*arg|
- __send__(name, *arg)
+ add_rpc_operation(*definitions)
+ qname = definitions[0]
+ name = definitions[2]
+ if qname.name != name and qname.name.capitalize == name.capitalize
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
+ __send__(name, *arg)
+ end
end
end
end
diff --git a/lib/wsdl/soap/methodDefCreator.rb b/lib/wsdl/soap/methodDefCreator.rb
index f256b42451..f3ffadbe69 100644
--- a/lib/wsdl/soap/methodDefCreator.rb
+++ b/lib/wsdl/soap/methodDefCreator.rb
@@ -46,18 +46,18 @@ class MethodDefCreator
def collect_rpcparameter(operation)
result = operation.inputparts.collect { |part|
collect_type(part.type)
- param_set(::SOAP::RPC::SOAPMethod::IN, rpcdefinedtype(part), part.name)
+ param_set(::SOAP::RPC::SOAPMethod::IN, part.name, rpcdefinedtype(part))
}
outparts = operation.outputparts
if outparts.size > 0
retval = outparts[0]
collect_type(retval.type)
- result << param_set(::SOAP::RPC::SOAPMethod::RETVAL,
- rpcdefinedtype(retval), retval.name)
+ result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, retval.name,
+ rpcdefinedtype(retval))
cdr(outparts).each { |part|
collect_type(part.type)
- result << param_set(::SOAP::RPC::SOAPMethod::OUT, rpcdefinedtype(part),
- part.name)
+ result << param_set(::SOAP::RPC::SOAPMethod::OUT, part.name,
+ rpcdefinedtype(part))
}
end
result
@@ -66,12 +66,12 @@ class MethodDefCreator
def collect_documentparameter(operation)
param = []
operation.inputparts.each do |input|
- param << param_set(::SOAP::RPC::SOAPMethod::IN,
- documentdefinedtype(input), input.name)
+ param << param_set(::SOAP::RPC::SOAPMethod::IN, input.name,
+ documentdefinedtype(input), elementqualified(input))
end
operation.outputparts.each do |output|
- param << param_set(::SOAP::RPC::SOAPMethod::OUT,
- documentdefinedtype(output), output.name)
+ param << param_set(::SOAP::RPC::SOAPMethod::OUT, output.name,
+ documentdefinedtype(output), elementqualified(output))
end
param
end
@@ -82,23 +82,38 @@ private
name = safemethodname(operation.name.name)
name_as = operation.name.name
style = binding.soapoperation_style
+ inputuse = binding.input.soapbody_use
+ outputuse = binding.output.soapbody_use
namespace = binding.input.soapbody.namespace
if style == :rpc
+ qname = XSD::QName.new(namespace, name_as)
paramstr = param2str(collect_rpcparameter(operation))
else
+ qname = nil
paramstr = param2str(collect_documentparameter(operation))
end
if paramstr.empty?
paramstr = '[]'
else
- paramstr = "[\n" << paramstr.gsub(/^/, ' ') << "\n ]"
+ paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
end
- return <<__EOD__
-[#{dq(name_as)}, #{dq(name)},
+ definitions = <<__EOD__
+#{ndq(binding.soapaction)},
+ #{dq(name)},
#{paramstr},
- #{ndq(binding.soapaction)}, #{ndq(namespace)}, #{sym(style.id2name)}
-]
+ { :request_style => #{sym(style.id2name)}, :request_use => #{sym(inputuse.id2name)},
+ :response_style => #{sym(style.id2name)}, :response_use => #{sym(outputuse.id2name)} }
__EOD__
+ if style == :rpc
+ return <<__EOD__
+[ #{qname.dump},
+ #{definitions}]
+__EOD__
+ else
+ return <<__EOD__
+[ #{definitions}]
+__EOD__
+ end
end
def rpcdefinedtype(part)
@@ -144,8 +159,22 @@ __EOD__
end
end
- def param_set(io_type, type, name)
- [io_type, type, name]
+ def elementqualified(part)
+ if mapped = basetype_mapped_class(part.type)
+ false
+ elsif definedtype = @simpletypes[part.type]
+ false
+ elsif definedtype = @elements[part.element]
+ definedtype.elementform == 'qualified'
+ elsif definedtype = @complextypes[part.type]
+ false
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def param_set(io_type, name, type, ele = nil)
+ [io_type, name, type, ele]
end
def collect_type(type)
@@ -161,7 +190,12 @@ __EOD__
def param2str(params)
params.collect { |param|
- "[#{dq(param[0])}, #{dq(param[2])}, #{type2str(param[1])}]"
+ io, name, type, ele = param
+ unless ele.nil?
+ "[#{dq(io)}, #{dq(name)}, #{type2str(type)}, #{ele2str(ele)}]"
+ else
+ "[#{dq(io)}, #{dq(name)}, #{type2str(type)}]"
+ end
}.join(",\n")
end
@@ -173,6 +207,15 @@ __EOD__
end
end
+ def ele2str(ele)
+ qualified = ele
+ if qualified
+ "true"
+ else
+ "false"
+ end
+ end
+
def cdr(ary)
result = ary.dup
result.shift
diff --git a/lib/wsdl/soap/standaloneServerStubCreator.rb b/lib/wsdl/soap/standaloneServerStubCreator.rb
index 243ac12216..0b751b5153 100644
--- a/lib/wsdl/soap/standaloneServerStubCreator.rb
+++ b/lib/wsdl/soap/standaloneServerStubCreator.rb
@@ -55,12 +55,12 @@ Methods = [
<<-EOD
super(*arg)
servant = #{class_name}.new
- #{class_name}::Methods.each do |name_as, name, param_def, soapaction, namespace, style|
- if style == :document
- @router.add_document_operation(servant, soapaction, name, param_def)
+ #{class_name}::Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
else
- qname = XSD::QName.new(namespace, name_as)
- @router.add_rpc_operation(servant, qname, soapaction, name, param_def)
+ @router.add_rpc_operation(servant, *definitions)
end
end
self.mapping_registry = #{class_name}::MappingRegistry
diff --git a/lib/wsdl/xmlSchema/all.rb b/lib/wsdl/xmlSchema/all.rb
index 1cb1ac16ea..bb9566feac 100644
--- a/lib/wsdl/xmlSchema/all.rb
+++ b/lib/wsdl/xmlSchema/all.rb
@@ -29,6 +29,10 @@ class All < Info
parent.targetnamespace
end
+ def elementformdefault
+ parent.elementformdefault
+ end
+
def <<(element)
@elements << element
end
diff --git a/lib/wsdl/xmlSchema/attribute.rb b/lib/wsdl/xmlSchema/attribute.rb
index c82bd13bde..f9048661a2 100644
--- a/lib/wsdl/xmlSchema/attribute.rb
+++ b/lib/wsdl/xmlSchema/attribute.rb
@@ -18,9 +18,8 @@ class Attribute < Info
if RUBY_VERSION > "1.7.0"
def attr_reader_ref(symbol)
name = symbol.to_s
- iv = "@#{name}"
define_method(name) {
- instance_variable_get(iv) ||
+ instance_variable_get("@#{name}") ||
(refelement ? refelement.__send__(name) : nil)
}
end
@@ -94,7 +93,11 @@ class Attribute < Info
when FormAttrName
@form = value.source
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value.source)
+ if directelement?
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ @name = XSD::QName.new(nil, value.source)
+ end
when TypeAttrName
@type = value
when DefaultAttrName
@@ -111,6 +114,12 @@ class Attribute < Info
nil
end
end
+
+private
+
+ def directelement?
+ parent.is_a?(Schema)
+ end
end
diff --git a/lib/wsdl/xmlSchema/choice.rb b/lib/wsdl/xmlSchema/choice.rb
index 435fd48e49..f6d27fa38c 100644
--- a/lib/wsdl/xmlSchema/choice.rb
+++ b/lib/wsdl/xmlSchema/choice.rb
@@ -29,6 +29,10 @@ class Choice < Info
parent.targetnamespace
end
+ def elementformdefault
+ parent.elementformdefault
+ end
+
def <<(element)
@elements << element
end
diff --git a/lib/wsdl/xmlSchema/complexType.rb b/lib/wsdl/xmlSchema/complexType.rb
index 0d9c622c74..dc9ec954fc 100644
--- a/lib/wsdl/xmlSchema/complexType.rb
+++ b/lib/wsdl/xmlSchema/complexType.rb
@@ -37,7 +37,13 @@ class ComplexType < Info
end
def targetnamespace
- parent.is_a?(WSDL::XMLSchema::Element) ? nil : parent.targetnamespace
+ # inner elements can be qualified
+ # parent.is_a?(WSDL::XMLSchema::Element) ? nil : parent.targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
end
AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
diff --git a/lib/wsdl/xmlSchema/element.rb b/lib/wsdl/xmlSchema/element.rb
index 4a144cd522..fffb6485d0 100644
--- a/lib/wsdl/xmlSchema/element.rb
+++ b/lib/wsdl/xmlSchema/element.rb
@@ -18,9 +18,8 @@ class Element < Info
if RUBY_VERSION > "1.7.0"
def attr_reader_ref(symbol)
name = symbol.to_s
- iv = "@#{name}"
define_method(name) {
- instance_variable_get(iv) ||
+ instance_variable_get("@#{name}") ||
(refelement ? refelement.__send__(name) : nil)
}
end
@@ -37,6 +36,7 @@ class Element < Info
end
attr_writer :name # required
+ attr_writer :form
attr_writer :type
attr_writer :local_simpletype
attr_writer :local_complextype
@@ -46,6 +46,7 @@ class Element < Info
attr_writer :nillable
attr_reader_ref :name
+ attr_reader_ref :form
attr_reader_ref :type
attr_reader_ref :local_simpletype
attr_reader_ref :local_complextype
@@ -59,6 +60,7 @@ class Element < Info
def initialize(name = nil, type = nil)
super()
@name = name
+ @form = nil
@type = type
@local_simpletype = @local_complextype = nil
@constraint = nil
@@ -70,18 +72,21 @@ class Element < Info
end
def refelement
- @refelement ||= root.collect_elements[@ref]
+ @refelement ||= (@ref ? root.collect_elements[@ref] : nil)
end
def targetnamespace
parent.targetnamespace
end
- def elementform
- # ToDo: must be overwritten.
+ def elementformdefault
parent.elementformdefault
end
+ def elementform
+ self.form.nil? ? parent.elementformdefault : self.form
+ end
+
def parse_element(element)
case element
when SimpleTypeName
@@ -102,7 +107,14 @@ class Element < Info
def parse_attr(attr, value)
case attr
when NameAttrName
- @name = XSD::QName.new(targetnamespace, value.source)
+ # namespace may be nil
+ if directelement? or elementform == 'qualified'
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ @name = XSD::QName.new(nil, value.source)
+ end
+ when FormAttrName
+ @form = value.source
when TypeAttrName
@type = value
when RefAttrName
@@ -110,14 +122,16 @@ class Element < Info
when MaxOccursAttrName
if parent.is_a?(All)
if value.source != '1'
- raise Parser::AttrConstraintError.new("cannot parse #{value} for #{attr}")
+ raise Parser::AttrConstraintError.new(
+ "cannot parse #{value} for #{attr}")
end
end
@maxoccurs = value.source
when MinOccursAttrName
if parent.is_a?(All)
unless ['0', '1'].include?(value.source)
- raise Parser::AttrConstraintError.new("cannot parse #{value} for #{attr}")
+ raise Parser::AttrConstraintError.new(
+ "cannot parse #{value} for #{attr}")
end
end
@minoccurs = value.source
@@ -127,6 +141,12 @@ class Element < Info
nil
end
end
+
+private
+
+ def directelement?
+ parent.is_a?(Schema)
+ end
end
diff --git a/lib/wsdl/xmlSchema/schema.rb b/lib/wsdl/xmlSchema/schema.rb
index 43447f9fbf..ec97d07aa5 100644
--- a/lib/wsdl/xmlSchema/schema.rb
+++ b/lib/wsdl/xmlSchema/schema.rb
@@ -1,5 +1,5 @@
# WSDL4R - XMLSchema schema definition for WSDL.
-# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+# Copyright (C) 2002, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
@@ -34,7 +34,8 @@ class Schema < Info
@elements = XSD::NamedElements.new
@attributes = XSD::NamedElements.new
@imports = []
- @elementformdefault = "qualified"
+ @attributeformdefault = "unqualified"
+ @elementformdefault = "unqualified"
@importedschema = {}
@location = nil
@root = self
diff --git a/lib/wsdl/xmlSchema/sequence.rb b/lib/wsdl/xmlSchema/sequence.rb
index bffb6a009d..823fa3b7f9 100644
--- a/lib/wsdl/xmlSchema/sequence.rb
+++ b/lib/wsdl/xmlSchema/sequence.rb
@@ -29,6 +29,10 @@ class Sequence < Info
parent.targetnamespace
end
+ def elementformdefault
+ parent.elementformdefault
+ end
+
def <<(element)
@elements << element
end