1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 package org.exolab.castor.xml.schema;
47
48
49
50
51
52
53
54
55 public class SchemaNames {
56
57
58 public static final String SCHEMA_PACKAGE =
59 "org.exolab.castor.xml.schema";
60
61
62 public static final String ALL = "all";
63 public static final String ANNOTATION = "annotation";
64 public static final String ANY = "any";
65 public static final String ANYTYPE = "anyType";
66 public static final String ANY_ATTRIBUTE = "anyAttribute";
67 public static final String APPINFO = "appinfo";
68 public static final String ATTRIBUTE = "attribute";
69 public static final String ATTRIBUTE_GROUP = "attributeGroup";
70 public static final String CHOICE = "choice";
71 public static final String COMPLEX_CONTENT = "complexContent";
72 public static final String COMPLEX_TYPE = "complexType";
73 public static final String DOCUMENTATION = "documentation";
74 public static final String ELEMENT = "element";
75 public static final String ENUMERATION = "enumeration";
76 public static final String EXTENSION = "extension";
77 public static final String FIELD = "field";
78 public static final String GROUP = "group";
79 public static final String INCLUDE = "include";
80 public static final String IMPORT = "import";
81 public static final String KEY = "key";
82 public static final String KEYREF = "keyref";
83 public static final String LIST = "list";
84 public static final String MAX_EXCLUSIVE = "maxExclusive";
85 public static final String MAX_INCLUSIVE = "maxInclusive";
86 public static final String MIN_EXCLUSIVE = "minExclusive";
87 public static final String MIN_INCLUSIVE = "minInclusive";
88 public static final String REDEFINE = "redefine";
89 public static final String RESTRICTION = "restriction";
90 public static final String SCHEMA = "schema";
91 public static final String SELECTOR = "selector";
92 public static final String SEQUENCE = "sequence";
93 public static final String SIMPLETYPE_REF = "simpletypeRef";
94 public static final String SIMPLE_CONTENT = "simpleContent";
95 public static final String SIMPLE_TYPE = "simpleType";
96 public static final String UNION = "union";
97 public static final String UNIQUE = "unique";
98
99
100 public static final String ABSTRACT = "abstract";
101 public static final String ATTR_FORM_DEFAULT_ATTR = "attributeFormDefault";
102 public static final String BASE_ATTR = "base";
103 public static final String BLOCK_ATTR = "block";
104 public static final String BLOCK_DEFAULT_ATTR = "blockDefault";
105 public static final String DEFAULT_ATTR = "default";
106 public static final String ELEM_FORM_DEFAULT_ATTR = "elementFormDefault";
107 public static final String ID_ATTR = "id";
108 public static final String ITEM_TYPE_ATTR = "itemType";
109 public static final String FINAL_ATTR = "final";
110 public static final String FINAL_DEFAULT_ATTR = "finalDefault";
111 public static final String FIXED_ATTR = "fixed";
112 public static final String FORM = "form";
113 public static final String MAX_OCCURS_ATTR = "maxOccurs";
114 public static final String MEMBER_TYPES_ATTR = "memberTypes";
115 public static final String MIN_OCCURS_ATTR = "minOccurs";
116 public static final String MIXED = "mixed";
117 public static final String NAME_ATTR = "name";
118 public static final String NAMESPACE = "namespace";
119 public static final String NILLABLE_ATTR = "nillable";
120 public static final String ORDER_ATTR = "order";
121 public static final String PROCESS_CONTENTS = "processContents";
122 public static final String REF_ATTR = "ref";
123 public static final String REFER_ATTR = "refer";
124 public static final String SCHEMALOCATION_ATTR = "schemaLocation";
125 public static final String SOURCE_ATTR = "source";
126 public static final String SUBSTITUTION_GROUP_ATTR = "substitutionGroup";
127 public static final String TARGET_NS_ATTR = "targetNamespace";
128 public static final String TYPE_ATTR = "type";
129 public static final String USE_ATTR = "use";
130 public static final String VALUE_ATTR = "value";
131 public static final String VERSION_ATTR = "version";
132 public static final String XPATH_ATTR = "xpath";
133
134
135 public static final String INTEGER_TYPE = "integer";
136 public static final String INT_TYPE = "int";
137 public static final String STRING_TYPE = "string";
138
139
140 public static final String NAMESPACE_ANY ="##any";
141 public static final String NAMESPACE_LOCAL ="##local";
142 public static final String NAMESPACE_OTHER ="##other";
143 public static final String NAMESPACE_TARGET ="##targetNamespace";
144
145
146 public static final String LAX = "lax";
147 public static final String SKIP = "skip";
148 public static final String STRICT = "strict";
149
150
151 public static final String WILDCARD = "wildcard";
152
153
154
155
156
157
158
159
160 public static String getStructureName(Structure structure) {
161
162 if (structure == null) return null;
163
164 switch (structure.getStructureType()) {
165 case Structure.ANYTYPE:
166 return ANYTYPE;
167 case Structure.ANNOTATION:
168 return ANNOTATION;
169 case Structure.APPINFO:
170 return APPINFO;
171 case Structure.ATTRIBUTE:
172 return ATTRIBUTE;
173 case Structure.ATTRIBUTE_GROUP:
174 return ATTRIBUTE_GROUP;
175 case Structure.COMPLEX_CONTENT:
176 return COMPLEX_CONTENT;
177 case Structure.COMPLEX_TYPE:
178 return COMPLEX_TYPE;
179 case Structure.DOCUMENTATION:
180 return DOCUMENTATION;
181 case Structure.ELEMENT:
182 return ELEMENT;
183 case Structure.FACET:
184 Facet facet = (Facet)structure;
185 return facet.getName();
186 case Structure.GROUP:
187 Group group = (Group)structure;
188 Order order = group.getOrder();
189 return order.toString();
190 case Structure.IDENTITY_FIELD:
191 return FIELD;
192 case Structure.IDENTITY_SELECTOR:
193 return SELECTOR;
194 case Structure.KEY:
195 return KEY;
196 case Structure.KEYREF:
197 return KEYREF;
198 case Structure.LIST:
199 return LIST;
200 case Structure.MODELGROUP:
201 return GROUP;
202 case Structure.MODELGROUP_REF:
203 return GROUP;
204 case Structure.REDEFINE:
205 return REDEFINE;
206 case Structure.SCHEMA:
207 return SCHEMA;
208 case Structure.SIMPLE_CONTENT:
209 return SIMPLE_CONTENT;
210 case Structure.SIMPLE_TYPE:
211 return SIMPLE_TYPE;
212 case Structure.UNION:
213 return UNION;
214 case Structure.UNIQUE:
215 return UNIQUE;
216 case Structure.WILDCARD:
217 return ANY;
218 default:
219 break;
220 }
221 return null;
222 }
223
224
225
226
227
228
229
230 public static boolean isGroupName(String name) {
231 return (SchemaNames.GROUP.equals(name) ||
232 SchemaNames.SEQUENCE.equals(name) ||
233 SchemaNames.CHOICE.equals(name) ||
234 SchemaNames.ALL.equals(name));
235 }
236
237
238
239
240
241
242
243
244
245 public static boolean isNamespaceName(String name) {
246 boolean result = (SchemaNames.NAMESPACE_ANY.equals(name) ||
247 SchemaNames.NAMESPACE_LOCAL.equals(name) ||
248 SchemaNames.NAMESPACE_OTHER.equals(name) ||
249 SchemaNames.NAMESPACE_TARGET.equals(name));
250 if (result) return result;
251 try {
252 new java.net.URL(name);
253 result = true;
254 } catch (java.net.MalformedURLException e){
255
256 result = false;
257 }
258 return result;
259 }
260
261
262
263
264
265
266
267 public static boolean isProcessName(String name) {
268 return (SchemaNames.LAX.equals(name) ||
269 SchemaNames.SKIP.equals(name) ||
270 SchemaNames.STRICT.equals(name));
271 }
272
273
274 }