1 /* |
1 /* |
2 * reserved comment block |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT REMOVE OR ALTER! |
3 * @LastModified: Oct 2017 |
4 */ |
4 */ |
5 /* |
5 /* |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
7 * contributor license agreements. See the NOTICE file distributed with |
7 * contributor license agreements. See the NOTICE file distributed with |
8 * this work for additional information regarding copyright ownership. |
8 * this work for additional information regarding copyright ownership. |
18 * See the License for the specific language governing permissions and |
18 * See the License for the specific language governing permissions and |
19 * limitations under the License. |
19 * limitations under the License. |
20 */ |
20 */ |
21 |
21 |
22 package com.sun.org.apache.xerces.internal.impl.xs.traversers; |
22 package com.sun.org.apache.xerces.internal.impl.xs.traversers; |
23 |
|
24 import java.util.ArrayList; |
|
25 import java.util.Vector; |
|
26 |
23 |
27 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeFacetException; |
24 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeFacetException; |
28 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; |
25 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; |
29 import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl; |
26 import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl; |
30 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar; |
27 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar; |
33 import com.sun.org.apache.xerces.internal.impl.xs.util.XInt; |
30 import com.sun.org.apache.xerces.internal.impl.xs.util.XInt; |
34 import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl; |
31 import com.sun.org.apache.xerces.internal.impl.xs.util.XSObjectListImpl; |
35 import com.sun.org.apache.xerces.internal.util.DOMUtil; |
32 import com.sun.org.apache.xerces.internal.util.DOMUtil; |
36 import com.sun.org.apache.xerces.internal.xni.QName; |
33 import com.sun.org.apache.xerces.internal.xni.QName; |
37 import com.sun.org.apache.xerces.internal.xs.XSConstants; |
34 import com.sun.org.apache.xerces.internal.xs.XSConstants; |
|
35 import com.sun.org.apache.xerces.internal.xs.XSObject; |
38 import com.sun.org.apache.xerces.internal.xs.XSObjectList; |
36 import com.sun.org.apache.xerces.internal.xs.XSObjectList; |
39 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; |
37 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; |
|
38 import java.util.ArrayList; |
|
39 import java.util.List; |
40 import org.w3c.dom.Element; |
40 import org.w3c.dom.Element; |
41 |
41 |
42 /** |
42 /** |
43 * The simple type definition schema component traverser. |
43 * The simple type definition schema component traverser. |
44 * |
44 * |
239 // General Attribute Checking: get base/item/member types |
239 // General Attribute Checking: get base/item/member types |
240 Object[] contentAttrs = fAttrChecker.checkAttributes(child, false, schemaDoc); |
240 Object[] contentAttrs = fAttrChecker.checkAttributes(child, false, schemaDoc); |
241 QName baseTypeName = (QName)contentAttrs[restriction ? |
241 QName baseTypeName = (QName)contentAttrs[restriction ? |
242 XSAttributeChecker.ATTIDX_BASE : |
242 XSAttributeChecker.ATTIDX_BASE : |
243 XSAttributeChecker.ATTIDX_ITEMTYPE]; |
243 XSAttributeChecker.ATTIDX_ITEMTYPE]; |
244 Vector memberTypes = (Vector)contentAttrs[XSAttributeChecker.ATTIDX_MEMBERTYPES]; |
244 @SuppressWarnings("unchecked") |
|
245 List<QName> memberTypes = (ArrayList<QName>)contentAttrs[XSAttributeChecker.ATTIDX_MEMBERTYPES]; |
245 //content = {annotation?,simpleType?...} |
246 //content = {annotation?,simpleType?...} |
246 Element content = DOMUtil.getFirstChildElement(child); |
247 Element content = DOMUtil.getFirstChildElement(child); |
247 //check content (annotation?, ...) |
248 //check content (annotation?, ...) |
248 if (content != null && DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) { |
249 if (content != null && DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) { |
249 XSAnnotationImpl annotation = traverseAnnotationDecl(content, contentAttrs, false, schemaDoc); |
250 XSAnnotationImpl annotation = traverseAnnotationDecl(content, contentAttrs, false, schemaDoc); |
284 fIsBuiltIn = false; |
285 fIsBuiltIn = false; |
285 return null; |
286 return null; |
286 } |
287 } |
287 } |
288 } |
288 // get types from "memberTypes" attribute |
289 // get types from "memberTypes" attribute |
289 ArrayList dTValidators = null; |
290 List<XSObject> dTValidators = null; |
290 XSSimpleType dv = null; |
291 XSSimpleType dv = null; |
291 XSObjectList dvs; |
292 XSObjectList dvs; |
292 if (union && memberTypes != null && memberTypes.size() > 0) { |
293 if (union && memberTypes != null && memberTypes.size() > 0) { |
293 int size = memberTypes.size(); |
294 int size = memberTypes.size(); |
294 dTValidators = new ArrayList(size); |
295 dTValidators = new ArrayList<>(size); |
295 // for each qname in the list |
296 // for each qname in the list |
296 for (int i = 0; i < size; i++) { |
297 for (int i = 0; i < size; i++) { |
297 // get the type decl |
298 // get the type decl |
298 dv = findDTValidator(child, name, (QName)memberTypes.elementAt(i), |
299 dv = findDTValidator(child, name, (QName)memberTypes.get(i), |
299 XSConstants.DERIVATION_UNION, schemaDoc); |
300 XSConstants.DERIVATION_UNION, schemaDoc); |
300 if (dv != null) { |
301 if (dv != null) { |
301 // if it's a union, expand it |
302 // if it's a union, expand it |
302 if (dv.getVariety() == XSSimpleType.VARIETY_UNION) { |
303 if (dv.getVariety() == XSSimpleType.VARIETY_UNION) { |
303 dvs = dv.getMemberTypes(); |
304 dvs = dv.getMemberTypes(); |
324 // get the next element |
325 // get the next element |
325 content = DOMUtil.getNextSiblingElement(content); |
326 content = DOMUtil.getNextSiblingElement(content); |
326 } |
327 } |
327 else if (union) { |
328 else if (union) { |
328 if (dTValidators == null) { |
329 if (dTValidators == null) { |
329 dTValidators = new ArrayList(2); |
330 dTValidators = new ArrayList<>(2); |
330 } |
331 } |
331 do { |
332 do { |
332 // traverse this child to get the member type |
333 // traverse this child to get the member type |
333 dv = traverseLocal(content, schemaDoc, grammar); |
334 dv = traverseLocal(content, schemaDoc, grammar); |
334 if (dv != null) { |
335 if (dv != null) { |