12005
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
7 |
*
|
|
8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9 |
* you may not use this file except in compliance with the License.
|
|
10 |
* You may obtain a copy of the License at
|
|
11 |
*
|
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13 |
*
|
|
14 |
* Unless required by applicable law or agreed to in writing, software
|
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17 |
* See the License for the specific language governing permissions and
|
|
18 |
* limitations under the License.
|
|
19 |
*/
|
|
20 |
|
|
21 |
package com.sun.org.apache.xerces.internal.impl.xs.traversers;
|
|
22 |
|
|
23 |
import java.util.Hashtable;
|
|
24 |
import java.util.Iterator;
|
|
25 |
import java.util.Map;
|
|
26 |
import java.util.StringTokenizer;
|
|
27 |
import java.util.Vector;
|
|
28 |
|
|
29 |
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
|
|
30 |
import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
|
|
31 |
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
|
|
32 |
import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;
|
|
33 |
import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
|
|
34 |
import com.sun.org.apache.xerces.internal.impl.xs.XSAttributeDecl;
|
|
35 |
import com.sun.org.apache.xerces.internal.impl.xs.XSGrammarBucket;
|
|
36 |
import com.sun.org.apache.xerces.internal.impl.xs.XSWildcardDecl;
|
|
37 |
import com.sun.org.apache.xerces.internal.impl.xs.util.XInt;
|
|
38 |
import com.sun.org.apache.xerces.internal.impl.xs.util.XIntPool;
|
|
39 |
import com.sun.org.apache.xerces.internal.util.DOMUtil;
|
|
40 |
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
|
41 |
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
|
42 |
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
|
43 |
import com.sun.org.apache.xerces.internal.xni.QName;
|
|
44 |
import com.sun.org.apache.xerces.internal.xs.XSConstants;
|
|
45 |
import java.util.HashMap;
|
|
46 |
import org.w3c.dom.Attr;
|
|
47 |
import org.w3c.dom.Element;
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Class <code>XSAttributeCheck</code> is used to check the validity of attributes
|
|
51 |
* appearing in the schema document. It
|
|
52 |
* - reports an error for invalid element (invalid namespace, invalid name)
|
|
53 |
* - reports an error for invalid attribute (invalid namespace, invalid name)
|
|
54 |
* - reports an error for invalid attribute value
|
|
55 |
* - return compiled values for attriute values
|
|
56 |
* - provide default value for missing optional attributes
|
|
57 |
* - provide default value for incorrect attribute values
|
|
58 |
*
|
|
59 |
* But it's the caller's responsibility to check whether a required attribute
|
|
60 |
* is present.
|
|
61 |
*
|
|
62 |
* Things need revisiting:
|
|
63 |
* - Whether to return non-schema attributes/values
|
|
64 |
* - Do we need to update NamespaceScope and ErrorReporter when reset()?
|
|
65 |
* - Should have the datatype validators return compiled value
|
|
66 |
* - use symbol table instead of many hashtables
|
|
67 |
*
|
|
68 |
* @xerces.internal
|
|
69 |
*
|
|
70 |
* @author Sandy Gao, IBM
|
|
71 |
* @version $Id: XSAttributeChecker.java,v 1.12 2010-11-01 04:40:02 joehw Exp $
|
|
72 |
*/
|
|
73 |
|
|
74 |
public class XSAttributeChecker {
|
|
75 |
|
|
76 |
// REVISIT: only local element and attribute are different from others.
|
|
77 |
// it's possible to have either name or ref. all the others
|
|
78 |
// are only allowed to have one of name or ref, or neither of them.
|
|
79 |
// we'd better move such checking to the traverser.
|
|
80 |
private static final String ELEMENT_N = "element_n";
|
|
81 |
private static final String ELEMENT_R = "element_r";
|
|
82 |
private static final String ATTRIBUTE_N = "attribute_n";
|
|
83 |
private static final String ATTRIBUTE_R = "attribute_r";
|
|
84 |
|
|
85 |
private static int ATTIDX_COUNT = 0;
|
|
86 |
public static final int ATTIDX_ABSTRACT = ATTIDX_COUNT++;
|
|
87 |
public static final int ATTIDX_AFORMDEFAULT = ATTIDX_COUNT++;
|
|
88 |
public static final int ATTIDX_BASE = ATTIDX_COUNT++;
|
|
89 |
public static final int ATTIDX_BLOCK = ATTIDX_COUNT++;
|
|
90 |
public static final int ATTIDX_BLOCKDEFAULT = ATTIDX_COUNT++;
|
|
91 |
public static final int ATTIDX_DEFAULT = ATTIDX_COUNT++;
|
|
92 |
public static final int ATTIDX_EFORMDEFAULT = ATTIDX_COUNT++;
|
|
93 |
public static final int ATTIDX_FINAL = ATTIDX_COUNT++;
|
|
94 |
public static final int ATTIDX_FINALDEFAULT = ATTIDX_COUNT++;
|
|
95 |
public static final int ATTIDX_FIXED = ATTIDX_COUNT++;
|
|
96 |
public static final int ATTIDX_FORM = ATTIDX_COUNT++;
|
|
97 |
public static final int ATTIDX_ID = ATTIDX_COUNT++;
|
|
98 |
public static final int ATTIDX_ITEMTYPE = ATTIDX_COUNT++;
|
|
99 |
public static final int ATTIDX_MAXOCCURS = ATTIDX_COUNT++;
|
|
100 |
public static final int ATTIDX_MEMBERTYPES = ATTIDX_COUNT++;
|
|
101 |
public static final int ATTIDX_MINOCCURS = ATTIDX_COUNT++;
|
|
102 |
public static final int ATTIDX_MIXED = ATTIDX_COUNT++;
|
|
103 |
public static final int ATTIDX_NAME = ATTIDX_COUNT++;
|
|
104 |
public static final int ATTIDX_NAMESPACE = ATTIDX_COUNT++;
|
|
105 |
public static final int ATTIDX_NAMESPACE_LIST = ATTIDX_COUNT++;
|
|
106 |
public static final int ATTIDX_NILLABLE = ATTIDX_COUNT++;
|
|
107 |
public static final int ATTIDX_NONSCHEMA = ATTIDX_COUNT++;
|
|
108 |
public static final int ATTIDX_PROCESSCONTENTS = ATTIDX_COUNT++;
|
|
109 |
public static final int ATTIDX_PUBLIC = ATTIDX_COUNT++;
|
|
110 |
public static final int ATTIDX_REF = ATTIDX_COUNT++;
|
|
111 |
public static final int ATTIDX_REFER = ATTIDX_COUNT++;
|
|
112 |
public static final int ATTIDX_SCHEMALOCATION = ATTIDX_COUNT++;
|
|
113 |
public static final int ATTIDX_SOURCE = ATTIDX_COUNT++;
|
|
114 |
public static final int ATTIDX_SUBSGROUP = ATTIDX_COUNT++;
|
|
115 |
public static final int ATTIDX_SYSTEM = ATTIDX_COUNT++;
|
|
116 |
public static final int ATTIDX_TARGETNAMESPACE = ATTIDX_COUNT++;
|
|
117 |
public static final int ATTIDX_TYPE = ATTIDX_COUNT++;
|
|
118 |
public static final int ATTIDX_USE = ATTIDX_COUNT++;
|
|
119 |
public static final int ATTIDX_VALUE = ATTIDX_COUNT++;
|
|
120 |
public static final int ATTIDX_ENUMNSDECLS = ATTIDX_COUNT++;
|
|
121 |
public static final int ATTIDX_VERSION = ATTIDX_COUNT++;
|
|
122 |
public static final int ATTIDX_XML_LANG = ATTIDX_COUNT++;
|
|
123 |
public static final int ATTIDX_XPATH = ATTIDX_COUNT++;
|
|
124 |
public static final int ATTIDX_FROMDEFAULT = ATTIDX_COUNT++;
|
|
125 |
//public static final int ATTIDX_OTHERVALUES = ATTIDX_COUNT++;
|
|
126 |
public static final int ATTIDX_ISRETURNED = ATTIDX_COUNT++;
|
|
127 |
|
|
128 |
private static final XIntPool fXIntPool = new XIntPool();
|
|
129 |
// constants to return
|
|
130 |
private static final XInt INT_QUALIFIED = fXIntPool.getXInt(SchemaSymbols.FORM_QUALIFIED);
|
|
131 |
private static final XInt INT_UNQUALIFIED = fXIntPool.getXInt(SchemaSymbols.FORM_UNQUALIFIED);
|
|
132 |
private static final XInt INT_EMPTY_SET = fXIntPool.getXInt(XSConstants.DERIVATION_NONE);
|
|
133 |
private static final XInt INT_ANY_STRICT = fXIntPool.getXInt(XSWildcardDecl.PC_STRICT);
|
|
134 |
private static final XInt INT_ANY_LAX = fXIntPool.getXInt(XSWildcardDecl.PC_LAX);
|
|
135 |
private static final XInt INT_ANY_SKIP = fXIntPool.getXInt(XSWildcardDecl.PC_SKIP);
|
|
136 |
private static final XInt INT_ANY_ANY = fXIntPool.getXInt(XSWildcardDecl.NSCONSTRAINT_ANY);
|
|
137 |
private static final XInt INT_ANY_LIST = fXIntPool.getXInt(XSWildcardDecl.NSCONSTRAINT_LIST);
|
|
138 |
private static final XInt INT_ANY_NOT = fXIntPool.getXInt(XSWildcardDecl.NSCONSTRAINT_NOT);
|
|
139 |
private static final XInt INT_USE_OPTIONAL = fXIntPool.getXInt(SchemaSymbols.USE_OPTIONAL);
|
|
140 |
private static final XInt INT_USE_REQUIRED = fXIntPool.getXInt(SchemaSymbols.USE_REQUIRED);
|
|
141 |
private static final XInt INT_USE_PROHIBITED = fXIntPool.getXInt(SchemaSymbols.USE_PROHIBITED);
|
|
142 |
private static final XInt INT_WS_PRESERVE = fXIntPool.getXInt(XSSimpleType.WS_PRESERVE);
|
|
143 |
private static final XInt INT_WS_REPLACE = fXIntPool.getXInt(XSSimpleType.WS_REPLACE);
|
|
144 |
private static final XInt INT_WS_COLLAPSE = fXIntPool.getXInt(XSSimpleType.WS_COLLAPSE);
|
|
145 |
private static final XInt INT_UNBOUNDED = fXIntPool.getXInt(SchemaSymbols.OCCURRENCE_UNBOUNDED);
|
|
146 |
|
|
147 |
// used to store the map from element name to attribute list
|
|
148 |
// for 14 global elements
|
|
149 |
private static final Map fEleAttrsMapG = new HashMap(29);
|
|
150 |
// for 39 local elememnts
|
|
151 |
private static final Map fEleAttrsMapL = new HashMap(79);
|
|
152 |
|
|
153 |
// used to initialize fEleAttrsMap
|
|
154 |
// step 1: all possible data types
|
|
155 |
// DT_??? >= 0 : validate using a validator, which is initialized staticly
|
|
156 |
// DT_??? < 0 : validate directly, which is done in "validate()"
|
|
157 |
|
|
158 |
protected static final int DT_ANYURI = 0;
|
|
159 |
protected static final int DT_ID = 1;
|
|
160 |
protected static final int DT_QNAME = 2;
|
|
161 |
protected static final int DT_STRING = 3;
|
|
162 |
protected static final int DT_TOKEN = 4;
|
|
163 |
protected static final int DT_NCNAME = 5;
|
|
164 |
protected static final int DT_XPATH = 6;
|
|
165 |
protected static final int DT_XPATH1 = 7;
|
|
166 |
protected static final int DT_LANGUAGE = 8;
|
|
167 |
|
|
168 |
// used to store extra datatype validators
|
|
169 |
protected static final int DT_COUNT = DT_LANGUAGE + 1;
|
|
170 |
private static final XSSimpleType[] fExtraDVs = new XSSimpleType[DT_COUNT];
|
|
171 |
static {
|
|
172 |
// step 5: register all datatype validators for new types
|
|
173 |
SchemaGrammar grammar = SchemaGrammar.SG_SchemaNS;
|
|
174 |
// anyURI
|
|
175 |
fExtraDVs[DT_ANYURI] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYURI);
|
|
176 |
// ID
|
|
177 |
fExtraDVs[DT_ID] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ID);
|
|
178 |
// QName
|
|
179 |
fExtraDVs[DT_QNAME] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME);
|
|
180 |
// string
|
|
181 |
fExtraDVs[DT_STRING] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING);
|
|
182 |
// token
|
|
183 |
fExtraDVs[DT_TOKEN] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_TOKEN);
|
|
184 |
// NCName
|
|
185 |
fExtraDVs[DT_NCNAME] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_NCNAME);
|
|
186 |
// xpath = a subset of XPath expression
|
|
187 |
fExtraDVs[DT_XPATH] = fExtraDVs[DT_STRING];
|
|
188 |
// xpath = a subset of XPath expression
|
|
189 |
fExtraDVs[DT_XPATH] = fExtraDVs[DT_STRING];
|
|
190 |
// language
|
|
191 |
fExtraDVs[DT_LANGUAGE] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_LANGUAGE);
|
|
192 |
}
|
|
193 |
|
|
194 |
protected static final int DT_BLOCK = -1;
|
|
195 |
protected static final int DT_BLOCK1 = -2;
|
|
196 |
protected static final int DT_FINAL = -3;
|
|
197 |
protected static final int DT_FINAL1 = -4;
|
|
198 |
protected static final int DT_FINAL2 = -5;
|
|
199 |
protected static final int DT_FORM = -6;
|
|
200 |
protected static final int DT_MAXOCCURS = -7;
|
|
201 |
protected static final int DT_MAXOCCURS1 = -8;
|
|
202 |
protected static final int DT_MEMBERTYPES = -9;
|
|
203 |
protected static final int DT_MINOCCURS1 = -10;
|
|
204 |
protected static final int DT_NAMESPACE = -11;
|
|
205 |
protected static final int DT_PROCESSCONTENTS = -12;
|
|
206 |
protected static final int DT_USE = -13;
|
|
207 |
protected static final int DT_WHITESPACE = -14;
|
|
208 |
protected static final int DT_BOOLEAN = -15;
|
|
209 |
protected static final int DT_NONNEGINT = -16;
|
|
210 |
protected static final int DT_POSINT = -17;
|
|
211 |
|
|
212 |
static {
|
|
213 |
// step 2: all possible attributes for all elements
|
|
214 |
int attCount = 0;
|
|
215 |
int ATT_ABSTRACT_D = attCount++;
|
|
216 |
int ATT_ATTRIBUTE_FD_D = attCount++;
|
|
217 |
int ATT_BASE_R = attCount++;
|
|
218 |
int ATT_BASE_N = attCount++;
|
|
219 |
int ATT_BLOCK_N = attCount++;
|
|
220 |
int ATT_BLOCK1_N = attCount++;
|
|
221 |
int ATT_BLOCK_D_D = attCount++;
|
|
222 |
int ATT_DEFAULT_N = attCount++;
|
|
223 |
int ATT_ELEMENT_FD_D = attCount++;
|
|
224 |
int ATT_FINAL_N = attCount++;
|
|
225 |
int ATT_FINAL1_N = attCount++;
|
|
226 |
int ATT_FINAL_D_D = attCount++;
|
|
227 |
int ATT_FIXED_N = attCount++;
|
|
228 |
int ATT_FIXED_D = attCount++;
|
|
229 |
int ATT_FORM_N = attCount++;
|
|
230 |
int ATT_ID_N = attCount++;
|
|
231 |
int ATT_ITEMTYPE_N = attCount++;
|
|
232 |
int ATT_MAXOCCURS_D = attCount++;
|
|
233 |
int ATT_MAXOCCURS1_D = attCount++;
|
|
234 |
int ATT_MEMBER_T_N = attCount++;
|
|
235 |
int ATT_MINOCCURS_D = attCount++;
|
|
236 |
int ATT_MINOCCURS1_D = attCount++;
|
|
237 |
int ATT_MIXED_D = attCount++;
|
|
238 |
int ATT_MIXED_N = attCount++;
|
|
239 |
int ATT_NAME_R = attCount++;
|
|
240 |
int ATT_NAMESPACE_D = attCount++;
|
|
241 |
int ATT_NAMESPACE_N = attCount++;
|
|
242 |
int ATT_NILLABLE_D = attCount++;
|
|
243 |
int ATT_PROCESS_C_D = attCount++;
|
|
244 |
int ATT_PUBLIC_R = attCount++;
|
|
245 |
int ATT_REF_R = attCount++;
|
|
246 |
int ATT_REFER_R = attCount++;
|
|
247 |
int ATT_SCHEMA_L_R = attCount++;
|
|
248 |
int ATT_SCHEMA_L_N = attCount++;
|
|
249 |
int ATT_SOURCE_N = attCount++;
|
|
250 |
int ATT_SUBSTITUTION_G_N = attCount++;
|
|
251 |
int ATT_SYSTEM_N = attCount++;
|
|
252 |
int ATT_TARGET_N_N = attCount++;
|
|
253 |
int ATT_TYPE_N = attCount++;
|
|
254 |
int ATT_USE_D = attCount++;
|
|
255 |
int ATT_VALUE_NNI_N = attCount++;
|
|
256 |
int ATT_VALUE_PI_N = attCount++;
|
|
257 |
int ATT_VALUE_STR_N = attCount++;
|
|
258 |
int ATT_VALUE_WS_N = attCount++;
|
|
259 |
int ATT_VERSION_N = attCount++;
|
|
260 |
int ATT_XML_LANG = attCount++;
|
|
261 |
int ATT_XPATH_R = attCount++;
|
|
262 |
int ATT_XPATH1_R = attCount++;
|
|
263 |
|
|
264 |
// step 3: store all these attributes in an array
|
|
265 |
OneAttr[] allAttrs = new OneAttr[attCount];
|
|
266 |
allAttrs[ATT_ABSTRACT_D] = new OneAttr(SchemaSymbols.ATT_ABSTRACT,
|
|
267 |
DT_BOOLEAN,
|
|
268 |
ATTIDX_ABSTRACT,
|
|
269 |
Boolean.FALSE);
|
|
270 |
allAttrs[ATT_ATTRIBUTE_FD_D] = new OneAttr(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT,
|
|
271 |
DT_FORM,
|
|
272 |
ATTIDX_AFORMDEFAULT,
|
|
273 |
INT_UNQUALIFIED);
|
|
274 |
allAttrs[ATT_BASE_R] = new OneAttr(SchemaSymbols.ATT_BASE,
|
|
275 |
DT_QNAME,
|
|
276 |
ATTIDX_BASE,
|
|
277 |
null);
|
|
278 |
allAttrs[ATT_BASE_N] = new OneAttr(SchemaSymbols.ATT_BASE,
|
|
279 |
DT_QNAME,
|
|
280 |
ATTIDX_BASE,
|
|
281 |
null);
|
|
282 |
allAttrs[ATT_BLOCK_N] = new OneAttr(SchemaSymbols.ATT_BLOCK,
|
|
283 |
DT_BLOCK,
|
|
284 |
ATTIDX_BLOCK,
|
|
285 |
null);
|
|
286 |
allAttrs[ATT_BLOCK1_N] = new OneAttr(SchemaSymbols.ATT_BLOCK,
|
|
287 |
DT_BLOCK1,
|
|
288 |
ATTIDX_BLOCK,
|
|
289 |
null);
|
|
290 |
allAttrs[ATT_BLOCK_D_D] = new OneAttr(SchemaSymbols.ATT_BLOCKDEFAULT,
|
|
291 |
DT_BLOCK,
|
|
292 |
ATTIDX_BLOCKDEFAULT,
|
|
293 |
INT_EMPTY_SET);
|
|
294 |
allAttrs[ATT_DEFAULT_N] = new OneAttr(SchemaSymbols.ATT_DEFAULT,
|
|
295 |
DT_STRING,
|
|
296 |
ATTIDX_DEFAULT,
|
|
297 |
null);
|
|
298 |
allAttrs[ATT_ELEMENT_FD_D] = new OneAttr(SchemaSymbols.ATT_ELEMENTFORMDEFAULT,
|
|
299 |
DT_FORM,
|
|
300 |
ATTIDX_EFORMDEFAULT,
|
|
301 |
INT_UNQUALIFIED);
|
|
302 |
allAttrs[ATT_FINAL_N] = new OneAttr(SchemaSymbols.ATT_FINAL,
|
|
303 |
DT_FINAL,
|
|
304 |
ATTIDX_FINAL,
|
|
305 |
null);
|
|
306 |
allAttrs[ATT_FINAL1_N] = new OneAttr(SchemaSymbols.ATT_FINAL,
|
|
307 |
DT_FINAL1,
|
|
308 |
ATTIDX_FINAL,
|
|
309 |
null);
|
|
310 |
allAttrs[ATT_FINAL_D_D] = new OneAttr(SchemaSymbols.ATT_FINALDEFAULT,
|
|
311 |
DT_FINAL2,
|
|
312 |
ATTIDX_FINALDEFAULT,
|
|
313 |
INT_EMPTY_SET);
|
|
314 |
allAttrs[ATT_FIXED_N] = new OneAttr(SchemaSymbols.ATT_FIXED,
|
|
315 |
DT_STRING,
|
|
316 |
ATTIDX_FIXED,
|
|
317 |
null);
|
|
318 |
allAttrs[ATT_FIXED_D] = new OneAttr(SchemaSymbols.ATT_FIXED,
|
|
319 |
DT_BOOLEAN,
|
|
320 |
ATTIDX_FIXED,
|
|
321 |
Boolean.FALSE);
|
|
322 |
allAttrs[ATT_FORM_N] = new OneAttr(SchemaSymbols.ATT_FORM,
|
|
323 |
DT_FORM,
|
|
324 |
ATTIDX_FORM,
|
|
325 |
null);
|
|
326 |
allAttrs[ATT_ID_N] = new OneAttr(SchemaSymbols.ATT_ID,
|
|
327 |
DT_ID,
|
|
328 |
ATTIDX_ID,
|
|
329 |
null);
|
|
330 |
allAttrs[ATT_ITEMTYPE_N] = new OneAttr(SchemaSymbols.ATT_ITEMTYPE,
|
|
331 |
DT_QNAME,
|
|
332 |
ATTIDX_ITEMTYPE,
|
|
333 |
null);
|
|
334 |
allAttrs[ATT_MAXOCCURS_D] = new OneAttr(SchemaSymbols.ATT_MAXOCCURS,
|
|
335 |
DT_MAXOCCURS,
|
|
336 |
ATTIDX_MAXOCCURS,
|
|
337 |
fXIntPool.getXInt(1));
|
|
338 |
allAttrs[ATT_MAXOCCURS1_D] = new OneAttr(SchemaSymbols.ATT_MAXOCCURS,
|
|
339 |
DT_MAXOCCURS1,
|
|
340 |
ATTIDX_MAXOCCURS,
|
|
341 |
fXIntPool.getXInt(1));
|
|
342 |
allAttrs[ATT_MEMBER_T_N] = new OneAttr(SchemaSymbols.ATT_MEMBERTYPES,
|
|
343 |
DT_MEMBERTYPES,
|
|
344 |
ATTIDX_MEMBERTYPES,
|
|
345 |
null);
|
|
346 |
allAttrs[ATT_MINOCCURS_D] = new OneAttr(SchemaSymbols.ATT_MINOCCURS,
|
|
347 |
DT_NONNEGINT,
|
|
348 |
ATTIDX_MINOCCURS,
|
|
349 |
fXIntPool.getXInt(1));
|
|
350 |
allAttrs[ATT_MINOCCURS1_D] = new OneAttr(SchemaSymbols.ATT_MINOCCURS,
|
|
351 |
DT_MINOCCURS1,
|
|
352 |
ATTIDX_MINOCCURS,
|
|
353 |
fXIntPool.getXInt(1));
|
|
354 |
allAttrs[ATT_MIXED_D] = new OneAttr(SchemaSymbols.ATT_MIXED,
|
|
355 |
DT_BOOLEAN,
|
|
356 |
ATTIDX_MIXED,
|
|
357 |
Boolean.FALSE);
|
|
358 |
allAttrs[ATT_MIXED_N] = new OneAttr(SchemaSymbols.ATT_MIXED,
|
|
359 |
DT_BOOLEAN,
|
|
360 |
ATTIDX_MIXED,
|
|
361 |
null);
|
|
362 |
allAttrs[ATT_NAME_R] = new OneAttr(SchemaSymbols.ATT_NAME,
|
|
363 |
DT_NCNAME,
|
|
364 |
ATTIDX_NAME,
|
|
365 |
null);
|
|
366 |
allAttrs[ATT_NAMESPACE_D] = new OneAttr(SchemaSymbols.ATT_NAMESPACE,
|
|
367 |
DT_NAMESPACE,
|
|
368 |
ATTIDX_NAMESPACE,
|
|
369 |
INT_ANY_ANY);
|
|
370 |
allAttrs[ATT_NAMESPACE_N] = new OneAttr(SchemaSymbols.ATT_NAMESPACE,
|
|
371 |
DT_ANYURI,
|
|
372 |
ATTIDX_NAMESPACE,
|
|
373 |
null);
|
|
374 |
allAttrs[ATT_NILLABLE_D] = new OneAttr(SchemaSymbols.ATT_NILLABLE,
|
|
375 |
DT_BOOLEAN,
|
|
376 |
ATTIDX_NILLABLE,
|
|
377 |
Boolean.FALSE);
|
|
378 |
allAttrs[ATT_PROCESS_C_D] = new OneAttr(SchemaSymbols.ATT_PROCESSCONTENTS,
|
|
379 |
DT_PROCESSCONTENTS,
|
|
380 |
ATTIDX_PROCESSCONTENTS,
|
|
381 |
INT_ANY_STRICT);
|
|
382 |
allAttrs[ATT_PUBLIC_R] = new OneAttr(SchemaSymbols.ATT_PUBLIC,
|
|
383 |
DT_TOKEN,
|
|
384 |
ATTIDX_PUBLIC,
|
|
385 |
null);
|
|
386 |
allAttrs[ATT_REF_R] = new OneAttr(SchemaSymbols.ATT_REF,
|
|
387 |
DT_QNAME,
|
|
388 |
ATTIDX_REF,
|
|
389 |
null);
|
|
390 |
allAttrs[ATT_REFER_R] = new OneAttr(SchemaSymbols.ATT_REFER,
|
|
391 |
DT_QNAME,
|
|
392 |
ATTIDX_REFER,
|
|
393 |
null);
|
|
394 |
allAttrs[ATT_SCHEMA_L_R] = new OneAttr(SchemaSymbols.ATT_SCHEMALOCATION,
|
|
395 |
DT_ANYURI,
|
|
396 |
ATTIDX_SCHEMALOCATION,
|
|
397 |
null);
|
|
398 |
allAttrs[ATT_SCHEMA_L_N] = new OneAttr(SchemaSymbols.ATT_SCHEMALOCATION,
|
|
399 |
DT_ANYURI,
|
|
400 |
ATTIDX_SCHEMALOCATION,
|
|
401 |
null);
|
|
402 |
allAttrs[ATT_SOURCE_N] = new OneAttr(SchemaSymbols.ATT_SOURCE,
|
|
403 |
DT_ANYURI,
|
|
404 |
ATTIDX_SOURCE,
|
|
405 |
null);
|
|
406 |
allAttrs[ATT_SUBSTITUTION_G_N] = new OneAttr(SchemaSymbols.ATT_SUBSTITUTIONGROUP,
|
|
407 |
DT_QNAME,
|
|
408 |
ATTIDX_SUBSGROUP,
|
|
409 |
null);
|
|
410 |
allAttrs[ATT_SYSTEM_N] = new OneAttr(SchemaSymbols.ATT_SYSTEM,
|
|
411 |
DT_ANYURI,
|
|
412 |
ATTIDX_SYSTEM,
|
|
413 |
null);
|
|
414 |
allAttrs[ATT_TARGET_N_N] = new OneAttr(SchemaSymbols.ATT_TARGETNAMESPACE,
|
|
415 |
DT_ANYURI,
|
|
416 |
ATTIDX_TARGETNAMESPACE,
|
|
417 |
null);
|
|
418 |
allAttrs[ATT_TYPE_N] = new OneAttr(SchemaSymbols.ATT_TYPE,
|
|
419 |
DT_QNAME,
|
|
420 |
ATTIDX_TYPE,
|
|
421 |
null);
|
|
422 |
allAttrs[ATT_USE_D] = new OneAttr(SchemaSymbols.ATT_USE,
|
|
423 |
DT_USE,
|
|
424 |
ATTIDX_USE,
|
|
425 |
INT_USE_OPTIONAL);
|
|
426 |
allAttrs[ATT_VALUE_NNI_N] = new OneAttr(SchemaSymbols.ATT_VALUE,
|
|
427 |
DT_NONNEGINT,
|
|
428 |
ATTIDX_VALUE,
|
|
429 |
null);
|
|
430 |
allAttrs[ATT_VALUE_PI_N] = new OneAttr(SchemaSymbols.ATT_VALUE,
|
|
431 |
DT_POSINT,
|
|
432 |
ATTIDX_VALUE,
|
|
433 |
null);
|
|
434 |
allAttrs[ATT_VALUE_STR_N] = new OneAttr(SchemaSymbols.ATT_VALUE,
|
|
435 |
DT_STRING,
|
|
436 |
ATTIDX_VALUE,
|
|
437 |
null);
|
|
438 |
allAttrs[ATT_VALUE_WS_N] = new OneAttr(SchemaSymbols.ATT_VALUE,
|
|
439 |
DT_WHITESPACE,
|
|
440 |
ATTIDX_VALUE,
|
|
441 |
null);
|
|
442 |
allAttrs[ATT_VERSION_N] = new OneAttr(SchemaSymbols.ATT_VERSION,
|
|
443 |
DT_TOKEN,
|
|
444 |
ATTIDX_VERSION,
|
|
445 |
null);
|
|
446 |
allAttrs[ATT_XML_LANG] = new OneAttr(SchemaSymbols.ATT_XML_LANG,
|
|
447 |
DT_LANGUAGE,
|
|
448 |
ATTIDX_XML_LANG,
|
|
449 |
null);
|
|
450 |
allAttrs[ATT_XPATH_R] = new OneAttr(SchemaSymbols.ATT_XPATH,
|
|
451 |
DT_XPATH,
|
|
452 |
ATTIDX_XPATH,
|
|
453 |
null);
|
|
454 |
allAttrs[ATT_XPATH1_R] = new OneAttr(SchemaSymbols.ATT_XPATH,
|
|
455 |
DT_XPATH1,
|
|
456 |
ATTIDX_XPATH,
|
|
457 |
null);
|
|
458 |
|
|
459 |
// step 4: for each element, make a list of possible attributes
|
|
460 |
Container attrList;
|
|
461 |
|
|
462 |
// for element "attribute" - global
|
|
463 |
attrList = Container.getContainer(5);
|
|
464 |
// default = string
|
|
465 |
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
|
|
466 |
// fixed = string
|
|
467 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
|
|
468 |
// id = ID
|
|
469 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
470 |
// name = NCName
|
|
471 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
472 |
// type = QName
|
|
473 |
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
|
|
474 |
fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTE, attrList);
|
|
475 |
|
|
476 |
// for element "attribute" - local name
|
|
477 |
attrList = Container.getContainer(7);
|
|
478 |
// default = string
|
|
479 |
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
|
|
480 |
// fixed = string
|
|
481 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
|
|
482 |
// form = (qualified | unqualified)
|
|
483 |
attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]);
|
|
484 |
// id = ID
|
|
485 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
486 |
// name = NCName
|
|
487 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
488 |
// type = QName
|
|
489 |
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
|
|
490 |
// use = (optional | prohibited | required) : optional
|
|
491 |
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
|
|
492 |
fEleAttrsMapL.put(ATTRIBUTE_N, attrList);
|
|
493 |
|
|
494 |
// for element "attribute" - local ref
|
|
495 |
attrList = Container.getContainer(5);
|
|
496 |
// default = string
|
|
497 |
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
|
|
498 |
// fixed = string
|
|
499 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
|
|
500 |
// id = ID
|
|
501 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
502 |
// ref = QName
|
|
503 |
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
|
|
504 |
// use = (optional | prohibited | required) : optional
|
|
505 |
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
|
|
506 |
fEleAttrsMapL.put(ATTRIBUTE_R, attrList);
|
|
507 |
|
|
508 |
// for element "element" - global
|
|
509 |
attrList = Container.getContainer(10);
|
|
510 |
// abstract = boolean : false
|
|
511 |
attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]);
|
|
512 |
// block = (#all | List of (extension | restriction | substitution))
|
|
513 |
attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
|
|
514 |
// default = string
|
|
515 |
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
|
|
516 |
// final = (#all | List of (extension | restriction))
|
|
517 |
attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]);
|
|
518 |
// fixed = string
|
|
519 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
|
|
520 |
// id = ID
|
|
521 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
522 |
// name = NCName
|
|
523 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
524 |
// nillable = boolean : false
|
|
525 |
attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]);
|
|
526 |
// substitutionGroup = QName
|
|
527 |
attrList.put(SchemaSymbols.ATT_SUBSTITUTIONGROUP, allAttrs[ATT_SUBSTITUTION_G_N]);
|
|
528 |
// type = QName
|
|
529 |
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
|
|
530 |
fEleAttrsMapG.put(SchemaSymbols.ELT_ELEMENT, attrList);
|
|
531 |
|
|
532 |
// for element "element" - local name
|
|
533 |
attrList = Container.getContainer(10);
|
|
534 |
// block = (#all | List of (extension | restriction | substitution))
|
|
535 |
attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
|
|
536 |
// default = string
|
|
537 |
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
|
|
538 |
// fixed = string
|
|
539 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
|
|
540 |
// form = (qualified | unqualified)
|
|
541 |
attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]);
|
|
542 |
// id = ID
|
|
543 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
544 |
// maxOccurs = (nonNegativeInteger | unbounded) : 1
|
|
545 |
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
|
|
546 |
// minOccurs = nonNegativeInteger : 1
|
|
547 |
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
|
|
548 |
// name = NCName
|
|
549 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
550 |
// nillable = boolean : false
|
|
551 |
attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]);
|
|
552 |
// type = QName
|
|
553 |
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
|
|
554 |
fEleAttrsMapL.put(ELEMENT_N, attrList);
|
|
555 |
|
|
556 |
// for element "element" - local ref
|
|
557 |
attrList = Container.getContainer(4);
|
|
558 |
// id = ID
|
|
559 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
560 |
// maxOccurs = (nonNegativeInteger | unbounded) : 1
|
|
561 |
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
|
|
562 |
// minOccurs = nonNegativeInteger : 1
|
|
563 |
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
|
|
564 |
// ref = QName
|
|
565 |
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
|
|
566 |
fEleAttrsMapL.put(ELEMENT_R, attrList);
|
|
567 |
|
|
568 |
// for element "complexType" - global
|
|
569 |
attrList = Container.getContainer(6);
|
|
570 |
// abstract = boolean : false
|
|
571 |
attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]);
|
|
572 |
// block = (#all | List of (extension | restriction))
|
|
573 |
attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK1_N]);
|
|
574 |
// final = (#all | List of (extension | restriction))
|
|
575 |
attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]);
|
|
576 |
// id = ID
|
|
577 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
578 |
// mixed = boolean : false
|
|
579 |
attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
|
|
580 |
// name = NCName
|
|
581 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
582 |
fEleAttrsMapG.put(SchemaSymbols.ELT_COMPLEXTYPE, attrList);
|
|
583 |
|
|
584 |
// for element "notation" - global
|
|
585 |
attrList = Container.getContainer(4);
|
|
586 |
// id = ID
|
|
587 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
588 |
// name = NCName
|
|
589 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
590 |
// public = A public identifier, per ISO 8879
|
|
591 |
attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]);
|
|
592 |
// system = anyURI
|
|
593 |
attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]);
|
|
594 |
fEleAttrsMapG.put(SchemaSymbols.ELT_NOTATION, attrList);
|
|
595 |
|
|
596 |
|
|
597 |
// for element "complexType" - local
|
|
598 |
attrList = Container.getContainer(2);
|
|
599 |
// id = ID
|
|
600 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
601 |
// mixed = boolean : false
|
|
602 |
attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
|
|
603 |
fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXTYPE, attrList);
|
|
604 |
|
|
605 |
// for element "simpleContent" - local
|
|
606 |
attrList = Container.getContainer(1);
|
|
607 |
// id = ID
|
|
608 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
609 |
fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLECONTENT, attrList);
|
|
610 |
|
|
611 |
// for element "restriction" - local
|
|
612 |
attrList = Container.getContainer(2);
|
|
613 |
// base = QName
|
|
614 |
attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_N]);
|
|
615 |
// id = ID
|
|
616 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
617 |
fEleAttrsMapL.put(SchemaSymbols.ELT_RESTRICTION, attrList);
|
|
618 |
|
|
619 |
// for element "extension" - local
|
|
620 |
attrList = Container.getContainer(2);
|
|
621 |
// base = QName
|
|
622 |
attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_R]);
|
|
623 |
// id = ID
|
|
624 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
625 |
fEleAttrsMapL.put(SchemaSymbols.ELT_EXTENSION, attrList);
|
|
626 |
|
|
627 |
// for element "attributeGroup" - local ref
|
|
628 |
attrList = Container.getContainer(2);
|
|
629 |
// id = ID
|
|
630 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
631 |
// ref = QName
|
|
632 |
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
|
|
633 |
fEleAttrsMapL.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, attrList);
|
|
634 |
|
|
635 |
// for element "anyAttribute" - local
|
|
636 |
attrList = Container.getContainer(3);
|
|
637 |
// id = ID
|
|
638 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
639 |
// namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any
|
|
640 |
attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]);
|
|
641 |
// processContents = (lax | skip | strict) : strict
|
|
642 |
attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
|
|
643 |
fEleAttrsMapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, attrList);
|
|
644 |
|
|
645 |
// for element "complexContent" - local
|
|
646 |
attrList = Container.getContainer(2);
|
|
647 |
// id = ID
|
|
648 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
649 |
// mixed = boolean
|
|
650 |
attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_N]);
|
|
651 |
fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXCONTENT, attrList);
|
|
652 |
|
|
653 |
// for element "attributeGroup" - global
|
|
654 |
attrList = Container.getContainer(2);
|
|
655 |
// id = ID
|
|
656 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
657 |
// name = NCName
|
|
658 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
659 |
fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, attrList);
|
|
660 |
|
|
661 |
// for element "group" - global
|
|
662 |
attrList = Container.getContainer(2);
|
|
663 |
// id = ID
|
|
664 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
665 |
// name = NCName
|
|
666 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
667 |
fEleAttrsMapG.put(SchemaSymbols.ELT_GROUP, attrList);
|
|
668 |
|
|
669 |
// for element "group" - local ref
|
|
670 |
attrList = Container.getContainer(4);
|
|
671 |
// id = ID
|
|
672 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
673 |
// maxOccurs = (nonNegativeInteger | unbounded) : 1
|
|
674 |
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
|
|
675 |
// minOccurs = nonNegativeInteger : 1
|
|
676 |
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
|
|
677 |
// ref = QName
|
|
678 |
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
|
|
679 |
fEleAttrsMapL.put(SchemaSymbols.ELT_GROUP, attrList);
|
|
680 |
|
|
681 |
// for element "all" - local
|
|
682 |
attrList = Container.getContainer(3);
|
|
683 |
// id = ID
|
|
684 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
685 |
// maxOccurs = 1 : 1
|
|
686 |
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS1_D]);
|
|
687 |
// minOccurs = (0 | 1) : 1
|
|
688 |
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS1_D]);
|
|
689 |
fEleAttrsMapL.put(SchemaSymbols.ELT_ALL, attrList);
|
|
690 |
|
|
691 |
// for element "choice" - local
|
|
692 |
attrList = Container.getContainer(3);
|
|
693 |
// id = ID
|
|
694 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
695 |
// maxOccurs = (nonNegativeInteger | unbounded) : 1
|
|
696 |
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
|
|
697 |
// minOccurs = nonNegativeInteger : 1
|
|
698 |
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
|
|
699 |
fEleAttrsMapL.put(SchemaSymbols.ELT_CHOICE, attrList);
|
|
700 |
// for element "sequence" - local
|
|
701 |
fEleAttrsMapL.put(SchemaSymbols.ELT_SEQUENCE, attrList);
|
|
702 |
|
|
703 |
// for element "any" - local
|
|
704 |
attrList = Container.getContainer(5);
|
|
705 |
// id = ID
|
|
706 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
707 |
// maxOccurs = (nonNegativeInteger | unbounded) : 1
|
|
708 |
attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
|
|
709 |
// minOccurs = nonNegativeInteger : 1
|
|
710 |
attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
|
|
711 |
// namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any
|
|
712 |
attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]);
|
|
713 |
// processContents = (lax | skip | strict) : strict
|
|
714 |
attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
|
|
715 |
fEleAttrsMapL.put(SchemaSymbols.ELT_ANY, attrList);
|
|
716 |
|
|
717 |
// for element "unique" - local
|
|
718 |
attrList = Container.getContainer(2);
|
|
719 |
// id = ID
|
|
720 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
721 |
// name = NCName
|
|
722 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
723 |
fEleAttrsMapL.put(SchemaSymbols.ELT_UNIQUE, attrList);
|
|
724 |
// for element "key" - local
|
|
725 |
fEleAttrsMapL.put(SchemaSymbols.ELT_KEY, attrList);
|
|
726 |
|
|
727 |
// for element "keyref" - local
|
|
728 |
attrList = Container.getContainer(3);
|
|
729 |
// id = ID
|
|
730 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
731 |
// name = NCName
|
|
732 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
733 |
// refer = QName
|
|
734 |
attrList.put(SchemaSymbols.ATT_REFER, allAttrs[ATT_REFER_R]);
|
|
735 |
fEleAttrsMapL.put(SchemaSymbols.ELT_KEYREF, attrList);
|
|
736 |
|
|
737 |
// for element "selector" - local
|
|
738 |
attrList = Container.getContainer(2);
|
|
739 |
// id = ID
|
|
740 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
741 |
// xpath = a subset of XPath expression
|
|
742 |
attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH_R]);
|
|
743 |
fEleAttrsMapL.put(SchemaSymbols.ELT_SELECTOR, attrList);
|
|
744 |
|
|
745 |
// for element "field" - local
|
|
746 |
attrList = Container.getContainer(2);
|
|
747 |
// id = ID
|
|
748 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
749 |
// xpath = a subset of XPath expression
|
|
750 |
attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH1_R]);
|
|
751 |
fEleAttrsMapL.put(SchemaSymbols.ELT_FIELD, attrList);
|
|
752 |
|
|
753 |
// for element "annotation" - global
|
|
754 |
attrList = Container.getContainer(1);
|
|
755 |
// id = ID
|
|
756 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
757 |
fEleAttrsMapG.put(SchemaSymbols.ELT_ANNOTATION, attrList);
|
|
758 |
// for element "annotation" - local
|
|
759 |
fEleAttrsMapL.put(SchemaSymbols.ELT_ANNOTATION, attrList);
|
|
760 |
|
|
761 |
// for element "appinfo" - local
|
|
762 |
attrList = Container.getContainer(1);
|
|
763 |
// source = anyURI
|
|
764 |
attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
|
|
765 |
fEleAttrsMapG.put(SchemaSymbols.ELT_APPINFO, attrList);
|
|
766 |
fEleAttrsMapL.put(SchemaSymbols.ELT_APPINFO, attrList);
|
|
767 |
|
|
768 |
// for element "documentation" - local
|
|
769 |
attrList = Container.getContainer(2);
|
|
770 |
// source = anyURI
|
|
771 |
attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
|
|
772 |
// xml:lang = language
|
|
773 |
attrList.put(SchemaSymbols.ATT_XML_LANG, allAttrs[ATT_XML_LANG]);
|
|
774 |
fEleAttrsMapG.put(SchemaSymbols.ELT_DOCUMENTATION, attrList);
|
|
775 |
fEleAttrsMapL.put(SchemaSymbols.ELT_DOCUMENTATION, attrList);
|
|
776 |
|
|
777 |
// for element "simpleType" - global
|
|
778 |
attrList = Container.getContainer(3);
|
|
779 |
// final = (#all | List of (list | union | restriction))
|
|
780 |
attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
|
|
781 |
// id = ID
|
|
782 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
783 |
// name = NCName
|
|
784 |
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
|
|
785 |
fEleAttrsMapG.put(SchemaSymbols.ELT_SIMPLETYPE, attrList);
|
|
786 |
|
|
787 |
// for element "simpleType" - local
|
|
788 |
attrList = Container.getContainer(2);
|
|
789 |
// final = (#all | List of (list | union | restriction))
|
|
790 |
attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
|
|
791 |
// id = ID
|
|
792 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
793 |
fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLETYPE, attrList);
|
|
794 |
|
|
795 |
// for element "restriction" - local
|
|
796 |
// already registered for complexType
|
|
797 |
|
|
798 |
// for element "list" - local
|
|
799 |
attrList = Container.getContainer(2);
|
|
800 |
// id = ID
|
|
801 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
802 |
// itemType = QName
|
|
803 |
attrList.put(SchemaSymbols.ATT_ITEMTYPE, allAttrs[ATT_ITEMTYPE_N]);
|
|
804 |
fEleAttrsMapL.put(SchemaSymbols.ELT_LIST, attrList);
|
|
805 |
|
|
806 |
// for element "union" - local
|
|
807 |
attrList = Container.getContainer(2);
|
|
808 |
// id = ID
|
|
809 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
810 |
// memberTypes = List of QName
|
|
811 |
attrList.put(SchemaSymbols.ATT_MEMBERTYPES, allAttrs[ATT_MEMBER_T_N]);
|
|
812 |
fEleAttrsMapL.put(SchemaSymbols.ELT_UNION, attrList);
|
|
813 |
|
|
814 |
// for element "schema" - global
|
|
815 |
attrList = Container.getContainer(8);
|
|
816 |
// attributeFormDefault = (qualified | unqualified) : unqualified
|
|
817 |
attrList.put(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT, allAttrs[ATT_ATTRIBUTE_FD_D]);
|
|
818 |
// blockDefault = (#all | List of (extension | restriction | substitution)) : ''
|
|
819 |
attrList.put(SchemaSymbols.ATT_BLOCKDEFAULT, allAttrs[ATT_BLOCK_D_D]);
|
|
820 |
// elementFormDefault = (qualified | unqualified) : unqualified
|
|
821 |
attrList.put(SchemaSymbols.ATT_ELEMENTFORMDEFAULT, allAttrs[ATT_ELEMENT_FD_D]);
|
|
822 |
// finalDefault = (#all | List of (extension | restriction | list | union)) : ''
|
|
823 |
attrList.put(SchemaSymbols.ATT_FINALDEFAULT, allAttrs[ATT_FINAL_D_D]);
|
|
824 |
// id = ID
|
|
825 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
826 |
// targetNamespace = anyURI
|
|
827 |
attrList.put(SchemaSymbols.ATT_TARGETNAMESPACE, allAttrs[ATT_TARGET_N_N]);
|
|
828 |
// version = token
|
|
829 |
attrList.put(SchemaSymbols.ATT_VERSION, allAttrs[ATT_VERSION_N]);
|
|
830 |
// xml:lang = language
|
|
831 |
attrList.put(SchemaSymbols.ATT_XML_LANG, allAttrs[ATT_XML_LANG]);
|
|
832 |
fEleAttrsMapG.put(SchemaSymbols.ELT_SCHEMA, attrList);
|
|
833 |
|
|
834 |
// for element "include" - global
|
|
835 |
attrList = Container.getContainer(2);
|
|
836 |
// id = ID
|
|
837 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
838 |
// schemaLocation = anyURI
|
|
839 |
attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_R]);
|
|
840 |
fEleAttrsMapG.put(SchemaSymbols.ELT_INCLUDE, attrList);
|
|
841 |
// for element "redefine" - global
|
|
842 |
fEleAttrsMapG.put(SchemaSymbols.ELT_REDEFINE, attrList);
|
|
843 |
|
|
844 |
// for element "import" - global
|
|
845 |
attrList = Container.getContainer(3);
|
|
846 |
// id = ID
|
|
847 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
848 |
// namespace = anyURI
|
|
849 |
attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_N]);
|
|
850 |
// schemaLocation = anyURI
|
|
851 |
attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_N]);
|
|
852 |
fEleAttrsMapG.put(SchemaSymbols.ELT_IMPORT, attrList);
|
|
853 |
|
|
854 |
// for element "length" - local
|
|
855 |
attrList = Container.getContainer(3);
|
|
856 |
// id = ID
|
|
857 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
858 |
// value = nonNegativeInteger
|
|
859 |
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_NNI_N]);
|
|
860 |
// fixed = boolean : false
|
|
861 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
|
|
862 |
fEleAttrsMapL.put(SchemaSymbols.ELT_LENGTH, attrList);
|
|
863 |
// for element "minLength" - local
|
|
864 |
fEleAttrsMapL.put(SchemaSymbols.ELT_MINLENGTH, attrList);
|
|
865 |
// for element "maxLength" - local
|
|
866 |
fEleAttrsMapL.put(SchemaSymbols.ELT_MAXLENGTH, attrList);
|
|
867 |
// for element "fractionDigits" - local
|
|
868 |
fEleAttrsMapL.put(SchemaSymbols.ELT_FRACTIONDIGITS, attrList);
|
|
869 |
|
|
870 |
// for element "totalDigits" - local
|
|
871 |
attrList = Container.getContainer(3);
|
|
872 |
// id = ID
|
|
873 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
874 |
// value = positiveInteger
|
|
875 |
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_PI_N]);
|
|
876 |
// fixed = boolean : false
|
|
877 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
|
|
878 |
fEleAttrsMapL.put(SchemaSymbols.ELT_TOTALDIGITS, attrList);
|
|
879 |
|
|
880 |
// for element "pattern" - local
|
|
881 |
attrList = Container.getContainer(2);
|
|
882 |
// id = ID
|
|
883 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
884 |
// value = string
|
|
885 |
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
|
|
886 |
fEleAttrsMapL.put(SchemaSymbols.ELT_PATTERN, attrList);
|
|
887 |
|
|
888 |
// for element "enumeration" - local
|
|
889 |
attrList = Container.getContainer(2);
|
|
890 |
// id = ID
|
|
891 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
892 |
// value = anySimpleType
|
|
893 |
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
|
|
894 |
fEleAttrsMapL.put(SchemaSymbols.ELT_ENUMERATION, attrList);
|
|
895 |
|
|
896 |
// for element "whiteSpace" - local
|
|
897 |
attrList = Container.getContainer(3);
|
|
898 |
// id = ID
|
|
899 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
900 |
// value = preserve | replace | collapse
|
|
901 |
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_WS_N]);
|
|
902 |
// fixed = boolean : false
|
|
903 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
|
|
904 |
fEleAttrsMapL.put(SchemaSymbols.ELT_WHITESPACE, attrList);
|
|
905 |
|
|
906 |
// for element "maxInclusive" - local
|
|
907 |
attrList = Container.getContainer(3);
|
|
908 |
// id = ID
|
|
909 |
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
|
|
910 |
// value = anySimpleType
|
|
911 |
attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
|
|
912 |
// fixed = boolean : false
|
|
913 |
attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
|
|
914 |
fEleAttrsMapL.put(SchemaSymbols.ELT_MAXINCLUSIVE, attrList);
|
|
915 |
// for element "maxExclusive" - local
|
|
916 |
fEleAttrsMapL.put(SchemaSymbols.ELT_MAXEXCLUSIVE, attrList);
|
|
917 |
// for element "minInclusive" - local
|
|
918 |
fEleAttrsMapL.put(SchemaSymbols.ELT_MININCLUSIVE, attrList);
|
|
919 |
// for element "minExclusive" - local
|
|
920 |
fEleAttrsMapL.put(SchemaSymbols.ELT_MINEXCLUSIVE, attrList);
|
|
921 |
}
|
|
922 |
|
|
923 |
// used to resolver namespace prefixes
|
|
924 |
protected XSDHandler fSchemaHandler = null;
|
|
925 |
|
|
926 |
// used to store symbols.
|
|
927 |
protected SymbolTable fSymbolTable = null;
|
|
928 |
|
|
929 |
// used to store the mapping from processed element to attributes
|
|
930 |
protected Map fNonSchemaAttrs = new HashMap();
|
|
931 |
|
|
932 |
// temprory vector, used to hold the namespace list
|
|
933 |
protected Vector fNamespaceList = new Vector();
|
|
934 |
|
|
935 |
// whether this attribute appeared in the current element
|
|
936 |
protected boolean[] fSeen = new boolean[ATTIDX_COUNT];
|
|
937 |
private static boolean[] fSeenTemp = new boolean[ATTIDX_COUNT];
|
|
938 |
|
|
939 |
// constructor. Sets fErrorReproter and get datatype validators
|
|
940 |
public XSAttributeChecker(XSDHandler schemaHandler) {
|
|
941 |
fSchemaHandler = schemaHandler;
|
|
942 |
}
|
|
943 |
|
|
944 |
public void reset(SymbolTable symbolTable) {
|
|
945 |
fSymbolTable = symbolTable;
|
|
946 |
fNonSchemaAttrs.clear();
|
|
947 |
}
|
|
948 |
|
|
949 |
/**
|
|
950 |
* Check whether the specified element conforms to the attributes restriction
|
|
951 |
* an array of attribute values is returned. the caller must call
|
|
952 |
* <code>returnAttrArray</code> to return that array.
|
|
953 |
*
|
|
954 |
* @param element which element to check
|
|
955 |
* @param isGlobal whether a child of <schema> or <redefine>
|
|
956 |
* @param schemaDoc the document where the element lives in
|
|
957 |
* @return an array containing attribute values
|
|
958 |
*/
|
|
959 |
public Object[] checkAttributes(Element element, boolean isGlobal,
|
|
960 |
XSDocumentInfo schemaDoc) {
|
|
961 |
return checkAttributes(element, isGlobal, schemaDoc, false);
|
|
962 |
}
|
|
963 |
|
|
964 |
/**
|
|
965 |
* Check whether the specified element conforms to the attributes restriction
|
|
966 |
* an array of attribute values is returned. the caller must call
|
|
967 |
* <code>returnAttrArray</code> to return that array. This method also takes
|
|
968 |
* an extra parameter: if the element is "enumeration", whether to make a
|
|
969 |
* copy of the namespace context, so that the value can be resolved as a
|
|
970 |
* QName later.
|
|
971 |
*
|
|
972 |
* @param element which element to check
|
|
973 |
* @param isGlobal whether a child of <schema> or <redefine>
|
|
974 |
* @param schemaDoc the document where the element lives in
|
|
975 |
* @param enumAsQName whether to tread enumeration value as QName
|
|
976 |
* @return an array containing attribute values
|
|
977 |
*/
|
|
978 |
public Object[] checkAttributes(Element element, boolean isGlobal,
|
|
979 |
XSDocumentInfo schemaDoc, boolean enumAsQName) {
|
|
980 |
if (element == null)
|
|
981 |
return null;
|
|
982 |
|
|
983 |
// get all attributes
|
|
984 |
Attr[] attrs = DOMUtil.getAttrs(element);
|
|
985 |
|
|
986 |
// update NamespaceSupport
|
|
987 |
resolveNamespace(element, attrs, schemaDoc.fNamespaceSupport);
|
|
988 |
|
|
989 |
String uri = DOMUtil.getNamespaceURI(element);
|
|
990 |
String elName = DOMUtil.getLocalName(element);
|
|
991 |
|
|
992 |
if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(uri)) {
|
|
993 |
reportSchemaError("s4s-elt-schema-ns", new Object[] {elName}, element);
|
|
994 |
}
|
|
995 |
|
|
996 |
Map eleAttrsMap = fEleAttrsMapG;
|
|
997 |
String lookupName = elName;
|
|
998 |
|
|
999 |
// REVISIT: only local element and attribute are different from others.
|
|
1000 |
// it's possible to have either name or ref. all the others
|
|
1001 |
// are only allowed to have one of name or ref, or neither of them.
|
|
1002 |
// we'd better move such checking to the traverser.
|
|
1003 |
if (!isGlobal) {
|
|
1004 |
eleAttrsMap = fEleAttrsMapL;
|
|
1005 |
if (elName.equals(SchemaSymbols.ELT_ELEMENT)) {
|
|
1006 |
if (DOMUtil.getAttr(element, SchemaSymbols.ATT_REF) != null)
|
|
1007 |
lookupName = ELEMENT_R;
|
|
1008 |
else
|
|
1009 |
lookupName = ELEMENT_N;
|
|
1010 |
} else if (elName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
|
|
1011 |
if (DOMUtil.getAttr(element, SchemaSymbols.ATT_REF) != null)
|
|
1012 |
lookupName = ATTRIBUTE_R;
|
|
1013 |
else
|
|
1014 |
lookupName = ATTRIBUTE_N;
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
// get desired attribute list of this element
|
|
1019 |
Container attrList = (Container)eleAttrsMap.get(lookupName);
|
|
1020 |
if (attrList == null) {
|
|
1021 |
// should never gets here.
|
|
1022 |
// when this method is called, the call already knows that
|
|
1023 |
// the element can appear.
|
|
1024 |
reportSchemaError ("s4s-elt-invalid", new Object[] {elName}, element);
|
|
1025 |
return null;
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
//Hashtable attrValues = new Hashtable();
|
|
1029 |
Object[] attrValues = getAvailableArray();
|
|
1030 |
//Hashtable otherValues = new Hashtable();
|
|
1031 |
long fromDefault = 0;
|
|
1032 |
|
|
1033 |
// clear the "seen" flag.
|
|
1034 |
System.arraycopy(fSeenTemp, 0, fSeen, 0, ATTIDX_COUNT);
|
|
1035 |
|
|
1036 |
// traverse all attributes
|
|
1037 |
int length = attrs.length;
|
|
1038 |
Attr sattr = null;
|
|
1039 |
for (int i = 0; i < length; i++) {
|
|
1040 |
sattr = attrs[i];
|
|
1041 |
// get the attribute name/value
|
|
1042 |
//String attrName = DOMUtil.getLocalName(sattr);
|
|
1043 |
String attrName = sattr.getName();
|
|
1044 |
String attrURI = DOMUtil.getNamespaceURI(sattr);
|
|
1045 |
String attrVal = DOMUtil.getValue(sattr);
|
|
1046 |
|
|
1047 |
if (attrName.startsWith("xml")) {
|
|
1048 |
String attrPrefix = DOMUtil.getPrefix(sattr);
|
|
1049 |
// we don't want to add namespace declarations to the non-schema attributes
|
|
1050 |
if ("xmlns".equals(attrPrefix) || "xmlns".equals(attrName)) {
|
|
1051 |
continue;
|
|
1052 |
}
|
|
1053 |
// Both <schema> and <documentation> may have an xml:lang attribute.
|
|
1054 |
// Set the URI for this attribute to null so that we process it
|
|
1055 |
// like any other schema attribute.
|
|
1056 |
else if (SchemaSymbols.ATT_XML_LANG.equals(attrName) &&
|
|
1057 |
(SchemaSymbols.ELT_SCHEMA.equals(elName) ||
|
|
1058 |
SchemaSymbols.ELT_DOCUMENTATION.equals(elName))) {
|
|
1059 |
attrURI = null;
|
|
1060 |
}
|
|
1061 |
}
|
|
1062 |
|
|
1063 |
// for attributes with namespace prefix
|
|
1064 |
//
|
|
1065 |
if (attrURI != null && attrURI.length() != 0) {
|
|
1066 |
// attributes with schema namespace are not allowed
|
|
1067 |
// and not allowed on "document" and "appInfo"
|
|
1068 |
if (attrURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) {
|
|
1069 |
reportSchemaError ("s4s-att-not-allowed", new Object[] {elName, attrName}, element);
|
|
1070 |
}
|
|
1071 |
else {
|
|
1072 |
if(attrValues[ATTIDX_NONSCHEMA] == null) {
|
|
1073 |
// these are usually small
|
|
1074 |
attrValues[ATTIDX_NONSCHEMA] = new Vector(4,2);
|
|
1075 |
}
|
|
1076 |
((Vector)attrValues[ATTIDX_NONSCHEMA]).addElement(attrName);
|
|
1077 |
((Vector)attrValues[ATTIDX_NONSCHEMA]).addElement(attrVal);
|
|
1078 |
// for attributes from other namespace
|
|
1079 |
// store them in a list, and TRY to validate them after
|
|
1080 |
// schema traversal (because it's "lax")
|
|
1081 |
//otherValues.put(attrName, attrVal);
|
|
1082 |
// REVISIT: actually use this some day...
|
|
1083 |
// String attrRName = attrURI + "," + attrName;
|
|
1084 |
// Vector values = (Vector)fNonSchemaAttrs.get(attrRName);
|
|
1085 |
// if (values == null) {
|
|
1086 |
// values = new Vector();
|
|
1087 |
// values.addElement(attrName);
|
|
1088 |
// values.addElement(elName);
|
|
1089 |
// values.addElement(attrVal);
|
|
1090 |
// fNonSchemaAttrs.put(attrRName, values);
|
|
1091 |
// }
|
|
1092 |
// else {
|
|
1093 |
// values.addElement(elName);
|
|
1094 |
// values.addElement(attrVal);
|
|
1095 |
// }
|
|
1096 |
}
|
|
1097 |
continue;
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// check whether this attribute is allowed
|
|
1101 |
OneAttr oneAttr = attrList.get(attrName);
|
|
1102 |
if (oneAttr == null) {
|
|
1103 |
reportSchemaError ("s4s-att-not-allowed",
|
|
1104 |
new Object[] {elName, attrName},
|
|
1105 |
element);
|
|
1106 |
continue;
|
|
1107 |
}
|
|
1108 |
|
|
1109 |
// we've seen this attribute
|
|
1110 |
fSeen[oneAttr.valueIndex] = true;
|
|
1111 |
|
|
1112 |
// check the value against the datatype
|
|
1113 |
try {
|
|
1114 |
// no checking on string needs to be done here.
|
|
1115 |
// no checking on xpath needs to be done here.
|
|
1116 |
// xpath values are validated in xpath parser
|
|
1117 |
if (oneAttr.dvIndex >= 0) {
|
|
1118 |
if (oneAttr.dvIndex != DT_STRING &&
|
|
1119 |
oneAttr.dvIndex != DT_XPATH &&
|
|
1120 |
oneAttr.dvIndex != DT_XPATH1) {
|
|
1121 |
XSSimpleType dv = fExtraDVs[oneAttr.dvIndex];
|
|
1122 |
Object avalue = dv.validate(attrVal, schemaDoc.fValidationContext, null);
|
|
1123 |
// kludge to handle chameleon includes/redefines...
|
|
1124 |
if (oneAttr.dvIndex == DT_QNAME) {
|
|
1125 |
QName qname = (QName)avalue;
|
|
1126 |
if(qname.prefix == XMLSymbols.EMPTY_STRING && qname.uri == null && schemaDoc.fIsChameleonSchema)
|
|
1127 |
qname.uri = schemaDoc.fTargetNamespace;
|
|
1128 |
}
|
|
1129 |
attrValues[oneAttr.valueIndex] = avalue;
|
|
1130 |
} else {
|
|
1131 |
attrValues[oneAttr.valueIndex] = attrVal;
|
|
1132 |
}
|
|
1133 |
}
|
|
1134 |
else {
|
|
1135 |
attrValues[oneAttr.valueIndex] = validate(attrValues, attrName, attrVal, oneAttr.dvIndex, schemaDoc);
|
|
1136 |
}
|
|
1137 |
} catch (InvalidDatatypeValueException ide) {
|
|
1138 |
reportSchemaError ("s4s-att-invalid-value",
|
|
1139 |
new Object[] {elName, attrName, ide.getMessage()},
|
|
1140 |
element);
|
|
1141 |
if (oneAttr.dfltValue != null)
|
|
1142 |
//attrValues.put(attrName, oneAttr.dfltValue);
|
|
1143 |
attrValues[oneAttr.valueIndex] = oneAttr.dfltValue;
|
|
1144 |
}
|
|
1145 |
|
|
1146 |
// For "enumeration", and type is possible to be a QName, we need
|
|
1147 |
// to return namespace context for later QName resolution.
|
|
1148 |
if (elName.equals(SchemaSymbols.ELT_ENUMERATION) && enumAsQName) {
|
|
1149 |
attrValues[ATTIDX_ENUMNSDECLS] = new SchemaNamespaceSupport(schemaDoc.fNamespaceSupport);
|
|
1150 |
}
|
|
1151 |
}
|
|
1152 |
|
|
1153 |
// apply default values
|
|
1154 |
OneAttr[] reqAttrs = attrList.values;
|
|
1155 |
for (int i = 0; i < reqAttrs.length; i++) {
|
|
1156 |
OneAttr oneAttr = reqAttrs[i];
|
|
1157 |
|
|
1158 |
// if the attribute didn't apprear, and
|
|
1159 |
// if the attribute is optional with default value, apply it
|
|
1160 |
if (oneAttr.dfltValue != null && !fSeen[oneAttr.valueIndex]) {
|
|
1161 |
//attrValues.put(oneAttr.name, oneAttr.dfltValue);
|
|
1162 |
attrValues[oneAttr.valueIndex] = oneAttr.dfltValue;
|
|
1163 |
fromDefault |= (1<<oneAttr.valueIndex);
|
|
1164 |
}
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
attrValues[ATTIDX_FROMDEFAULT] = new Long(fromDefault);
|
|
1168 |
//attrValues[ATTIDX_OTHERVALUES] = otherValues;
|
|
1169 |
|
|
1170 |
// Check that minOccurs isn't greater than maxOccurs.
|
|
1171 |
// p-props-correct 2.1
|
|
1172 |
if (attrValues[ATTIDX_MAXOCCURS] != null) {
|
|
1173 |
int min = ((XInt)attrValues[ATTIDX_MINOCCURS]).intValue();
|
|
1174 |
int max = ((XInt)attrValues[ATTIDX_MAXOCCURS]).intValue();
|
|
1175 |
if (max != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
|
|
1176 |
|
|
1177 |
// maxOccurLimit is only check in secure mode
|
|
1178 |
if (fSchemaHandler.fSecureProcessing != null) {
|
|
1179 |
String localName = element.getLocalName();
|
|
1180 |
|
|
1181 |
// The maxOccurs restriction no longer applies to elements
|
|
1182 |
// and wildcards in a sequence in which they are the only
|
|
1183 |
// particle. These are now validated using a constant
|
|
1184 |
// space algorithm. The restriction still applies to all
|
|
1185 |
// other cases.
|
|
1186 |
|
|
1187 |
// Determine if constant-space algorithm can be applied
|
|
1188 |
final boolean optimize =
|
|
1189 |
(localName.equals("element") || localName.equals("any")) &&
|
|
1190 |
(element.getNextSibling() == null) &&
|
|
1191 |
(element.getPreviousSibling() == null) &&
|
|
1192 |
(element.getParentNode().getLocalName().equals("sequence"));
|
|
1193 |
|
|
1194 |
if (!optimize) {
|
|
1195 |
//Revisit :: IMO this is not right place to check
|
|
1196 |
// maxOccurNodeLimit.
|
|
1197 |
int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getMaxOccurNodeLimit();
|
|
1198 |
if (max > maxOccurNodeLimit) {
|
|
1199 |
reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
|
|
1200 |
|
|
1201 |
// reset max values in case processing continues on error
|
|
1202 |
attrValues[ATTIDX_MAXOCCURS] = fXIntPool.getXInt(maxOccurNodeLimit);
|
|
1203 |
//new Integer(maxOccurNodeLimit);
|
|
1204 |
max = maxOccurNodeLimit;
|
|
1205 |
}
|
|
1206 |
}
|
|
1207 |
}
|
|
1208 |
|
|
1209 |
if (min > max) {
|
|
1210 |
reportSchemaError ("p-props-correct.2.1",
|
|
1211 |
new Object[] {elName, attrValues[ATTIDX_MINOCCURS], attrValues[ATTIDX_MAXOCCURS]},
|
|
1212 |
element);
|
|
1213 |
attrValues[ATTIDX_MINOCCURS] = attrValues[ATTIDX_MAXOCCURS];
|
|
1214 |
}
|
|
1215 |
}
|
|
1216 |
}
|
|
1217 |
|
|
1218 |
return attrValues;
|
|
1219 |
}
|
|
1220 |
|
|
1221 |
private Object validate(Object[] attrValues, String attr, String ivalue, int dvIndex,
|
|
1222 |
XSDocumentInfo schemaDoc) throws InvalidDatatypeValueException {
|
|
1223 |
if (ivalue == null)
|
|
1224 |
return null;
|
|
1225 |
|
|
1226 |
// To validate these types, we don't actually need to normalize the
|
|
1227 |
// strings. We only need to remove the whitespace from both ends.
|
|
1228 |
// In some special cases (list types), StringTokenizer can correctly
|
|
1229 |
// process the un-normalized whitespace.
|
|
1230 |
|
|
1231 |
String value = XMLChar.trim(ivalue);
|
|
1232 |
Object retValue = null;
|
|
1233 |
Vector memberType;
|
|
1234 |
int choice;
|
|
1235 |
|
|
1236 |
switch (dvIndex) {
|
|
1237 |
case DT_BOOLEAN:
|
|
1238 |
if (value.equals(SchemaSymbols.ATTVAL_FALSE) ||
|
|
1239 |
value.equals(SchemaSymbols.ATTVAL_FALSE_0)) {
|
|
1240 |
retValue = Boolean.FALSE;
|
|
1241 |
} else if (value.equals(SchemaSymbols.ATTVAL_TRUE) ||
|
|
1242 |
value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
|
|
1243 |
retValue = Boolean.TRUE;
|
|
1244 |
} else {
|
|
1245 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{value, "boolean"});
|
|
1246 |
}
|
|
1247 |
break;
|
|
1248 |
case DT_NONNEGINT:
|
|
1249 |
try {
|
|
1250 |
if (value.length() > 0 && value.charAt(0) == '+')
|
|
1251 |
value = value.substring(1);
|
|
1252 |
retValue = fXIntPool.getXInt(Integer.parseInt(value));
|
|
1253 |
} catch (NumberFormatException e) {
|
|
1254 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{value, "nonNegativeInteger"});
|
|
1255 |
}
|
|
1256 |
if (((XInt)retValue).intValue() < 0)
|
|
1257 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{value, "nonNegativeInteger"});
|
|
1258 |
break;
|
|
1259 |
case DT_POSINT:
|
|
1260 |
try {
|
|
1261 |
if (value.length() > 0 && value.charAt(0) == '+')
|
|
1262 |
value = value.substring(1);
|
|
1263 |
retValue = fXIntPool.getXInt(Integer.parseInt(value));
|
|
1264 |
} catch (NumberFormatException e) {
|
|
1265 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{value, "positiveInteger"});
|
|
1266 |
}
|
|
1267 |
if (((XInt)retValue).intValue() <= 0)
|
|
1268 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{value, "positiveInteger"});
|
|
1269 |
break;
|
|
1270 |
case DT_BLOCK:
|
|
1271 |
// block = (#all | List of (extension | restriction | substitution))
|
|
1272 |
choice = 0;
|
|
1273 |
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
|
|
1274 |
choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
|
|
1275 |
XSConstants.DERIVATION_RESTRICTION;
|
|
1276 |
}
|
|
1277 |
else {
|
|
1278 |
StringTokenizer t = new StringTokenizer(value, " \n\t\r");
|
|
1279 |
while (t.hasMoreTokens()) {
|
|
1280 |
String token = t.nextToken ();
|
|
1281 |
|
|
1282 |
if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
|
|
1283 |
choice |= XSConstants.DERIVATION_EXTENSION;
|
|
1284 |
}
|
|
1285 |
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
|
|
1286 |
choice |= XSConstants.DERIVATION_RESTRICTION;
|
|
1287 |
}
|
|
1288 |
else if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION)) {
|
|
1289 |
choice |= XSConstants.DERIVATION_SUBSTITUTION;
|
|
1290 |
}
|
|
1291 |
else {
|
|
1292 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (extension | restriction | substitution))"});
|
|
1293 |
}
|
|
1294 |
}
|
|
1295 |
}
|
|
1296 |
retValue = fXIntPool.getXInt(choice);
|
|
1297 |
break;
|
|
1298 |
case DT_BLOCK1:
|
|
1299 |
case DT_FINAL:
|
|
1300 |
// block = (#all | List of (extension | restriction))
|
|
1301 |
// final = (#all | List of (extension | restriction))
|
|
1302 |
choice = 0;
|
|
1303 |
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
|
|
1304 |
//choice = SchemaSymbols.EXTENSION|SchemaSymbols.RESTRICTION;
|
|
1305 |
// REVISIT: if #all, then make the result the combination of
|
|
1306 |
// everything: substitution/externsion/restriction/list/union.
|
|
1307 |
// would this be a problem?
|
|
1308 |
// the reason doing so is that when final/blockFinal on <schema>
|
|
1309 |
// is #all, it's not always the same as the conbination of those
|
|
1310 |
// values allowed by final/blockFinal.
|
|
1311 |
// for example, finalDefault="#all" is not always the same as
|
|
1312 |
// finalDefault="extension restriction".
|
|
1313 |
// if finalDefault="#all", final on any simple type would be
|
|
1314 |
// "extension restriction list union".
|
|
1315 |
choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
|
|
1316 |
XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST|
|
|
1317 |
XSConstants.DERIVATION_UNION;
|
|
1318 |
}
|
|
1319 |
else {
|
|
1320 |
StringTokenizer t = new StringTokenizer(value, " \n\t\r");
|
|
1321 |
while (t.hasMoreTokens()) {
|
|
1322 |
String token = t.nextToken ();
|
|
1323 |
|
|
1324 |
if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
|
|
1325 |
choice |= XSConstants.DERIVATION_EXTENSION;
|
|
1326 |
}
|
|
1327 |
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
|
|
1328 |
choice |= XSConstants.DERIVATION_RESTRICTION;
|
|
1329 |
}
|
|
1330 |
else {
|
|
1331 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (extension | restriction))"});
|
|
1332 |
}
|
|
1333 |
}
|
|
1334 |
}
|
|
1335 |
retValue = fXIntPool.getXInt(choice);
|
|
1336 |
break;
|
|
1337 |
case DT_FINAL1:
|
|
1338 |
// final = (#all | List of (list | union | restriction))
|
|
1339 |
choice = 0;
|
|
1340 |
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
|
|
1341 |
//choice = SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
|
|
1342 |
// SchemaSymbols.UNION;
|
|
1343 |
// REVISIT: if #all, then make the result the combination of
|
|
1344 |
// everything: substitution/externsion/restriction/list/union.
|
|
1345 |
// would this be a problem?
|
|
1346 |
// same reason as above DT_BLOCK1/DT_FINAL
|
|
1347 |
choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
|
|
1348 |
XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST|
|
|
1349 |
XSConstants.DERIVATION_UNION;
|
|
1350 |
}
|
|
1351 |
else {
|
|
1352 |
StringTokenizer t = new StringTokenizer(value, " \n\t\r");
|
|
1353 |
while (t.hasMoreTokens()) {
|
|
1354 |
String token = t.nextToken ();
|
|
1355 |
|
|
1356 |
if (token.equals (SchemaSymbols.ATTVAL_LIST)) {
|
|
1357 |
choice |= XSConstants.DERIVATION_LIST;
|
|
1358 |
}
|
|
1359 |
else if (token.equals (SchemaSymbols.ATTVAL_UNION)) {
|
|
1360 |
choice |= XSConstants.DERIVATION_UNION;
|
|
1361 |
}
|
|
1362 |
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
|
|
1363 |
choice |= XSConstants.DERIVATION_RESTRICTION;
|
|
1364 |
}
|
|
1365 |
else {
|
|
1366 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (list | union | restriction))"});
|
|
1367 |
}
|
|
1368 |
}
|
|
1369 |
}
|
|
1370 |
retValue = fXIntPool.getXInt(choice);
|
|
1371 |
break;
|
|
1372 |
case DT_FINAL2:
|
|
1373 |
// finalDefault = (#all | List of (extension | restriction | list | union))
|
|
1374 |
choice = 0;
|
|
1375 |
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
|
|
1376 |
//choice = SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
|
|
1377 |
// SchemaSymbols.UNION;
|
|
1378 |
// REVISIT: if #all, then make the result the combination of
|
|
1379 |
// everything: substitution/externsion/restriction/list/union.
|
|
1380 |
// would this be a problem?
|
|
1381 |
// same reason as above DT_BLOCK1/DT_FINAL
|
|
1382 |
choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
|
|
1383 |
XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST|
|
|
1384 |
XSConstants.DERIVATION_UNION;
|
|
1385 |
}
|
|
1386 |
else {
|
|
1387 |
StringTokenizer t = new StringTokenizer(value, " \n\t\r");
|
|
1388 |
while (t.hasMoreTokens()) {
|
|
1389 |
String token = t.nextToken ();
|
|
1390 |
|
|
1391 |
if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
|
|
1392 |
choice |= XSConstants.DERIVATION_EXTENSION;
|
|
1393 |
}
|
|
1394 |
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
|
|
1395 |
choice |= XSConstants.DERIVATION_RESTRICTION;
|
|
1396 |
}
|
|
1397 |
else if (token.equals (SchemaSymbols.ATTVAL_LIST)) {
|
|
1398 |
choice |= XSConstants.DERIVATION_LIST;
|
|
1399 |
}
|
|
1400 |
else if (token.equals (SchemaSymbols.ATTVAL_UNION)) {
|
|
1401 |
choice |= XSConstants.DERIVATION_UNION;
|
|
1402 |
}
|
|
1403 |
else {
|
|
1404 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (extension | restriction | list | union))"});
|
|
1405 |
}
|
|
1406 |
}
|
|
1407 |
}
|
|
1408 |
retValue = fXIntPool.getXInt(choice);
|
|
1409 |
break;
|
|
1410 |
case DT_FORM:
|
|
1411 |
// form = (qualified | unqualified)
|
|
1412 |
if (value.equals (SchemaSymbols.ATTVAL_QUALIFIED))
|
|
1413 |
retValue = INT_QUALIFIED;
|
|
1414 |
else if (value.equals (SchemaSymbols.ATTVAL_UNQUALIFIED))
|
|
1415 |
retValue = INT_UNQUALIFIED;
|
|
1416 |
else
|
|
1417 |
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
|
|
1418 |
new Object[]{value, "(qualified | unqualified)"});
|
|
1419 |
break;
|
|
1420 |
case DT_MAXOCCURS:
|
|
1421 |
// maxOccurs = (nonNegativeInteger | unbounded)
|
|
1422 |
if (value.equals(SchemaSymbols.ATTVAL_UNBOUNDED)) {
|
|
1423 |
retValue = INT_UNBOUNDED;
|
|
1424 |
} else {
|
|
1425 |
try {
|
|
1426 |
retValue = validate(attrValues, attr, value, DT_NONNEGINT, schemaDoc);
|
|
1427 |
} catch (NumberFormatException e) {
|
|
1428 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(nonNegativeInteger | unbounded)"});
|
|
1429 |
}
|
|
1430 |
}
|
|
1431 |
break;
|
|
1432 |
case DT_MAXOCCURS1:
|
|
1433 |
// maxOccurs = 1
|
|
1434 |
if (value.equals("1"))
|
|
1435 |
retValue = fXIntPool.getXInt(1);
|
|
1436 |
else
|
|
1437 |
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
|
|
1438 |
new Object[]{value, "(1)"});
|
|
1439 |
break;
|
|
1440 |
case DT_MEMBERTYPES:
|
|
1441 |
// memberTypes = List of QName
|
|
1442 |
memberType = new Vector();
|
|
1443 |
try {
|
|
1444 |
StringTokenizer t = new StringTokenizer(value, " \n\t\r");
|
|
1445 |
while (t.hasMoreTokens()) {
|
|
1446 |
String token = t.nextToken ();
|
|
1447 |
QName qname = (QName)fExtraDVs[DT_QNAME].validate(token, schemaDoc.fValidationContext, null);
|
|
1448 |
// kludge to handle chameleon includes/redefines...
|
|
1449 |
if(qname.prefix == XMLSymbols.EMPTY_STRING && qname.uri == null && schemaDoc.fIsChameleonSchema)
|
|
1450 |
qname.uri = schemaDoc.fTargetNamespace;
|
|
1451 |
memberType.addElement(qname);
|
|
1452 |
}
|
|
1453 |
retValue = memberType;
|
|
1454 |
}
|
|
1455 |
catch (InvalidDatatypeValueException ide) {
|
|
1456 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.2", new Object[]{value, "(List of QName)"});
|
|
1457 |
}
|
|
1458 |
break;
|
|
1459 |
case DT_MINOCCURS1:
|
|
1460 |
// minOccurs = (0 | 1)
|
|
1461 |
if (value.equals("0"))
|
|
1462 |
retValue = fXIntPool.getXInt(0);
|
|
1463 |
else if (value.equals("1"))
|
|
1464 |
retValue = fXIntPool.getXInt(1);
|
|
1465 |
else
|
|
1466 |
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
|
|
1467 |
new Object[]{value, "(0 | 1)"});
|
|
1468 |
break;
|
|
1469 |
case DT_NAMESPACE:
|
|
1470 |
// namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
|
|
1471 |
if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDANY)) {
|
|
1472 |
// ##any
|
|
1473 |
retValue = INT_ANY_ANY;
|
|
1474 |
} else if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDOTHER)) {
|
|
1475 |
// ##other
|
|
1476 |
retValue = INT_ANY_NOT;
|
|
1477 |
String[] list = new String[2];
|
|
1478 |
list[0] = schemaDoc.fTargetNamespace;
|
|
1479 |
list[1] = null;
|
|
1480 |
attrValues[ATTIDX_NAMESPACE_LIST] = list;
|
|
1481 |
} else {
|
|
1482 |
// list
|
|
1483 |
retValue = INT_ANY_LIST;
|
|
1484 |
|
|
1485 |
fNamespaceList.removeAllElements();
|
|
1486 |
|
|
1487 |
// tokenize
|
|
1488 |
StringTokenizer tokens = new StringTokenizer(value, " \n\t\r");
|
|
1489 |
String token;
|
|
1490 |
String tempNamespace;
|
|
1491 |
try {
|
|
1492 |
while (tokens.hasMoreTokens()) {
|
|
1493 |
token = tokens.nextToken();
|
|
1494 |
if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) {
|
|
1495 |
tempNamespace = null;
|
|
1496 |
} else if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS)) {
|
|
1497 |
tempNamespace = schemaDoc.fTargetNamespace;
|
|
1498 |
} else {
|
|
1499 |
// we have found namespace URI here
|
|
1500 |
// need to add it to the symbol table
|
|
1501 |
fExtraDVs[DT_ANYURI].validate(token, schemaDoc.fValidationContext, null);
|
|
1502 |
tempNamespace = fSymbolTable.addSymbol(token);
|
|
1503 |
}
|
|
1504 |
|
|
1505 |
//check for duplicate namespaces in the list
|
|
1506 |
if (!fNamespaceList.contains(tempNamespace)) {
|
|
1507 |
fNamespaceList.addElement(tempNamespace);
|
|
1508 |
}
|
|
1509 |
}
|
|
1510 |
} catch (InvalidDatatypeValueException ide) {
|
|
1511 |
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )"});
|
|
1512 |
}
|
|
1513 |
|
|
1514 |
// convert the vector to an array
|
|
1515 |
int num = fNamespaceList.size();
|
|
1516 |
String[] list = new String[num];
|
|
1517 |
fNamespaceList.copyInto(list);
|
|
1518 |
attrValues[ATTIDX_NAMESPACE_LIST] = list;
|
|
1519 |
}
|
|
1520 |
break;
|
|
1521 |
case DT_PROCESSCONTENTS:
|
|
1522 |
// processContents = (lax | skip | strict)
|
|
1523 |
if (value.equals (SchemaSymbols.ATTVAL_STRICT))
|
|
1524 |
retValue = INT_ANY_STRICT;
|
|
1525 |
else if (value.equals (SchemaSymbols.ATTVAL_LAX))
|
|
1526 |
retValue = INT_ANY_LAX;
|
|
1527 |
else if (value.equals (SchemaSymbols.ATTVAL_SKIP))
|
|
1528 |
retValue = INT_ANY_SKIP;
|
|
1529 |
else
|
|
1530 |
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
|
|
1531 |
new Object[]{value, "(lax | skip | strict)"});
|
|
1532 |
break;
|
|
1533 |
case DT_USE:
|
|
1534 |
// use = (optional | prohibited | required)
|
|
1535 |
if (value.equals (SchemaSymbols.ATTVAL_OPTIONAL))
|
|
1536 |
retValue = INT_USE_OPTIONAL;
|
|
1537 |
else if (value.equals (SchemaSymbols.ATTVAL_REQUIRED))
|
|
1538 |
retValue = INT_USE_REQUIRED;
|
|
1539 |
else if (value.equals (SchemaSymbols.ATTVAL_PROHIBITED))
|
|
1540 |
retValue = INT_USE_PROHIBITED;
|
|
1541 |
else
|
|
1542 |
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
|
|
1543 |
new Object[]{value, "(optional | prohibited | required)"});
|
|
1544 |
break;
|
|
1545 |
case DT_WHITESPACE:
|
|
1546 |
// value = preserve | replace | collapse
|
|
1547 |
if (value.equals (SchemaSymbols.ATTVAL_PRESERVE))
|
|
1548 |
retValue = INT_WS_PRESERVE;
|
|
1549 |
else if (value.equals (SchemaSymbols.ATTVAL_REPLACE))
|
|
1550 |
retValue = INT_WS_REPLACE;
|
|
1551 |
else if (value.equals (SchemaSymbols.ATTVAL_COLLAPSE))
|
|
1552 |
retValue = INT_WS_COLLAPSE;
|
|
1553 |
else
|
|
1554 |
throw new InvalidDatatypeValueException("cvc-enumeration-valid",
|
|
1555 |
new Object[]{value, "(preserve | replace | collapse)"});
|
|
1556 |
break;
|
|
1557 |
}
|
|
1558 |
|
|
1559 |
return retValue;
|
|
1560 |
}
|
|
1561 |
|
|
1562 |
void reportSchemaFatalError (String key, Object[] args, Element ele) {
|
|
1563 |
fSchemaHandler.reportSchemaFatalError(key, args, ele);
|
|
1564 |
}
|
|
1565 |
|
|
1566 |
void reportSchemaError (String key, Object[] args, Element ele) {
|
|
1567 |
fSchemaHandler.reportSchemaError(key, args, ele);
|
|
1568 |
}
|
|
1569 |
|
|
1570 |
// validate attriubtes from non-schema namespaces
|
|
1571 |
// REVISIT: why we store the attributes in this way? why not just a list
|
|
1572 |
// of structure {element node, attr name/qname, attr value)?
|
|
1573 |
// REVISIT: pass the proper element node to reportSchemaError
|
|
1574 |
public void checkNonSchemaAttributes(XSGrammarBucket grammarBucket) {
|
|
1575 |
// for all attributes
|
|
1576 |
Iterator entries = fNonSchemaAttrs.entrySet().iterator();
|
|
1577 |
XSAttributeDecl attrDecl;
|
|
1578 |
while (entries.hasNext()) {
|
|
1579 |
Map.Entry entry = (Map.Entry) entries.next();
|
|
1580 |
// get name, uri, localpart
|
|
1581 |
String attrRName = (String) entry.getKey();
|
|
1582 |
String attrURI = attrRName.substring(0,attrRName.indexOf(','));
|
|
1583 |
String attrLocal = attrRName.substring(attrRName.indexOf(',')+1);
|
|
1584 |
// find associated grammar
|
|
1585 |
SchemaGrammar sGrammar = grammarBucket.getGrammar(attrURI);
|
|
1586 |
if (sGrammar == null) {
|
|
1587 |
continue;
|
|
1588 |
}
|
|
1589 |
// and get the datatype validator, if there is one
|
|
1590 |
attrDecl = sGrammar.getGlobalAttributeDecl(attrLocal);
|
|
1591 |
if (attrDecl == null) {
|
|
1592 |
continue;
|
|
1593 |
}
|
|
1594 |
XSSimpleType dv = (XSSimpleType)attrDecl.getTypeDefinition();
|
|
1595 |
if (dv == null) {
|
|
1596 |
continue;
|
|
1597 |
}
|
|
1598 |
|
|
1599 |
// get all values appeared with this attribute name
|
|
1600 |
Vector values = (Vector) entry.getValue();
|
|
1601 |
String elName;
|
|
1602 |
String attrName = (String)values.elementAt(0);
|
|
1603 |
// for each of the values
|
|
1604 |
int count = values.size();
|
|
1605 |
for (int i = 1; i < count; i += 2) {
|
|
1606 |
elName = (String)values.elementAt(i);
|
|
1607 |
try {
|
|
1608 |
// and validate it using the XSSimpleType
|
|
1609 |
// REVISIT: what would be the proper validation context?
|
|
1610 |
// guess we need to save that in the vectors too.
|
|
1611 |
dv.validate((String)values.elementAt(i+1), null, null);
|
|
1612 |
} catch(InvalidDatatypeValueException ide) {
|
|
1613 |
reportSchemaError ("s4s-att-invalid-value",
|
|
1614 |
new Object[] {elName, attrName, ide.getMessage()},
|
|
1615 |
null);
|
|
1616 |
}
|
|
1617 |
}
|
|
1618 |
}
|
|
1619 |
}
|
|
1620 |
|
|
1621 |
// normalize the string according to the whiteSpace facet
|
|
1622 |
public static String normalize(String content, short ws) {
|
|
1623 |
int len = content == null ? 0 : content.length();
|
|
1624 |
if (len == 0 || ws == XSSimpleType.WS_PRESERVE)
|
|
1625 |
return content;
|
|
1626 |
|
|
1627 |
StringBuffer sb = new StringBuffer();
|
|
1628 |
if (ws == XSSimpleType.WS_REPLACE) {
|
|
1629 |
char ch;
|
|
1630 |
// when it's replace, just replace #x9, #xa, #xd by #x20
|
|
1631 |
for (int i = 0; i < len; i++) {
|
|
1632 |
ch = content.charAt(i);
|
|
1633 |
if (ch != 0x9 && ch != 0xa && ch != 0xd)
|
|
1634 |
sb.append(ch);
|
|
1635 |
else
|
|
1636 |
sb.append((char)0x20);
|
|
1637 |
}
|
|
1638 |
} else {
|
|
1639 |
char ch;
|
|
1640 |
int i;
|
|
1641 |
boolean isLeading = true;
|
|
1642 |
// when it's collapse
|
|
1643 |
for (i = 0; i < len; i++) {
|
|
1644 |
ch = content.charAt(i);
|
|
1645 |
// append real characters, so we passed leading ws
|
|
1646 |
if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) {
|
|
1647 |
sb.append(ch);
|
|
1648 |
isLeading = false;
|
|
1649 |
}
|
|
1650 |
else {
|
|
1651 |
// for whitespaces, we skip all following ws
|
|
1652 |
for (; i < len-1; i++) {
|
|
1653 |
ch = content.charAt(i+1);
|
|
1654 |
if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20)
|
|
1655 |
break;
|
|
1656 |
}
|
|
1657 |
// if it's not a leading or tailing ws, then append a space
|
|
1658 |
if (i < len - 1 && !isLeading)
|
|
1659 |
sb.append((char)0x20);
|
|
1660 |
}
|
|
1661 |
}
|
|
1662 |
}
|
|
1663 |
|
|
1664 |
return sb.toString();
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
// the following part implements an attribute-value-array pool.
|
|
1668 |
// when checkAttribute is called, it calls getAvailableArray to get
|
|
1669 |
// an array from the pool; when the caller is done with the array,
|
|
1670 |
// it calls returnAttrArray to return that array to the pool.
|
|
1671 |
|
|
1672 |
// initial size of the array pool. 10 is big enough
|
|
1673 |
static final int INIT_POOL_SIZE = 10;
|
|
1674 |
// the incremental size of the array pool
|
|
1675 |
static final int INC_POOL_SIZE = 10;
|
|
1676 |
// the array pool
|
|
1677 |
Object[][] fArrayPool = new Object[INIT_POOL_SIZE][ATTIDX_COUNT];
|
|
1678 |
// used to clear the returned array
|
|
1679 |
// I think System.arrayCopy is more efficient than setting 35 fields to null
|
|
1680 |
private static Object[] fTempArray = new Object[ATTIDX_COUNT];
|
|
1681 |
// current position of the array pool (# of arrays not returned)
|
|
1682 |
int fPoolPos = 0;
|
|
1683 |
|
|
1684 |
// get the next available array
|
|
1685 |
protected Object[] getAvailableArray() {
|
|
1686 |
// if no array left in the pool, increase the pool size
|
|
1687 |
if (fArrayPool.length == fPoolPos) {
|
|
1688 |
// increase size
|
|
1689 |
fArrayPool = new Object[fPoolPos+INC_POOL_SIZE][];
|
|
1690 |
// initialize each *new* array
|
|
1691 |
for (int i = fPoolPos; i < fArrayPool.length; i++)
|
|
1692 |
fArrayPool[i] = new Object[ATTIDX_COUNT];
|
|
1693 |
}
|
|
1694 |
// get the next available one
|
|
1695 |
Object[] retArray = fArrayPool[fPoolPos];
|
|
1696 |
// clear it from the pool. this is for GC: if a caller forget to
|
|
1697 |
// return the array, we want that array to be GCed.
|
|
1698 |
fArrayPool[fPoolPos++] = null;
|
|
1699 |
// to make sure that one array is not returned twice, we use
|
|
1700 |
// the last entry to indicate whether an array is already returned
|
|
1701 |
// now set it to false.
|
|
1702 |
System.arraycopy(fTempArray, 0, retArray, 0, ATTIDX_COUNT-1);
|
|
1703 |
retArray[ATTIDX_ISRETURNED] = Boolean.FALSE;
|
|
1704 |
|
|
1705 |
return retArray;
|
|
1706 |
}
|
|
1707 |
|
|
1708 |
// return an array back to the pool
|
|
1709 |
public void returnAttrArray(Object[] attrArray, XSDocumentInfo schemaDoc) {
|
|
1710 |
// pop the namespace context
|
|
1711 |
if (schemaDoc != null)
|
|
1712 |
schemaDoc.fNamespaceSupport.popContext();
|
|
1713 |
|
|
1714 |
// if 1. the pool is full; 2. the array is null;
|
|
1715 |
// 3. the array is of wrong size; 4. the array is already returned
|
|
1716 |
// then we can't accept this array to be returned
|
|
1717 |
if (fPoolPos == 0 ||
|
|
1718 |
attrArray == null ||
|
|
1719 |
attrArray.length != ATTIDX_COUNT ||
|
|
1720 |
((Boolean)attrArray[ATTIDX_ISRETURNED]).booleanValue()) {
|
|
1721 |
return;
|
|
1722 |
}
|
|
1723 |
|
|
1724 |
// mark this array as returned
|
|
1725 |
attrArray[ATTIDX_ISRETURNED] = Boolean.TRUE;
|
|
1726 |
// better clear nonschema vector
|
|
1727 |
if(attrArray[ATTIDX_NONSCHEMA] != null)
|
|
1728 |
((Vector)attrArray[ATTIDX_NONSCHEMA]).clear();
|
|
1729 |
// and put it into the pool
|
|
1730 |
fArrayPool[--fPoolPos] = attrArray;
|
|
1731 |
}
|
|
1732 |
|
|
1733 |
public void resolveNamespace(Element element, Attr[] attrs,
|
|
1734 |
SchemaNamespaceSupport nsSupport) {
|
|
1735 |
// push the namespace context
|
|
1736 |
nsSupport.pushContext();
|
|
1737 |
|
|
1738 |
// search for new namespace bindings
|
|
1739 |
int length = attrs.length;
|
|
1740 |
Attr sattr = null;
|
|
1741 |
String rawname, prefix, uri;
|
|
1742 |
for (int i = 0; i < length; i++) {
|
|
1743 |
sattr = attrs[i];
|
|
1744 |
rawname = DOMUtil.getName(sattr);
|
|
1745 |
prefix = null;
|
|
1746 |
if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
|
|
1747 |
prefix = XMLSymbols.EMPTY_STRING;
|
|
1748 |
else if (rawname.startsWith("xmlns:"))
|
|
1749 |
prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
|
|
1750 |
if (prefix != null) {
|
|
1751 |
uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
|
|
1752 |
nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
|
|
1753 |
}
|
|
1754 |
}
|
|
1755 |
}
|
|
1756 |
}
|
|
1757 |
|
|
1758 |
class OneAttr {
|
|
1759 |
// name of the attribute
|
|
1760 |
public String name;
|
|
1761 |
// index of the datatype validator
|
|
1762 |
public int dvIndex;
|
|
1763 |
// whether it's optional, and has default value
|
|
1764 |
public int valueIndex;
|
|
1765 |
// the default value of this attribute
|
|
1766 |
public Object dfltValue;
|
|
1767 |
|
|
1768 |
public OneAttr(String name, int dvIndex, int valueIndex, Object dfltValue) {
|
|
1769 |
this.name = name;
|
|
1770 |
this.dvIndex = dvIndex;
|
|
1771 |
this.valueIndex = valueIndex;
|
|
1772 |
this.dfltValue = dfltValue;
|
|
1773 |
}
|
|
1774 |
}
|
|
1775 |
|
|
1776 |
abstract class Container {
|
|
1777 |
static final int THRESHOLD = 5;
|
|
1778 |
static Container getContainer(int size) {
|
|
1779 |
if (size > THRESHOLD)
|
|
1780 |
return new LargeContainer(size);
|
|
1781 |
else
|
|
1782 |
return new SmallContainer(size);
|
|
1783 |
}
|
|
1784 |
abstract void put(String key, OneAttr value);
|
|
1785 |
abstract OneAttr get(String key);
|
|
1786 |
|
|
1787 |
OneAttr[] values;
|
|
1788 |
int pos = 0;
|
|
1789 |
}
|
|
1790 |
|
|
1791 |
class SmallContainer extends Container {
|
|
1792 |
String[] keys;
|
|
1793 |
SmallContainer(int size) {
|
|
1794 |
keys = new String[size];
|
|
1795 |
values = new OneAttr[size];
|
|
1796 |
}
|
|
1797 |
void put(String key, OneAttr value) {
|
|
1798 |
keys[pos] = key;
|
|
1799 |
values[pos++] = value;
|
|
1800 |
}
|
|
1801 |
OneAttr get(String key) {
|
|
1802 |
for (int i = 0; i < pos; i++) {
|
|
1803 |
if (keys[i].equals(key)) {
|
|
1804 |
return values[i];
|
|
1805 |
}
|
|
1806 |
}
|
|
1807 |
return null;
|
|
1808 |
}
|
|
1809 |
}
|
|
1810 |
|
|
1811 |
class LargeContainer extends Container {
|
|
1812 |
Map items;
|
|
1813 |
LargeContainer(int size) {
|
|
1814 |
items = new HashMap(size*2+1);
|
|
1815 |
values = new OneAttr[size];
|
|
1816 |
}
|
|
1817 |
void put(String key, OneAttr value) {
|
|
1818 |
items.put(key, value);
|
|
1819 |
values[pos++] = value;
|
|
1820 |
}
|
|
1821 |
OneAttr get(String key) {
|
|
1822 |
OneAttr ret = (OneAttr)items.get(key);
|
|
1823 |
return ret;
|
|
1824 |
}
|
|
1825 |
}
|