Line | |
---|
1 | # WSDL4R - XMLSchema complexType definition for WSDL.
|
---|
2 | # Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <[email protected]>.
|
---|
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 |
|
---|
11 |
|
---|
12 | module WSDL
|
---|
13 | module XMLSchema
|
---|
14 |
|
---|
15 |
|
---|
16 | class Content < Info
|
---|
17 | attr_accessor :final
|
---|
18 | attr_accessor :mixed
|
---|
19 | attr_accessor :type
|
---|
20 | attr_reader :contents
|
---|
21 | attr_reader :elements
|
---|
22 |
|
---|
23 | def initialize
|
---|
24 | super()
|
---|
25 | @final = nil
|
---|
26 | @mixed = false
|
---|
27 | @type = nil
|
---|
28 | @contents = []
|
---|
29 | @elements = []
|
---|
30 | end
|
---|
31 |
|
---|
32 | def targetnamespace
|
---|
33 | parent.targetnamespace
|
---|
34 | end
|
---|
35 |
|
---|
36 | def <<(content)
|
---|
37 | @contents << content
|
---|
38 | update_elements
|
---|
39 | end
|
---|
40 |
|
---|
41 | def each
|
---|
42 | @contents.each do |content|
|
---|
43 | yield content
|
---|
44 | end
|
---|
45 | end
|
---|
46 |
|
---|
47 | def parse_element(element)
|
---|
48 | case element
|
---|
49 | when AllName, SequenceName, ChoiceName
|
---|
50 | o = Content.new
|
---|
51 | o.type = element.name
|
---|
52 | @contents << o
|
---|
53 | o
|
---|
54 | when AnyName
|
---|
55 | o = Any.new
|
---|
56 | @contents << o
|
---|
57 | o
|
---|
58 | when ElementName
|
---|
59 | o = Element.new
|
---|
60 | @contents << o
|
---|
61 | o
|
---|
62 | else
|
---|
63 | nil
|
---|
64 | end
|
---|
65 | end
|
---|
66 |
|
---|
67 | def parse_attr(attr, value)
|
---|
68 | case attr
|
---|
69 | when FinalAttrName
|
---|
70 | @final = value.source
|
---|
71 | when MixedAttrName
|
---|
72 | @mixed = (value.source == 'true')
|
---|
73 | else
|
---|
74 | nil
|
---|
75 | end
|
---|
76 | end
|
---|
77 |
|
---|
78 | def parse_epilogue
|
---|
79 | update_elements
|
---|
80 | end
|
---|
81 |
|
---|
82 | private
|
---|
83 |
|
---|
84 | def update_elements
|
---|
85 | @elements = []
|
---|
86 | @contents.each do |content|
|
---|
87 | if content.is_a?(Element)
|
---|
88 | @elements << [content.name, content]
|
---|
89 | end
|
---|
90 | end
|
---|
91 | end
|
---|
92 | end
|
---|
93 |
|
---|
94 |
|
---|
95 | end
|
---|
96 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.