diff options
Diffstat (limited to 'lib/wsdl/xmlSchema')
-rw-r--r-- | lib/wsdl/xmlSchema/all.rb | 8 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/any.rb | 12 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/attribute.rb | 25 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/choice.rb | 8 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/complexType.rb | 30 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/content.rb | 4 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/data.rb | 3 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/element.rb | 45 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/enumeration.rb | 4 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/import.rb | 4 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/parser.rb | 31 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/schema.rb | 8 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/sequence.rb | 8 | ||||
-rw-r--r-- | lib/wsdl/xmlSchema/simpleType.rb | 2 |
14 files changed, 86 insertions, 106 deletions
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 |