Changeset 1917
- Timestamp:
- 08/13/07 00:20:00 (1 year ago)
- Files:
-
- trunk/lib/wsdl/definitions.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/attributeGroup.rb (added)
- trunk/lib/wsdl/xmlSchema/complexExtension.rb (modified) (3 diffs)
- trunk/lib/wsdl/xmlSchema/complexRestriction.rb (modified) (3 diffs)
- trunk/lib/wsdl/xmlSchema/complexType.rb (modified) (4 diffs)
- trunk/lib/wsdl/xmlSchema/data.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/group.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/schema.rb (modified) (4 diffs)
- trunk/lib/wsdl/xmlSchema/simpleExtension.rb (modified) (3 diffs)
- trunk/lib/wsdl/xmlSchema/simpleRestriction.rb (modified) (3 diffs)
- trunk/lib/xsd/namedelements.rb (modified) (1 diff)
- trunk/test/wsdl/group/expectedClassdef.rb (modified) (3 diffs)
- trunk/test/wsdl/group/expectedMappingRegistry.rb (modified) (3 diffs)
- trunk/test/wsdl/group/group.wsdl (modified) (1 diff)
- trunk/test/wsdl/group/test_rpc.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/wsdl/definitions.rb
r1906 r1917 52 52 53 53 def collect_attributes 54 result = XSD::NamedElements.new 55 if @types 56 @types.schemas.each do |schema| 57 result.concat(schema.collect_attributes) 58 end 59 end 60 @imports.each do |import| 61 result.concat(import.content.collect_attributes) 62 end 63 result 54 collect_imports(:collect_attributes) 64 55 end 65 56 66 57 def collect_modelgroups 67 result = XSD::NamedElements.new 68 if @types 69 @types.schemas.each do |schema| 70 result.concat(schema.collect_modelgroups) 71 end 72 end 73 @imports.each do |import| 74 result.concat(import.content.collect_modelgroups) 75 end 76 result 58 collect_imports(:collect_modelgroups) 59 end 60 61 def collect_attributegroups 62 collect_imports(:collect_attributegroups) 77 63 end 78 64 79 65 def collect_elements 80 result = XSD::NamedElements.new 81 if @types 82 @types.schemas.each do |schema| 83 result.concat(schema.collect_elements) 84 end 85 end 86 @imports.each do |import| 87 result.concat(import.content.collect_elements) 88 end 89 result 66 collect_imports(:collect_elements) 90 67 end 91 68 92 69 def collect_complextypes 93 result = @anontypes.dup 94 if @types 95 @types.schemas.each do |schema| 96 result.concat(schema.collect_complextypes) 97 end 98 end 99 @imports.each do |import| 100 result.concat(import.content.collect_complextypes) 101 end 102 result 70 result = collect_imports(:collect_complextypes) 71 @anontypes.dup.concat(result) 103 72 end 104 73 105 74 def collect_simpletypes 106 result = XSD::NamedElements.new 107 if @types 108 @types.schemas.each do |schema| 109 result.concat(schema.collect_simpletypes) 110 end 111 end 112 @imports.each do |import| 113 result.concat(import.content.collect_simpletypes) 114 end 115 result 75 collect_imports(:collect_simpletypes) 116 76 end 117 77 … … 258 218 private 259 219 220 def collect_imports(method) 221 result = XSD::NamedElements.new 222 if @types 223 @types.schemas.each do |schema| 224 result.concat(schema.send(method)) 225 end 226 end 227 @imports.each do |import| 228 result.concat(import.content.send(method)) 229 end 230 result 231 end 232 260 233 end 261 234 trunk/lib/wsdl/xmlSchema/complexExtension.rb
r1905 r1917 18 18 attr_accessor :base 19 19 attr_reader :content 20 attr_accessor :anyattribute21 20 22 21 def initialize … … 26 25 @content = nil 27 26 @attributes = XSD::NamedElements.new 28 @anyattribute = nil29 27 end 30 28 … … 88 86 @attributes << o 89 87 o 88 when AttributeGroupName 89 o = AttributeGroup.new 90 @attributes << o 91 o 90 92 when AnyAttributeName 91 @anyattribute = AnyAttribute.new 93 o = AnyAttribute.new 94 @attributes << o 95 o 92 96 end 93 97 end trunk/lib/wsdl/xmlSchema/complexRestriction.rb
r1905 r1917 19 19 attr_reader :content 20 20 attr_reader :attributes 21 attr_accessor :anyattribute22 21 23 22 def initialize … … 27 26 @content = nil 28 27 @attributes = XSD::NamedElements.new 29 @anyattribute = nil30 28 end 31 29 … … 77 75 @attributes << o 78 76 o 77 when AttributeGroupName 78 o = AttributeGroup.new 79 @attributes << o 80 o 79 81 when AnyAttributeName 80 @anyattribute = AnyAttribute.new 82 o = AnyAttribute.new 83 @attributes << o 84 o 81 85 end 82 86 end trunk/lib/wsdl/xmlSchema/complexType.rb
r1906 r1917 24 24 attr_accessor :mixed 25 25 attr_accessor :abstract 26 attr_accessor :anyattribute27 26 28 27 def initialize(name = nil) … … 36 35 @abstract = false 37 36 @attributes = XSD::NamedElements.new 38 @anyattribute = nil39 37 end 40 38 … … 74 72 75 73 def attributes 74 attrs = nil 76 75 if @complexcontent 77 @complexcontent.attributes + @attributes76 attrs = @complexcontent.attributes + @attributes 78 77 elsif @simplecontent 79 @simplecontent.attributes + @attributes78 attrs = @simplecontent.attributes + @attributes 80 79 else 81 @attributes80 attrs = @attributes 82 81 end 82 found = XSD::NamedElements.new 83 attrs.each do |attr| 84 case attr 85 when Attribute 86 found << attr 87 when AttributeGroup 88 if attr.attributes 89 found.concat(attr.attributes) 90 end 91 when AnyAttribute 92 # ignored 93 else 94 warn("unknown attribute: #{attr}") 95 end 96 end 97 found 83 98 end 84 99 … … 139 154 @attributes << o 140 155 o 156 when AttributeGroupName 157 o = AttributeGroup.new 158 @attributes << o 159 o 141 160 when AnyAttributeName 142 @anyattribute = AnyAttribute.new 161 o = AnyAttribute.new 162 @attributes << o 163 o 143 164 else 144 165 nil trunk/lib/wsdl/xmlSchema/data.rb
r1906 r1917 31 31 require 'wsdl/xmlSchema/unique' 32 32 require 'wsdl/xmlSchema/group' 33 require 'wsdl/xmlSchema/attributeGroup' 33 34 34 35 require 'wsdl/xmlSchema/length' … … 54 55 AnyAttributeName = XSD::QName.new(XSD::Namespace, 'anyAttribute') 55 56 AttributeName = XSD::QName.new(XSD::Namespace, 'attribute') 57 AttributeGroupName = XSD::QName.new(XSD::Namespace, 'attributeGroup') 56 58 ChoiceName = XSD::QName.new(XSD::Namespace, 'choice') 57 59 ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent') trunk/lib/wsdl/xmlSchema/group.rb
r1906 r1917 84 84 case attr 85 85 when NameAttrName 86 # namespace may be nil 87 if directelement? or elementform == 'qualified' 88 @name = XSD::QName.new(targetnamespace, value.source) 89 else 90 @name = XSD::QName.new(nil, value.source) 91 end 86 @name = XSD::QName.new(targetnamespace, value.source) 92 87 when RefAttrName 93 88 @ref = value … … 117 112 end 118 113 end 119 120 private121 122 def directelement?123 parent.is_a?(Schema)124 end125 114 end 126 115 trunk/lib/wsdl/xmlSchema/schema.rb
r1906 r1917 22 22 attr_reader :attributes 23 23 attr_reader :modelgroups 24 attr_reader :attributegroups 24 25 attr_reader :imports 25 26 attr_accessor :attributeformdefault … … 37 38 @attributes = XSD::NamedElements.new 38 39 @modelgroups = XSD::NamedElements.new 40 @attributegroups = XSD::NamedElements.new 39 41 @imports = [] 40 42 @attributeformdefault = "unqualified" … … 85 87 @modelgroups << o 86 88 o 89 when AttributeGroupName 90 o = AttributeGroup.new 91 @attributegroups << o 92 o 87 93 else 88 94 nil … … 119 125 @imports.each do |import| 120 126 result.concat(import.content.collect_modelgroups) if import.content 127 end 128 result 129 end 130 131 def collect_attributegroups 132 result = XSD::NamedElements.new 133 result.concat(@attributegroups) 134 @imports.each do |import| 135 result.concat(import.content.collect_attributegroups) if import.content 121 136 end 122 137 result trunk/lib/wsdl/xmlSchema/simpleExtension.rb
r1905 r1917 18 18 attr_reader :base 19 19 attr_reader :attributes 20 attr_accessor :anyattribute21 20 22 21 def initialize … … 24 23 @base = nil 25 24 @attributes = XSD::NamedElements.new 26 @anyattribute = nil27 25 end 28 26 … … 41 39 @attributes << o 42 40 o 41 when AttributeGroupName 42 o = AttributeGroup.new 43 @attributes << o 44 o 43 45 when AnyAttributeName 44 @anyattribute = AnyAttribute.new 46 o = AnyAttribute.new 47 @attributes << o 48 o 45 49 end 46 50 end trunk/lib/wsdl/xmlSchema/simpleRestriction.rb
r1911 r1917 30 30 attr_accessor :fractiondigits 31 31 attr_reader :fixed 32 attr_ accessor :anyattribute32 attr_reader :attributes 33 33 34 34 def initialize … … 41 41 @pattern = nil 42 42 @fixed = {} 43 @a nyattribute = nil43 @attributes = XSD::NamedElements.new 44 44 end 45 45 … … 83 83 when FractionDigitsName 84 84 FractionDigits.new 85 when AttributeName 86 o = Attribute.new 87 @attributes << o 88 o 89 when AttributeGroupName 90 o = AttributeGroup.new 91 @attributes << o 92 o 85 93 when AnyAttributeName 86 @anyattribute = AnyAttribute.new 94 o = AnyAttribute.new 95 @attributes << o 96 o 87 97 end 88 98 end trunk/lib/xsd/namedelements.rb
r1824 r1917 95 95 end 96 96 97 def find_all 98 o = NamedElements.new 99 each do |ele| 100 o << ele if yield(ele) 101 end 102 o 103 end 104 97 105 Empty = NamedElements.new.freeze 98 106 trunk/test/wsdl/group/expectedClassdef.rb
r1906 r1917 9 9 # eletype - SOAP::SOAPString 10 10 # var - SOAP::SOAPString 11 # xmlattr_attr_min - SOAP::SOAPDecimal 12 # xmlattr_attr_max - SOAP::SOAPDecimal 11 13 class Groupele_type 14 AttrAttr_max = XSD::QName.new(nil, "attr_max") 15 AttrAttr_min = XSD::QName.new(nil, "attr_min") 16 12 17 attr_accessor :comment 13 18 attr_reader :__xmlele_any … … 20 25 end 21 26 27 def __xmlattr 28 @__xmlattr ||= {} 29 end 30 31 def xmlattr_attr_min 32 __xmlattr[AttrAttr_min] 33 end 34 35 def xmlattr_attr_min=(value) 36 __xmlattr[AttrAttr_min] = value 37 end 38 39 def xmlattr_attr_max 40 __xmlattr[AttrAttr_max] 41 end 42 43 def xmlattr_attr_max=(value) 44 __xmlattr[AttrAttr_max] = value 45 end 46 22 47 def initialize(comment = nil, element = nil, eletype = nil, var = nil) 23 48 @comment = comment … … 26 51 @eletype = eletype 27 52 @var = var 53 @__xmlattr = {} 28 54 end 29 55 end trunk/test/wsdl/group/expectedMappingRegistry.rb
r1906 r1917 22 22 ], 23 23 ["var", ["SOAP::SOAPString", XSD::QName.new(nil, "var")]] 24 ] 24 ], 25 :schema_attribute => { 26 XSD::QName.new(nil, "attr_min") => "SOAP::SOAPDecimal", 27 XSD::QName.new(nil, "attr_max") => "SOAP::SOAPDecimal" 28 } 25 29 ) 26 30 … … 38 42 ], 39 43 ["var", ["SOAP::SOAPString", XSD::QName.new(nil, "var")]] 40 ] 44 ], 45 :schema_attribute => { 46 XSD::QName.new(nil, "attr_min") => "SOAP::SOAPDecimal", 47 XSD::QName.new(nil, "attr_max") => "SOAP::SOAPDecimal" 48 } 41 49 ) 42 50 … … 54 62 ], 55 63 ["var", ["SOAP::SOAPString", XSD::QName.new(nil, "var")]] 56 ] 64 ], 65 :schema_attribute => { 66 XSD::QName.new(nil, "attr_min") => "SOAP::SOAPDecimal", 67 XSD::QName.new(nil, "attr_max") => "SOAP::SOAPDecimal" 68 } 57 69 ) 58 70 end trunk/test/wsdl/group/group.wsdl
r1906 r1917 8 8 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 9 9 xmlns="http://schemas.xmlsoap.org/wsdl/"> 10 <types>11 <xsd:schema elementFormDefault="unqualified" targetNamespace="urn:grouptype">10 <types> 11 <xsd:schema elementFormDefault="unqualified" targetNamespace="urn:grouptype"> 12 12 13 <xsd:element name="comment" type="xsd:string"/>13 <xsd:element name="comment" type="xsd:string"/> 14 14 15 <xsd:group name="common">16 <xsd:sequence>17 <xsd:element ref="txd:comment" minOccurs="0"/>18 <xsd:any namespace="##any" minOccurs="0"/>19 </xsd:sequence>20 </xsd:group>15 <xsd:simpleType name="attr_type"> 16 <xsd:restriction base="xsd:decimal"> 17 <xsd:maxInclusive value="-50"/> 18 <xsd:minInclusive value="50"/> 19 </xsd:restriction> 20 </xsd:simpleType> 21 21 22 <xsd:group name="common_element"> 23 <xsd:sequence> 24 <xsd:group ref="txd:common"/> 25 <xsd:choice> 26 <xsd:element name="element" type="xsd:string"/> 27 <xsd:element name="eletype" type="xsd:string"/> 28 </xsd:choice> 29 </xsd:sequence> 30 </xsd:group> 22 <xsd:group name="common"> 23 <xsd:sequence> 24 <xsd:element ref="txd:comment" minOccurs="0"/> 25 <xsd:any namespace="##any" minOccurs="0"/> 26 </xsd:sequence> 27 </xsd:group> 31 28 32 <xsd:complexType name="groupele_type"> 33 <xsd:sequence> 34 <xsd:group ref="txd:common_element"/> 35 <xsd:element name="var" type="xsd:string"/> 36 </xsd:sequence> 37 </xsd:complexType> 29 <xsd:attributeGroup name="common_attr"> 30 <xsd:attribute name="attr_min" type="txd:attr_type" default="0"/> 31 <xsd:attribute name="attr_max" type="txd:attr_type" default="0"/> 32 </xsd:attributeGroup> 38 33 39 <xsd:element name="groupele" type="txd:groupele_type"/> 40 </xsd:schema> 41 </types> 34 <xsd:group name="common_element"> 35 <xsd:sequence> 36 <xsd:group ref="txd:common"/> 37 <xsd:choice> 38 <xsd:element name="element" type="xsd:string"/> 39 <xsd:element name="eletype" type="xsd:string"/> 40 </xsd:choice> 41 </xsd:sequence> 42 </xsd:group> 43 44 <xsd:complexType name="groupele_type"> 45 <xsd:sequence> 46 <xsd:group ref="txd:common_element"/> 47 <xsd:element name="var" type="xsd:string"/> 48 </xsd:sequence> 49 <xsd:attributeGroup ref="txd:common_attr"/> 50 </xsd:complexType> 51 52 <xsd:element name="groupele" type="txd:groupele_type"/> 53 </xsd:schema> 54 </types> 42 55 43 56 <message name="echo_in"> trunk/test/wsdl/group/test_rpc.rb
r1906 r1917 29 29 # need to convert for 'any' 30 30 ret = Groupele_type.new(arg.comment, arg.element, arg.eletype, arg.var) 31 ret.xmlattr_attr_max = arg.xmlattr_attr_max 32 ret.xmlattr_attr_min = arg.xmlattr_attr_min 31 33 ret.set_any([::SOAP::SOAPElement.new("foo", arg.foo)]) 32 34 ret … … 128 130 arg.eletype = "eletype" 129 131 arg.var = "var" 132 arg.xmlattr_attr_min = -3 133 arg.xmlattr_attr_max = 3 130 134 ret = @client.echo(arg) 131 135 assert_equal(arg.comment, ret.comment)