You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/04/12 19:12:29 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/traversers XSDSimpleTypeTraverser.java
sandygao 02/04/12 10:12:28
Modified: java/src/org/apache/xerces/impl/xs/traversers
XSDSimpleTypeTraverser.java
Log:
returnAttrArray should be called after all the children are traversed,
otherwise namespace declaration won't be recognized by the children.
Revision Changes Path
1.16 +27 -14 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XSDSimpleTypeTraverser.java 3 Apr 2002 23:48:27 -0000 1.15
+++ XSDSimpleTypeTraverser.java 12 Apr 2002 17:12:28 -0000 1.16
@@ -118,7 +118,7 @@
* @author Neeraj Bajaj, Sun Microsystems, Inc.
* @author Sandy Gao, IBM
*
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.15 2002/04/03 23:48:27 elena Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.16 2002/04/12 17:12:28 sandygao Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -241,7 +241,6 @@
content = DOMUtil.getNextSiblingElement(content);
}
}
- fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
// get base type from "base" attribute
XSSimpleType baseValidator = null;
@@ -273,16 +272,22 @@
}
}
+ // when there is an error finding the base type of a restriciton
+ // we use anySimpleType as the base, then we should skip the facets,
+ // because anySimpleType doesn't recognize any facet.
+ boolean skipFacets = false;
+
// check if there is a child "simpleType"
if (content != null && DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_SIMPLETYPE)) {
if (restriction || list) {
// it's an error for both "base" and "simpleType" to appear
if (baseTypeName != null) {
reportSchemaError(list ? "src-simple-type.3" : "src-simple-type.2", null, content);
- return errorType(name, schemaDoc.fTargetNamespace, refType);
}
- // traver this child to get the base type
- baseValidator = traverseLocal(content, schemaDoc, grammar);
+ else {
+ // traver this child to get the base type
+ baseValidator = traverseLocal(content, schemaDoc, grammar);
+ }
// get the next element
content = DOMUtil.getNextSiblingElement(content);
}
@@ -311,23 +316,27 @@
else if ((restriction || list) && baseTypeName == null) {
// it's an error if neither "base" nor "simpleType" appears
reportSchemaError("src-simple-type.2", null, child);
- return errorType(name, schemaDoc.fTargetNamespace, refType);
+ // base can't be found, skip the facets.
+ skipFacets = true;
+ baseValidator = SchemaGrammar.fAnySimpleType;
}
else if (union && (memberTypes == null || memberTypes.size() == 0)) {
// it's an error if "memberTypes" is empty and no "simpleType" appears
reportSchemaError("src-union-memberTypes-or-simpleTypes", null, child);
- return errorType(name, schemaDoc.fTargetNamespace, SchemaSymbols.UNION);
+ dTValidators = new Vector(1);
+ dTValidators.addElement(SchemaGrammar.fAnySimpleType);
}
// error finding "base" or error traversing "simpleType".
// don't need to report an error, since some error has been reported.
if ((restriction || list) && baseValidator == null) {
- return errorType(name, schemaDoc.fTargetNamespace, refType);
+ baseValidator = SchemaGrammar.fAnySimpleType;
}
// error finding "memberTypes" or error traversing "simpleType".
// don't need to report an error, since some error has been reported.
if (union && (dTValidators == null || dTValidators.size() == 0)) {
- return errorType(name, schemaDoc.fTargetNamespace, SchemaSymbols.UNION);
+ dTValidators = new Vector(1);
+ dTValidators.addElement(SchemaGrammar.fAnySimpleType);
}
// item type of list types can't have list content
@@ -355,11 +364,13 @@
FacetInfo fi = traverseFacets(content, baseValidator, schemaDoc);
content = fi.nodeAfterFacets;
- try {
- fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
- newDecl.applyFacets(fi.facetdata, fi.fPresentFacets, fi.fFixedFacets, fValidationState);
- } catch (InvalidDatatypeFacetException ex) {
- reportSchemaError(ex.getKey(), ex.getArgs(), child);
+ if (!skipFacets) {
+ try {
+ fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
+ newDecl.applyFacets(fi.facetdata, fi.fPresentFacets, fi.fFixedFacets, fValidationState);
+ } catch (InvalidDatatypeFacetException ex) {
+ reportSchemaError(ex.getKey(), ex.getArgs(), child);
+ }
}
}
@@ -376,6 +387,8 @@
}
}
+ fAttrChecker.returnAttrArray(contentAttrs, schemaDoc);
+
// return the new type
return newDecl;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org