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