1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/soap/* (29 files): SOAP4R added.

* lib/wsdl/* (42 files): WSDL4R added.

* lib/xsd/* (12 files): XSD4R added.

* test/soap/* (16 files): added.

* test/wsdl/* (2 files): added.

* test/xsd/* (3 files): added.

* sample/soap/* (27 files): added.

* sample/wsdl/* (13 files): added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nahi 2003-09-24 15:18:44 +00:00
parent 8c2fb77787
commit db9445103c
145 changed files with 20938 additions and 0 deletions

76
lib/wsdl/xmlSchema/all.rb Normal file
View file

@ -0,0 +1,76 @@
=begin
WSDL4R - XMLSchema complexType definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class All < Info
attr_reader :minoccurs
attr_reader :maxoccurs
attr_reader :elements
def initialize
super()
@minoccurs = 1
@maxoccurs = 1
@elements = []
end
def targetnamespace
parent.targetnamespace
end
def <<(element)
@elements << element
end
def parse_element(element)
case element
when AnyName
o = Any.new
@elements << o
o
when ElementName
o = Element.new
@elements << o
o
else
nil
end
end
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
@maxoccurs = value
when MinOccursAttrName
@minoccurs = value
else
nil
end
end
end
end
end

67
lib/wsdl/xmlSchema/any.rb Normal file
View file

@ -0,0 +1,67 @@
=begin
WSDL4R - XMLSchema any definition for WSDL.
Copyright (C) 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Any < Info
attr_accessor :maxoccurs
attr_accessor :minoccurs
attr_accessor :namespace
attr_accessor :process_contents
def initialize
super()
@maxoccurs = 1
@minoccurs = 1
@namespace = '##any'
@process_contents = 'strict'
end
def targetnamespace
parent.targetnamespace
end
def parse_element(element)
nil
end
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
@maxoccurs = value
when MinOccursAttrName
@minoccurs = value
when NamespaceAttrName
@namespace = value
when ProcessContentsAttrName
@process_contents = value
else
nil
end
end
end
end
end

View file

@ -0,0 +1,85 @@
=begin
WSDL4R - XMLSchema attribute definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Attribute < Info
attr_accessor :ref
attr_accessor :use
attr_accessor :form
attr_accessor :name
attr_accessor :type
attr_accessor :default
attr_accessor :fixed
attr_accessor :arytype
def initialize
super
@ref = nil
@use = nil
@form = nil
@name = nil
@type = nil
@default = nil
@fixed = nil
@arytype = nil
end
def parse_element(element)
nil
end
def parse_attr(attr, value)
case attr
when RefAttrName
@ref = value
when UseAttrName
@use = value
when FormAttrName
@form = value
when NameAttrName
@name = value
when TypeAttrName
@type = value
when DefaultAttrName
@default = value
when FixedAttrName
@fixed = value
when ArrayTypeAttrName
@arytype = if value.is_a?(XSD::QName)
value
else
XSD::QName.new(XSD::Namespace, value)
end
else
nil
end
end
end
end
end

View file

@ -0,0 +1,76 @@
=begin
WSDL4R - XMLSchema complexType definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Choice < Info
attr_reader :minoccurs
attr_reader :maxoccurs
attr_reader :elements
def initialize
super()
@minoccurs = 1
@maxoccurs = 1
@elements = []
end
def targetnamespace
parent.targetnamespace
end
def <<(element)
@elements << element
end
def parse_element(element)
case element
when AnyName
o = Any.new
@elements << o
o
when ElementName
o = Element.new
@elements << o
o
else
nil
end
end
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
@maxoccurs = value
when MinOccursAttrName
@minoccurs = value
else
nil
end
end
end
end
end

View file

@ -0,0 +1,90 @@
=begin
WSDL4R - XMLSchema complexContent definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
require 'xsd/namedelements'
module WSDL
module XMLSchema
class ComplexContent < Info
attr_accessor :base
attr_reader :derivetype
attr_reader :content
attr_reader :attributes
def initialize
super
@base = nil
@derivetype = nil
@content = nil
@attributes = XSD::NamedElements.new
end
def parse_element(element)
case element
when RestrictionName, ExtensionName
@derivetype = element.name
self
when AllName
if @derivetype.nil?
raise Parser::ElementConstraintError.new("base attr not found.")
end
@content = All.new
@content
when SequenceName
if @derivetype.nil?
raise Parser::ElementConstraintError.new("base attr not found.")
end
@content = Sequence.new
@content
when ChoiceName
if @derivetype.nil?
raise Parser::ElementConstraintError.new("base attr not found.")
end
@content = Choice.new
@content
when AttributeName
if @derivetype.nil?
raise Parser::ElementConstraintError.new("base attr not found.")
end
o = Attribute.new
@attributes << o
o
end
end
def parse_attr(attr, value)
if @derivetype.nil?
return nil
end
case attr
when BaseAttrName
@base = value
else
nil
end
end
end
end
end

View file

@ -0,0 +1,130 @@
=begin
WSDL4R - XMLSchema complexType definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
require 'wsdl/xmlSchema/content'
require 'xsd/namedelements'
module WSDL
module XMLSchema
class ComplexType < Info
attr_accessor :name
attr_accessor :complexcontent
attr_accessor :content
attr_accessor :final
attr_accessor :mixed
attr_reader :attributes
def initialize(name = nil)
super()
@name = name
@complexcontent = nil
@content = nil
@final = nil
@mixed = false
@attributes = XSD::NamedElements.new
end
def targetnamespace
parent.targetnamespace
end
def each_element
if @content
@content.elements.each do |element|
yield(element.name, element)
end
end
end
def find_element(name)
if @content
@content.elements.each do |element|
return element if name == element.name
end
end
nil
end
def find_element_by_name(name)
if @content
@content.elements.each do |element|
return element if name == element.name.name
end
end
nil
end
def sequence_elements=(elements)
@content = Sequence.new
elements.each do |element|
@content << element
end
end
def all_elements=(elements)
@content = All.new
elements.each do |element|
@content << element
end
end
def parse_element(element)
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 AttributeName
o = Attribute.new
@attributes << o
o
else
nil
end
end
def parse_attr(attr, value)
case attr
when FinalAttrName
@final = value
when MixedAttrName
@mixed = (value == 'true')
when NameAttrName
@name = XSD::QName.new(targetnamespace, value)
else
nil
end
end
end
end
end

View file

@ -0,0 +1,107 @@
=begin
WSDL4R - XMLSchema complexType definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Content < Info
attr_accessor :final
attr_accessor :mixed
attr_accessor :type
attr_reader :contents
attr_reader :elements
def initialize
super()
@final = nil
@mixed = false
@type = nil
@contents = []
@elements = []
end
def targetnamespace
parent.targetnamespace
end
def <<(content)
@contents << content
update_elements
end
def each
@contents.each do |content|
yield content
end
end
def parse_element(element)
case element
when AllName, SequenceName, ChoiceName
o = Content.new
o.type = element.name
@contents << o
o
when AnyName
o = Any.new
@contents << o
o
when ElementName
o = Element.new
@contents << o
o
else
nil
end
end
def parse_attr(attr, value)
case attr
when FinalAttrName
@final = value
when MixedAttrName
@mixed = (value == 'true')
else
nil
end
end
def parse_epilogue
update_elements
end
private
def update_elements
@elements = []
@contents.each do |content|
if content.is_a?(Element)
@elements << [content.name, content]
end
end
end
end
end
end

View file

@ -0,0 +1,75 @@
=begin
WSDL4R - XMLSchema data definitions.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/xmlSchema/schema'
require 'wsdl/xmlSchema/import'
require 'wsdl/xmlSchema/complexType'
require 'wsdl/xmlSchema/complexContent'
require 'wsdl/xmlSchema/any'
require 'wsdl/xmlSchema/element'
require 'wsdl/xmlSchema/all'
require 'wsdl/xmlSchema/choice'
require 'wsdl/xmlSchema/sequence'
require 'wsdl/xmlSchema/attribute'
require 'wsdl/xmlSchema/unique'
module WSDL
module XMLSchema
AllName = XSD::QName.new(XSD::Namespace, 'all')
AnyName = XSD::QName.new(XSD::Namespace, 'any')
ArrayTypeAttrName = XSD::QName.new(Namespace, 'arrayType')
AttributeName = XSD::QName.new(XSD::Namespace, 'attribute')
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')
ExtensionName = XSD::QName.new(XSD::Namespace, 'extension')
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')
SimpleTypeName = XSD::QName.new(XSD::Namespace, 'simpleType')
UniqueName = XSD::QName.new(XSD::Namespace, 'unique')
AttributeFormDefaultAttrName = XSD::QName.new(nil, 'attributeFormDefault')
BaseAttrName = XSD::QName.new(nil, 'base')
DefaultAttrName = XSD::QName.new(nil, 'default')
ElementFormDefaultAttrName = XSD::QName.new(nil, 'elementFormDefault')
FinalAttrName = XSD::QName.new(nil, 'final')
FixedAttrName = XSD::QName.new(nil, 'fixed')
FormAttrName = XSD::QName.new(nil, 'form')
IdAttrName = XSD::QName.new(nil, 'id')
MaxOccursAttrName = XSD::QName.new(nil, 'maxOccurs')
MinOccursAttrName = XSD::QName.new(nil, 'minOccurs')
MixedAttrName = XSD::QName.new(nil, 'mixed')
NameAttrName = XSD::QName.new(nil, 'name')
NamespaceAttrName = XSD::QName.new(nil, 'namespace')
NillableAttrName = XSD::QName.new(nil, 'nillable')
RefAttrName = XSD::QName.new(nil, 'ref')
SchemaLocationAttrName = XSD::QName.new(nil, 'schemaLocation')
TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
TypeAttrName = XSD::QName.new(nil, 'type')
UseAttrName = XSD::QName.new(nil, 'use')
end
end

View file

@ -0,0 +1,115 @@
=begin
WSDL4R - XMLSchema element definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Element < Info
attr_accessor :name # required
attr_accessor :type
attr_accessor :local_complextype
attr_accessor :constraint
attr_accessor :maxoccurs
attr_accessor :minoccurs
attr_accessor :nillable
def initialize(name = nil, type = XSD::AnyTypeName)
super()
@name = name
@type = type
@local_complextype = nil
@constraint = nil
@maxoccurs = 1
@minoccurs = 1
@nillable = nil
end
def targetnamespace
parent.targetnamespace
end
def parse_element(element)
case element
when ComplexTypeName
@type = nil
@local_complextype = ComplexType.new
@local_complextype
when UniqueName
@constraint = Unique.new
@constraint
else
nil
end
end
def parse_attr(attr, value)
case attr
when NameAttrName
#@name = XSD::QName.new(nil, value)
@name = XSD::QName.new(targetnamespace, value)
when TypeAttrName
@type = if value.is_a?(XSD::QName)
value
else
XSD::QName.new(XSD::Namespace, value)
end
when MaxOccursAttrName
case parent
when All
if value != '1'
raise Parser::AttrConstraintError.new(
"Cannot parse #{ value } for #{ attr }.")
end
@maxoccurs = value
when Sequence
@maxoccurs = value
else
raise NotImplementedError.new
end
@maxoccurs
when MinOccursAttrName
case parent
when All
if ['0', '1'].include?(value)
@minoccurs = value
else
raise Parser::AttrConstraintError.new(
"Cannot parse #{ value } for #{ attr }.")
end
when Sequence
@minoccurs = value
else
raise NotImplementedError.new
end
@minoccurs
when NillableAttrName
@nillable = (value == 'true')
else
nil
end
end
end
end
end

View file

@ -0,0 +1,55 @@
=begin
WSDL4R - XMLSchema import definition.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Import < Info
attr_reader :namespace
attr_reader :schemalocation
def initialize
super
@namespace = nil
@schemalocation = nil
end
def parse_element(element)
nil
end
def parse_attr(attr, value)
case attr
when NamespaceAttrName
@namespace = value
when SchemaLocationAttrName
@schemalocation = value
else
nil
end
end
end
end
end

View file

@ -0,0 +1,172 @@
=begin
WSDL4R - WSDL XML Instance parser library.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'xsd/qname'
require 'xsd/ns'
require 'xsd/charset'
require 'xsd/datatypes'
require 'xsd/xmlparser'
require 'wsdl/xmlSchema/data'
module WSDL
module XMLSchema
class Parser
include XSD
class ParseError < Error; end
class FormatDecodeError < Error; end
class UnknownElementError < FormatDecodeError; end
class UnknownAttributeError < FormatDecodeError; end
class UnexpectedElementError < FormatDecodeError; end
class ElementConstraintError < FormatDecodeError; end
class AttributeConstraintError < FormatDecodeError; end
private
class ParseFrame
attr_reader :ns
attr_reader :name
attr_accessor :node
private
def initialize(ns, name, node)
@ns = ns
@name = name
@node = node
end
end
public
def initialize(opt = {})
@parser = XSD::XMLParser.create_parser(self, opt)
@parsestack = nil
@lastnode = nil
end
def parse(string_or_readable)
@parsestack = []
@lastnode = nil
@textbuf = ''
@parser.do_parse(string_or_readable)
@lastnode
end
def charset
@parser.charset
end
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
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
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
private
def decode_tag(ns, name, attrs, parent)
o = nil
element = ns.parse(name)
if !parent
if element == SchemaName
o = Schema.parse_element(element)
else
raise UnknownElementError.new("Unknown element #{ element }.")
end
else
o = parent.parse_element(element)
unless o
raise UnknownElementError.new("Unknown element #{ element }.")
end
o.parent = parent
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
o.id = value_ele
else
unless o.parse_attr(attr, value_ele)
STDERR.puts("Unknown attr #{ attr }.")
# raise UnknownAttributeError.new("Unknown attr #{ attr }.")
end
end
end
o
end
def decode_tag_end(ns, node)
node.parse_epilogue
end
def decode_text(ns, text)
@textbuf << text
end
end
end
end

View file

@ -0,0 +1,105 @@
=begin
WSDL4R - XMLSchema schema definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
require 'xsd/namedelements'
module WSDL
module XMLSchema
class Schema < Info
attr_reader :targetnamespace # required
attr_reader :complextypes
attr_reader :elements
attr_reader :attributes
attr_reader :imports
attr_accessor :attributeformdefault
attr_accessor :elementformdefault
def initialize
super
@targetnamespace = nil
@complextypes = XSD::NamedElements.new
@elements = XSD::NamedElements.new
@attributes = XSD::NamedElements.new
@imports = []
@elementformdefault = nil
end
def parse_element(element)
case element
when ImportName
o = Import.new
@imports << o
o
when ComplexTypeName
o = ComplexType.new
@complextypes << o
o
when ElementName
o = Element.new
@elements << o
o
when AttributeName
o = Attribute.new
o
else
nil
end
end
def parse_attr(attr, value)
case attr
when TargetNamespaceAttrName
@targetnamespace = value
when AttributeFormDefaultAttrName
@attributeformdefault = value
when ElementFormDefaultAttrName
@elementformdefault = value
else
nil
end
end
def collect_elements
result = XSD::NamedElements.new
result.concat(@elements)
result
end
def collect_complextypes
result = XSD::NamedElements.new
result.concat(@complextypes)
result
end
def self.parse_element(element)
if element == SchemaName
Schema.new
else
nil
end
end
end
end
end

View file

@ -0,0 +1,76 @@
=begin
WSDL4R - XMLSchema complexType definition for WSDL.
Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Sequence < Info
attr_reader :minoccurs
attr_reader :maxoccurs
attr_reader :elements
def initialize
super()
@minoccurs = 1
@maxoccurs = 1
@elements = []
end
def targetnamespace
parent.targetnamespace
end
def <<(element)
@elements << element
end
def parse_element(element)
case element
when AnyName
o = Any.new
@elements << o
o
when ElementName
o = Element.new
@elements << o
o
else
nil
end
end
def parse_attr(attr, value)
case attr
when MaxOccursAttrName
@maxoccurs = value
when MinOccursAttrName
@minoccurs = value
else
nil
end
end
end
end
end

View file

@ -0,0 +1,45 @@
=begin
WSDL4R - XMLSchema unique element.
Copyright (C) 2003 NAKAMURA, Hiroshi.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PRATICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
=end
require 'wsdl/info'
module WSDL
module XMLSchema
class Unique < Info
def initialize
super
end
def parse_element(element)
# Accepts any element.
self
end
def parse_attr(attr, value)
# Accepts any attribute.
true
end
end
end
end