summaryrefslogtreecommitdiff
path: root/lib/wsdl/xmlSchema
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-03 13:33:20 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-03 13:33:20 +0000
commitdf731e37a1953755edfedd1462995fa824ca22bf (patch)
tree38a98e1b29b3784843ad079fa003790c8f352f58 /lib/wsdl/xmlSchema
parent0d6fa996d9e842fe435308cef68df06bc3596a76 (diff)
* added files:
* lib/soap/header/* * lib/soap/rpc/httpserver.rb * lib/wsdl/soap/cgiStubCreator.rb * lib/wsdl/soap/classDefCreator.rb * lib/wsdl/soap/classDefCreatorSupport.rb * lib/wsdl/soap/clientSkeltonCreator.rb * lib/wsdl/soap/driverCreator.rb * lib/wsdl/soap/mappingRegistryCreator.rb * lib/wsdl/soap/methodDefCreator.rb * lib/wsdl/soap/servantSkeltonCreator.rb * lib/wsdl/soap/standaloneServerStubCreator.rb * lib/wsdl/xmlSchema/enumeration.rb * lib/wsdl/xmlSchema/simpleRestriction.rb * lib/wsdl/xmlSchema/simpleType.rb * lib/xsd/codegen/* * lib/xsd/codegen.rb * sample/soap/authheader/* * sample/soap/raa2.4/* * sample/soap/ssl/* * sample/soap/swa/* * sample/soap/whois.rb * sample/wsdl/raa2.4/* * test/soap/header/* * test/soap/ssl/* * test/soap/struct/* * test/soap/swa/* * test/soap/wsdlDriver/* * test/wsdl/multiplefault.wsdl * test/wsdl/simpletype/* * test/wsdl/test_multiplefault.rb * modified files: * lib/soap/baseData.rb * lib/soap/element.rb * lib/soap/generator.rb * lib/soap/netHttpClient.rb * lib/soap/parser.rb * lib/soap/property.rb * lib/soap/soap.rb * lib/soap/streamHandler.rb * lib/soap/wsdlDriver.rb * lib/soap/wsdlDriver.rb * lib/soap/encodingstyle/handler.rb * lib/soap/encodingstyle/literalHandler.rb * lib/soap/encodingstyle/soapHandler.rb * lib/soap/mapping/factory.rb * lib/soap/mapping/mapping.rb * lib/soap/mapping/registry.rb * lib/soap/mapping/rubytypeFactory.rb * lib/soap/mapping/wsdlRegistry.rb * lib/soap/rpc/cgistub.rb * lib/soap/rpc/driver.rb * lib/soap/rpc/proxy.rb * lib/soap/rpc/router.rb * lib/soap/rpc/soaplet.rb * lib/soap/rpc/standaloneServer.rb * lib/wsdl/data.rb * lib/wsdl/definitions.rb * lib/wsdl/operation.rb * lib/wsdl/parser.rb * lib/wsdl/soap/definitions.rb * lib/wsdl/xmlSchema/complexContent.rb * lib/wsdl/xmlSchema/complexType.rb * lib/wsdl/xmlSchema/data.rb * lib/wsdl/xmlSchema/parser.rb * lib/wsdl/xmlSchema/schema.rb * lib/xsd/datatypes.rb * lib/xsd/qname.rb * sample/soap/sampleStruct/server.rb * sample/wsdl/amazon/AmazonSearch.rb * sample/wsdl/amazon/AmazonSearchDriver.rb * test/soap/test_property.rb * test/soap/calc/test_calc_cgi.rb * test/wsdl/test_emptycomplextype.rb * summary * add SOAP Header mustUnderstand support. * add HTTP client SSL configuration and Cookies support (works completely with http-access2). * add header handler for handling sending/receiving SOAP Header. * map Ruby's anonymous Struct to common SOAP Struct in SOAP Object Model. it caused error. * add WSDL simpleType support to restrict lexical value space. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/wsdl/xmlSchema')
-rw-r--r--lib/wsdl/xmlSchema/complexContent.rb4
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb22
-rw-r--r--lib/wsdl/xmlSchema/data.rb7
-rw-r--r--lib/wsdl/xmlSchema/enumeration.rb36
-rw-r--r--lib/wsdl/xmlSchema/parser.rb3
-rw-r--r--lib/wsdl/xmlSchema/schema.rb13
-rw-r--r--lib/wsdl/xmlSchema/simpleRestriction.rb48
-rw-r--r--lib/wsdl/xmlSchema/simpleType.rb81
8 files changed, 206 insertions, 8 deletions
diff --git a/lib/wsdl/xmlSchema/complexContent.rb b/lib/wsdl/xmlSchema/complexContent.rb
index 22f6851864..66ad9e251d 100644
--- a/lib/wsdl/xmlSchema/complexContent.rb
+++ b/lib/wsdl/xmlSchema/complexContent.rb
@@ -28,6 +28,10 @@ class ComplexContent < Info
@attributes = XSD::NamedElements.new
end
+ def targetnamespace
+ parent.targetnamespace
+ end
+
def parse_element(element)
case element
when RestrictionName, ExtensionName
diff --git a/lib/wsdl/xmlSchema/complexType.rb b/lib/wsdl/xmlSchema/complexType.rb
index e889482d09..056a806dc5 100644
--- a/lib/wsdl/xmlSchema/complexType.rb
+++ b/lib/wsdl/xmlSchema/complexType.rb
@@ -8,6 +8,7 @@
require 'wsdl/info'
require 'wsdl/xmlSchema/content'
+require 'wsdl/xmlSchema/element'
require 'xsd/namedelements'
@@ -36,11 +37,16 @@ class ComplexType < Info
def targetnamespace
parent.targetnamespace
end
-
+
+ AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
def each_element
if @content
@content.elements.each do |element|
- yield(element.name, element)
+ if element.is_a?(Any)
+ yield(AnyAsElement)
+ else
+ yield(element)
+ end
end
end
end
@@ -48,7 +54,11 @@ class ComplexType < Info
def find_element(name)
if @content
@content.elements.each do |element|
- return element if name == element.name
+ if element.is_a?(Any)
+ return AnyAsElement if name == AnyAsElement.name
+ else
+ return element if name == element.name
+ end
end
end
nil
@@ -57,7 +67,11 @@ class ComplexType < Info
def find_element_by_name(name)
if @content
@content.elements.each do |element|
- return element if name == element.name.name
+ if element.is_a?(Any)
+ return AnyAsElement if name == AnyAsElement.name.name
+ else
+ return element if name == element.name.name
+ end
end
end
nil
diff --git a/lib/wsdl/xmlSchema/data.rb b/lib/wsdl/xmlSchema/data.rb
index 2fa8ad6a91..1283ac2a1d 100644
--- a/lib/wsdl/xmlSchema/data.rb
+++ b/lib/wsdl/xmlSchema/data.rb
@@ -6,8 +6,11 @@
# either the dual license version in 2003, or any later version.
+require 'xsd/datatypes'
require 'wsdl/xmlSchema/schema'
require 'wsdl/xmlSchema/import'
+require 'wsdl/xmlSchema/simpleType'
+require 'wsdl/xmlSchema/simpleRestriction'
require 'wsdl/xmlSchema/complexType'
require 'wsdl/xmlSchema/complexContent'
require 'wsdl/xmlSchema/any'
@@ -17,7 +20,7 @@ require 'wsdl/xmlSchema/choice'
require 'wsdl/xmlSchema/sequence'
require 'wsdl/xmlSchema/attribute'
require 'wsdl/xmlSchema/unique'
-
+require 'wsdl/xmlSchema/enumeration'
module WSDL
module XMLSchema
@@ -30,6 +33,7 @@ ChoiceName = XSD::QName.new(XSD::Namespace, 'choice')
ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent')
ComplexTypeName = XSD::QName.new(XSD::Namespace, 'complexType')
ElementName = XSD::QName.new(XSD::Namespace, 'element')
+EnumerationName = XSD::QName.new(XSD::Namespace, 'enumeration')
ExtensionName = XSD::QName.new(XSD::Namespace, 'extension')
ImportName = XSD::QName.new(XSD::Namespace, 'import')
RestrictionName = XSD::QName.new(XSD::Namespace, 'restriction')
@@ -57,6 +61,7 @@ SchemaLocationAttrName = XSD::QName.new(nil, 'schemaLocation')
TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
TypeAttrName = XSD::QName.new(nil, 'type')
UseAttrName = XSD::QName.new(nil, 'use')
+ValueAttrName = XSD::QName.new(nil, 'value')
end
diff --git a/lib/wsdl/xmlSchema/enumeration.rb b/lib/wsdl/xmlSchema/enumeration.rb
new file mode 100644
index 0000000000..cd61572d07
--- /dev/null
+++ b/lib/wsdl/xmlSchema/enumeration.rb
@@ -0,0 +1,36 @@
+# WSDL4R - XMLSchema enumeration definition for WSDL.
+# Copyright (C) 2004 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;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Enumeration < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when ValueAttrName
+ parent.enumeration << value
+ value
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/parser.rb b/lib/wsdl/xmlSchema/parser.rb
index 688af27c8c..5401c5f729 100644
--- a/lib/wsdl/xmlSchema/parser.rb
+++ b/lib/wsdl/xmlSchema/parser.rb
@@ -116,7 +116,8 @@ private
unless o
raise UnknownElementError.new("Unknown element #{ element }.")
end
- o.parent = parent
+ # 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
diff --git a/lib/wsdl/xmlSchema/schema.rb b/lib/wsdl/xmlSchema/schema.rb
index b2a195d41f..b530a92556 100644
--- a/lib/wsdl/xmlSchema/schema.rb
+++ b/lib/wsdl/xmlSchema/schema.rb
@@ -17,6 +17,7 @@ module XMLSchema
class Schema < Info
attr_reader :targetnamespace # required
attr_reader :complextypes
+ attr_reader :simpletypes
attr_reader :elements
attr_reader :attributes
attr_reader :imports
@@ -27,6 +28,7 @@ class Schema < Info
super
@targetnamespace = nil
@complextypes = XSD::NamedElements.new
+ @simpletypes = XSD::NamedElements.new
@elements = XSD::NamedElements.new
@attributes = XSD::NamedElements.new
@imports = []
@@ -44,8 +46,9 @@ class Schema < Info
@complextypes << o
o
when SimpleTypeName
- STDERR.puts("Restriction of basetype with simpleType definition is ignored for now.")
- nil
+ o = SimpleType.new
+ @simpletypes << o
+ o
when ElementName
o = Element.new
@elements << o
@@ -83,6 +86,12 @@ class Schema < Info
result
end
+ def collect_simpletypes
+ result = XSD::NamedElements.new
+ result.concat(@simpletypes)
+ result
+ end
+
def self.parse_element(element)
if element == SchemaName
Schema.new
diff --git a/lib/wsdl/xmlSchema/simpleRestriction.rb b/lib/wsdl/xmlSchema/simpleRestriction.rb
new file mode 100644
index 0000000000..6986e74423
--- /dev/null
+++ b/lib/wsdl/xmlSchema/simpleRestriction.rb
@@ -0,0 +1,48 @@
+# WSDL4R - XMLSchema simpleType definition for WSDL.
+# Copyright (C) 2004 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;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class SimpleRestriction < Info
+ attr_reader :base
+ attr_reader :enumeration
+
+ def initialize
+ super
+ @base = nil
+ @enumeration = [] # NamedElements?
+ end
+
+ def valid?(value)
+ @enumeration.include?(value)
+ end
+
+ def parse_element(element)
+ case element
+ when EnumerationName
+ Enumeration.new # just a parsing handler
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when BaseAttrName
+ @base = value
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/simpleType.rb b/lib/wsdl/xmlSchema/simpleType.rb
new file mode 100644
index 0000000000..830086f99e
--- /dev/null
+++ b/lib/wsdl/xmlSchema/simpleType.rb
@@ -0,0 +1,81 @@
+# WSDL4R - XMLSchema simpleType definition for WSDL.
+# Copyright (C) 2004 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;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class SimpleType < Info
+ attr_accessor :name
+ attr_reader :derivetype
+ attr_reader :restriction
+
+ def check_lexical_format(value)
+ if @restriction
+ check_restriction(value)
+ elsif @extension
+ raise NotImplementedError
+ # ToDo
+ else
+ raise ArgumentError.new("incomplete simpleType")
+ end
+ end
+
+ def base
+ if @restriction
+ @restriction.base
+ elsif @extension
+ @extension.base
+ else
+ raise ArgumentError.new("incomplete simpleType")
+ end
+ end
+
+ def initialize(name = nil)
+ super()
+ @name = name
+ @derivetype = nil
+ @restriction = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName
+ @restriction = SimpleRestriction.new
+ @derivetype = element.name
+ @restriction
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value)
+ end
+ end
+
+private
+
+ def check_restriction(value)
+ unless @restriction.valid?(value)
+ raise ::XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'.")
+ end
+ end
+end
+
+
+end
+end