source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/wsdl/xmlSchema/schema.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 3.0 KB
Line 
1# WSDL4R - XMLSchema schema definition for WSDL.
2# Copyright (C) 2002, 2003-2005 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
9require 'wsdl/info'
10require 'xsd/namedelements'
11
12
13module WSDL
14module XMLSchema
15
16
17class Schema < Info
18 attr_reader :targetnamespace # required
19 attr_reader :complextypes
20 attr_reader :simpletypes
21 attr_reader :elements
22 attr_reader :attributes
23 attr_reader :imports
24 attr_accessor :attributeformdefault
25 attr_accessor :elementformdefault
26
27 attr_reader :importedschema
28
29 def initialize
30 super
31 @targetnamespace = nil
32 @complextypes = XSD::NamedElements.new
33 @simpletypes = XSD::NamedElements.new
34 @elements = XSD::NamedElements.new
35 @attributes = XSD::NamedElements.new
36 @imports = []
37 @attributeformdefault = "unqualified"
38 @elementformdefault = "unqualified"
39 @importedschema = {}
40 @location = nil
41 @root = self
42 end
43
44 def location
45 @location || (root.nil? ? nil : root.location)
46 end
47
48 def location=(location)
49 @location = location
50 end
51
52 def parse_element(element)
53 case element
54 when ImportName
55 o = Import.new
56 @imports << o
57 o
58 when IncludeName
59 o = Include.new
60 @imports << o
61 o
62 when ComplexTypeName
63 o = ComplexType.new
64 @complextypes << o
65 o
66 when SimpleTypeName
67 o = SimpleType.new
68 @simpletypes << o
69 o
70 when ElementName
71 o = Element.new
72 @elements << o
73 o
74 when AttributeName
75 o = Attribute.new
76 @attributes << o
77 o
78 else
79 nil
80 end
81 end
82
83 def parse_attr(attr, value)
84 case attr
85 when TargetNamespaceAttrName
86 @targetnamespace = value.source
87 when AttributeFormDefaultAttrName
88 @attributeformdefault = value.source
89 when ElementFormDefaultAttrName
90 @elementformdefault = value.source
91 else
92 nil
93 end
94 end
95
96 def collect_attributes
97 result = XSD::NamedElements.new
98 result.concat(@attributes)
99 @imports.each do |import|
100 result.concat(import.content.collect_attributes) if import.content
101 end
102 result
103 end
104
105 def collect_elements
106 result = XSD::NamedElements.new
107 result.concat(@elements)
108 @imports.each do |import|
109 result.concat(import.content.collect_elements) if import.content
110 end
111 result
112 end
113
114 def collect_complextypes
115 result = XSD::NamedElements.new
116 result.concat(@complextypes)
117 @imports.each do |import|
118 result.concat(import.content.collect_complextypes) if import.content
119 end
120 result
121 end
122
123 def collect_simpletypes
124 result = XSD::NamedElements.new
125 result.concat(@simpletypes)
126 @imports.each do |import|
127 result.concat(import.content.collect_simpletypes) if import.content
128 end
129 result
130 end
131
132 def self.parse_element(element)
133 if element == SchemaName
134 Schema.new
135 else
136 nil
137 end
138 end
139end
140
141
142end
143end
Note: See TracBrowser for help on using the repository browser.