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

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

Revision 1917, 1.9 kB (checked in by nahi, 1 year ago)
  • added support for attributeGroup.
Line 
1 # WSDL4R - XMLSchema complexType restriction 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 ComplexRestriction < Info
18   attr_accessor :base
19   attr_reader :content
20   attr_reader :attributes
21
22   def initialize
23     super
24     @base = nil
25     @basetype = nil
26     @content = nil
27     @attributes = XSD::NamedElements.new
28   end
29
30   def targetnamespace
31     parent.targetnamespace
32   end
33
34   def elementformdefault
35     parent.elementformdefault
36   end
37
38   def have_any?
39     @content and @content.have_any?
40   end
41
42   def choice?
43     @content and @content.choice?
44   end
45
46   def elements
47     @content ? @content.elements : XSD::NamedElements::Empty
48   end
49
50   def nested_elements
51     @content ? @content.nested_elements : XSD::NamedElements::Empty
52   end
53
54   def check_type
55     if @base == ::SOAP::ValueArrayName
56       :TYPE_ARRAY
57     else
58       basetype.check_type if basetype
59     end
60   end
61  
62   def parse_element(element)
63     case element
64     when AllName
65       @content = All.new
66       @content
67     when SequenceName
68       @content = Sequence.new
69       @content
70     when ChoiceName
71       @content = Choice.new
72       @content
73     when AttributeName
74       o = Attribute.new
75       @attributes << o
76       o
77     when AttributeGroupName
78       o = AttributeGroup.new
79       @attributes << o
80       o
81     when AnyAttributeName
82       o = AnyAttribute.new
83       @attributes << o
84       o
85     end
86   end
87
88   def parse_attr(attr, value)
89     case attr
90     when BaseAttrName
91       @base = value
92     end
93   end
94
95 private
96
97   def basetype
98     @basetype ||= root.collect_complextypes[@base]
99   end
100 end
101
102
103 end
104 end
Note: See TracBrowser for help on using the browser.