Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/branches/1_5/lib/wsdl/xmlSchema/complexExtension.rb

Revision 1959, 2.2 kB (checked in by nahi, 1 year ago)
  • wsdl2ruby.rb generated inconsistent class definition when the base class was :TYPE_ARRAY and the derived class was a :TYPE_STRUCT. let the derived class be a standalone (not a derived) class. closes #424.
Line 
1 # WSDL4R - XMLSchema complexType extension definition for WSDL.
2 # Copyright (C) 2000-2007  NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
3
4 # This program is copyrighted free software by NAKAMURA, Hiroshi.  You can
5 # redistribute it and/or modify it under the same terms of Ruby's license;
6 # either the dual license version in 2003, or any later version.
7
8
9 require 'wsdl/info'
10 require 'xsd/namedelements'
11
12
13 module WSDL
14 module XMLSchema
15
16
17 class ComplexExtension < Info
18   attr_accessor :base
19   attr_reader :content
20
21   def initialize
22     super
23     @base = nil
24     @basetype = nil
25     @content = nil
26     @attributes = XSD::NamedElements.new
27   end
28
29   def targetnamespace
30     parent.targetnamespace
31   end
32
33   def elementformdefault
34     parent.elementformdefault
35   end
36
37   def have_any?
38     basetype.have_any? or (content && content.have_any?)
39   end
40
41   def choice?
42     content and content.choice?
43   end
44
45   def elements
46     result = XSD::NamedElements.new
47     result.concat(basetype.elements)
48     result.concat(content.elements) if content
49     result
50   end
51
52   def nested_elements
53     result = XSD::NamedElements.new
54     result.concat(basetype.nested_elements)
55     result.concat(content.nested_elements) if content
56     result
57   end
58
59   def attributes
60     basetype.attributes + @attributes
61   end
62
63   def check_type
64     if @base == ::SOAP::ValueArrayName
65       :TYPE_ARRAY
66     elsif content or !@attributes.empty?
67       :TYPE_STRUCT
68     else
69       basetype.check_type
70     end
71   end
72  
73   def parse_element(element)
74     case element
75     when AllName
76       @content = All.new
77       @content
78     when SequenceName
79       @content = Sequence.new
80       @content
81     when ChoiceName
82       @content = Choice.new
83       @content
84     when AttributeName
85       o = Attribute.new
86       @attributes << o
87       o
88     when AttributeGroupName
89       o = AttributeGroup.new
90       @attributes << o
91       o
92     when AnyAttributeName
93       o = AnyAttribute.new
94       @attributes << o
95       o
96     end
97   end
98
99   def parse_attr(attr, value)
100     case attr
101     when BaseAttrName
102       @base = value
103     end
104   end
105
106 private
107
108   def basetype
109     @basetype ||= root.collect_complextypes[@base]
110     unless @basetype
111       raise RuntimeError.new("base type definition not found: #{@base}")
112     end
113     @basetype
114   end
115 end
116
117
118 end
119 end
Note: See TracBrowser for help on using the browser.