You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/02/09 22:47:12 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/msg SchemaMessages.java
neilg 01/02/09 13:47:11
Modified: java/src/org/apache/xerces/validators/schema
TraverseSchema.java SchemaMessageProvider.java
java/src/org/apache/xerces/validators/common
XMLValidator.java
java/src/org/apache/xerces/msg SchemaMessages.java
Log:
message.txt
Revision Changes Path
1.98 +174 -293 xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java
Index: TraverseSchema.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- TraverseSchema.java 2001/02/09 20:28:19 1.97
+++ TraverseSchema.java 2001/02/09 21:47:08 1.98
@@ -124,7 +124,7 @@
*
* @see org.apache.xerces.validators.common.Grammar
*
- * @version $Id: TraverseSchema.java,v 1.97 2001/02/09 20:28:19 elena Exp $
+ * @version $Id: TraverseSchema.java,v 1.98 2001/02/09 21:47:08 neilg Exp $
*/
public class TraverseSchema implements
NamespacesScope.NamespacesHandler{
@@ -169,6 +169,9 @@
private Hashtable fComplexTypeRegistry = new Hashtable();
private Hashtable fAttributeDeclRegistry = new Hashtable();
+ // stores the names of groups that we've traversed so we can avoid multiple traversals
+ // qualified group names are keys and their contentSpecIndexes are values.
+ private Hashtable fGroupNameRegistry = new Hashtable();
private Vector fIncludeLocations = new Vector();
private Vector fImportLocations = new Vector();
@@ -2784,36 +2787,39 @@
}
Element referredAttribute = getTopLevelComponentByName(SchemaSymbols.ELT_ATTRIBUTE,localpart);
- if (referredAttribute != null) {
- traverseAttributeDecl(referredAttribute, typeInfo, true);
- // this nasty hack needed to ``override'' the "use" on the
- // global attribute with that on the ref'ing attribute.
- int referredAttName = fStringPool.addSymbol(referredAttribute.getAttribute(SchemaSymbols.ATT_NAME));
- int uriIndex = StringPool.EMPTY_STRING;
- if ( fTargetNSURIString.length() > 0) {
+ if (referredAttribute != null) {
+ if (typeInfo != null) {
+ // don't need to traverse ref'd attribute if we're global; just make sure it's there...
+ traverseAttributeDecl(referredAttribute, typeInfo, true);
+ // this nasty hack needed to ``override'' the "use" on the
+ // global attribute with that on the ref'ing attribute.
+ int referredAttName = fStringPool.addSymbol(referredAttribute.getAttribute(SchemaSymbols.ATT_NAME));
+ int uriIndex = StringPool.EMPTY_STRING;
+ if ( fTargetNSURIString.length() > 0) {
uriIndex = fTargetNSURI;
- }
- QName referredAttQName = new QName(-1,referredAttName,referredAttName,uriIndex);
- if (prohibited) {
- int tempIndex = fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, referredAttQName);
- XMLAttributeDecl referredAttrDecl = new XMLAttributeDecl();
- fSchemaGrammar.getAttributeDecl(tempIndex, referredAttrDecl);
- referredAttrDecl.defaultType = XMLAttributeDecl.DEFAULT_TYPE_PROHIBITED;
- fSchemaGrammar.setAttributeDecl(typeInfo.templateElementIndex, tempIndex, referredAttrDecl);
- }
- else if (required) {
- int tempIndex = fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, referredAttQName);
- XMLAttributeDecl referredAttrDecl = new XMLAttributeDecl();
- fSchemaGrammar.getAttributeDecl(tempIndex, referredAttrDecl);
- // now two cases: if it's othre than fixed, no problem, just overwrite.
- // but if it is *it* fixed, specs demand attr be treated as both fixed and required.
- if(referredAttrDecl.defaultType == XMLAttributeDecl.DEFAULT_TYPE_FIXED)
- referredAttrDecl.defaultType = XMLAttributeDecl.DEFAULT_TYPE_REQUIRED_AND_FIXED;
- else
- referredAttrDecl.defaultType = XMLAttributeDecl.DEFAULT_TYPE_REQUIRED;
- fSchemaGrammar.setAttributeDecl(typeInfo.templateElementIndex, tempIndex, referredAttrDecl);
- }
- }
+ }
+ QName referredAttQName = new QName(-1,referredAttName,referredAttName,uriIndex);
+ if (prohibited) {
+ int tempIndex = fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, referredAttQName);
+ XMLAttributeDecl referredAttrDecl = new XMLAttributeDecl();
+ fSchemaGrammar.getAttributeDecl(tempIndex, referredAttrDecl);
+ referredAttrDecl.defaultType = XMLAttributeDecl.DEFAULT_TYPE_PROHIBITED;
+ fSchemaGrammar.setAttributeDecl(typeInfo.templateElementIndex, tempIndex, referredAttrDecl);
+ }
+ else if (required) {
+ int tempIndex = fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, referredAttQName);
+ XMLAttributeDecl referredAttrDecl = new XMLAttributeDecl();
+ fSchemaGrammar.getAttributeDecl(tempIndex, referredAttrDecl);
+ // now two cases: if it's othre than fixed, no problem, just overwrite.
+ // but if it is *it* fixed, specs demand attr be treated as both fixed and required.
+ if(referredAttrDecl.defaultType == XMLAttributeDecl.DEFAULT_TYPE_FIXED)
+ referredAttrDecl.defaultType = XMLAttributeDecl.DEFAULT_TYPE_REQUIRED_AND_FIXED;
+ else
+ referredAttrDecl.defaultType = XMLAttributeDecl.DEFAULT_TYPE_REQUIRED;
+ fSchemaGrammar.setAttributeDecl(typeInfo.templateElementIndex, tempIndex, referredAttrDecl);
+ }
+ }
+ }
else {
if (fAttributeDeclRegistry.get(localpart) != null) {
@@ -3091,24 +3097,26 @@
* id = ID
* name = NCName
* ref = QName>
- * Content: (annotation?, (attribute|attributeGroup), anyAttribute?)
+ * Content: (annotation?, (attribute|attributeGroup)*, anyAttribute?)
* </>
*
*/
private int traverseAttributeGroupDecl( Element attrGrpDecl, ComplexTypeInfo typeInfo, Vector anyAttDecls ) throws Exception {
- // REVISIT: we are traversing Group decl each time it is referenced over and over again
- // do we really want to do it?!
- int attGrpName = fStringPool.addSymbol(attrGrpDecl.getAttribute(SchemaSymbols.ATT_NAME));
+ // attributeGroup name
+ String attGrpNameStr = attrGrpDecl.getAttribute(SchemaSymbols.ATT_NAME);
+ int attGrpName = fStringPool.addSymbol(attGrpNameStr);
String ref = attrGrpDecl.getAttribute(SchemaSymbols.ATT_REF);
-
- // attribute type
- int attType = -1;
- int enumeration = -1;
+ Element child = checkContent( attrGrpDecl, XUtil.getFirstChildElement(attrGrpDecl), true );
if (!ref.equals("")) {
- if (XUtil.getFirstChildElement(attrGrpDecl) != null)
- reportSchemaError(SchemaMessageProvider.NoContentForRef, null);
+ if(isTopLevel(attrGrpDecl))
+ // REVISIT: localize
+ reportGenericSchemaError ( "An attributeGroup with \"ref\" present must not have <schema> or <redefine> as its parent");
+ if(!attGrpNameStr.equals(""))
+ // REVISIT: localize
+ reportGenericSchemaError ( "attributeGroup " + attGrpNameStr + " cannot refer to another attributeGroup, but it refers to " + ref);
+
String prefix = "";
String localpart = ref;
int colonptr = ref.indexOf(":");
@@ -3126,37 +3134,51 @@
// REVISIST: different NS, not supported yet.
// REVISIT: Localize
//reportGenericSchemaError("Feature not supported: see an attribute from different NS");
- }
- Element referredAttrGrp = getTopLevelComponentByName(SchemaSymbols.ELT_ATTRIBUTEGROUP,localpart);
- if (referredAttrGrp != null) {
- traverseAttributeGroupDecl(referredAttrGrp, typeInfo, anyAttDecls);
}
- else {
- // REVISIT: Localize
- reportGenericSchemaError ( "Couldn't find top level attributegroup " + ref);
- }
- return -1;
+ if(typeInfo != null) {
+ // only do this if we're traversing because we were ref'd here; when we come
+ // upon this decl by itself we're just validating.
+ Element referredAttrGrp = getTopLevelComponentByName(SchemaSymbols.ELT_ATTRIBUTEGROUP,localpart);
+ if (referredAttrGrp != null) {
+ traverseAttributeGroupDecl(referredAttrGrp, typeInfo, anyAttDecls);
+ }
+ else {
+ // REVISIT: Localize
+ reportGenericSchemaError ( "Couldn't find top level attributegroup " + ref);
+ }
+ return -1;
+ }
}
- for ( Element child = XUtil.getFirstChildElement(attrGrpDecl);
+ for (;
child != null ; child = XUtil.getNextSiblingElement(child)) {
if ( child.getLocalName().equals(SchemaSymbols.ELT_ATTRIBUTE) ){
traverseAttributeDecl(child, typeInfo, false);
}
else if ( child.getLocalName().equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ) {
- traverseAttributeGroupDecl(child, typeInfo,anyAttDecls);
+ if(typeInfo != null)
+ // only do this if we're traversing because we were ref'd here; when we come
+ // upon this decl by itself we're just validating.
+ traverseAttributeGroupDecl(child, typeInfo,anyAttDecls);
}
- else if ( child.getLocalName().equals(SchemaSymbols.ELT_ANYATTRIBUTE) ) {
+ else
+ break;
+ }
+ if (child != null) {
+ if ( child.getLocalName().equals(SchemaSymbols.ELT_ANYATTRIBUTE) ) {
if (anyAttDecls != null) {
anyAttDecls.addElement(traverseAnyAttribute(child));
}
- break;
- }
- else if (child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION) ) {
- // REVISIT: what about appInfo
- }
- }
+ if (XUtil.getNextSiblingElement(child) != null)
+ // REVISIT: localize
+ reportGenericSchemaError ( "An attributeGroup declaration cannot have any children after an anyAttribute declaration");
+ return -1;
+ }
+ else
+ // REVISIT: localize
+ reportGenericSchemaError ( "An attributeGroup declaration must only contain attribute, attributeGroup and anyAttribute elements");
+ }
return -1;
} // end of method traverseAttributeGroup
@@ -4306,7 +4328,7 @@
* minOccurs = nonNegativeInteger
* name = NCName
* ref = QName>
- * Content: (annotation? , (element | group | all | choice | sequence | any)*)
+ * Content: (annotation? , (all | choice | sequence)?)
* <group/>
*
* @param elementDecl
@@ -4317,10 +4339,15 @@
String groupName = groupDecl.getAttribute(SchemaSymbols.ATT_NAME);
String ref = groupDecl.getAttribute(SchemaSymbols.ATT_REF);
+ Element child = checkContent( groupDecl, XUtil.getFirstChildElement(groupDecl), true );
if (!ref.equals("")) {
- if (XUtil.getFirstChildElement(groupDecl) != null)
- reportSchemaError(SchemaMessageProvider.NoContentForRef, null);
+ if(isTopLevel(groupDecl))
+ // REVISIT: localize
+ reportGenericSchemaError ( "A group with \"ref\" present must not have <schema> or <redefine> as its parent");
+ if(!groupName.equals(""))
+ // REVISIT: localize
+ reportGenericSchemaError ( "group " + groupName + " cannot refer to another group, but it refers to " + ref);
String prefix = "";
String localpart = ref;
int colonptr = ref.indexOf(":");
@@ -4335,7 +4362,9 @@
if (!uriStr.equals(fTargetNSURIString)) {
return traverseGroupDeclFromAnotherSchema(localpart, uriStr);
}
-
+ Object contentSpecHolder = fGroupNameRegistry.get(uriStr + "," + localpart);
+ if(contentSpecHolder != null ) // we've already traversed this group
+ return ((Integer)contentSpecHolder).intValue();
int contentSpecIndex = -1;
Element referredGroup = getTopLevelComponentByName(SchemaSymbols.ELT_GROUP,localpart);
if (referredGroup == null) {
@@ -4348,105 +4377,42 @@
contentSpecIndex = traverseGroupDecl(referredGroup);
}
+ System.err.println("group name being ref'd is " + ref + " and its contentSpec is " + contentSpecIndex);
return contentSpecIndex;
- }
-
- boolean traverseElt = true;
- if (fCurrentScope == TOP_LEVEL_SCOPE) {
- traverseElt = false;
}
-
- Element child = XUtil.getFirstChildElement(groupDecl);
- while (child != null && child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION))
- child = XUtil.getNextSiblingElement(child);
-
- int contentSpecType = 0;
- int csnType = 0;
- int allChildren[] = null;
- int allChildCount = 0;
-
- csnType = XMLContentSpec.CONTENTSPECNODE_SEQ;
- contentSpecType = XMLElementDecl.TYPE_CHILDREN;
-
- int left = -2;
- int right = -2;
- boolean hadContent = false;
- boolean seeAll = false;
- boolean seeParticle = false;
-
- for (;
- child != null;
- child = XUtil.getNextSiblingElement(child)) {
- int index = -2;
- hadContent = true;
-
- boolean illegalChild = false;
-
- String childName = child.getLocalName();
- if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
- QName eltQName = traverseElementDecl(child);
- index = fSchemaGrammar.addContentSpecNode( XMLContentSpec.CONTENTSPECNODE_LEAF,
- eltQName.localpart,
- eltQName.uri,
- false);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
- index = traverseGroupDecl(child);
- if (index == -1)
- continue;
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_ALL)) {
- index = traverseAll(child);
- //seeParticle = true;
- seeAll = true;
- }
- else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
- index = traverseChoice(child);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
- index = traverseSequence(child);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_ANY)) {
- index = traverseAny(child);
- seeParticle = true;
- }
- else {
- illegalChild = true;
- reportSchemaError(SchemaMessageProvider.GroupContentRestricted,
- new Object [] { "group", childName });
- }
-
- if ( ! illegalChild ) {
- index = expandContentModel( index, child);
- }
-
- if (seeParticle && seeAll) {
- reportSchemaError( SchemaMessageProvider.GroupContentRestricted,
- new Object [] { "'all' needs to be 'the' only Child", childName});
- }
-
- if (left == -2) {
- left = index;
- } else if (right == -2) {
- right = index;
- } else {
- left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
- right = index;
- }
+ String qualifiedGroupName = fTargetNSURIString + "," + groupName;
+ Object contentSpecHolder = fGroupNameRegistry.get(qualifiedGroupName);
+ if(contentSpecHolder != null ) // we've already traversed this group
+ return ((Integer)contentSpecHolder).intValue();
+
+ // if we're here then we're traversing a top-level group that we've never seen before.
+ int index = -2;
+
+ boolean illegalChild = false;
+ String childName =
+ (child != null) ? child.getLocalName() : "";
+ if (childName.equals(SchemaSymbols.ELT_ALL)) {
+ index = traverseAll(child);
+ }
+ else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
+ index = traverseChoice(child);
+ }
+ else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
+ index = traverseSequence(child);
+ }
+ else if (!childName.equals("") || (child != null && XUtil.getNextSiblingElement(child) != null)) {
+ illegalChild = true;
+ reportSchemaError(SchemaMessageProvider.GroupContentRestricted,
+ new Object [] { "group", childName });
+ }
+System.err.println("we got here!");
+ if ( ! illegalChild && child != null) {
+ index = expandContentModel( index, child);
}
- if (hadContent && right != -2)
- left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
-
- return left;
+ contentSpecHolder = new Integer(index);
+ fGroupNameRegistry.put(qualifiedGroupName, contentSpecHolder);
+ return index;
}
private int traverseGroupDeclFromAnotherSchema( String groupName , String uriStr ) throws Exception {
@@ -4473,96 +4439,43 @@
int saveTargetNSUri = fTargetNSURI;
fTargetNSURI = fStringPool.addSymbol(aGrammar.getTargetNamespaceURI());
fNamespacesScope = aGrammar.getNamespacesScope();
-
- boolean traverseElt = true;
- if (fCurrentScope == TOP_LEVEL_SCOPE) {
- traverseElt = false;
- }
-
- Element child = XUtil.getFirstChildElement(groupDecl);
- while (child != null && child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION))
- child = XUtil.getNextSiblingElement(child);
-
- int contentSpecType = 0;
- int csnType = 0;
- int allChildren[] = null;
- int allChildCount = 0;
-
- csnType = XMLContentSpec.CONTENTSPECNODE_SEQ;
- contentSpecType = XMLElementDecl.TYPE_CHILDREN;
-
- int left = -2;
- int right = -2;
- boolean hadContent = false;
-
- for (;
- child != null;
- child = XUtil.getNextSiblingElement(child)) {
- int index = -2;
- hadContent = true;
-
- boolean seeParticle = false;
- String childName = child.getLocalName();
- int childNameIndex = fStringPool.addSymbol(childName);
- String formAttrVal = child.getAttribute(SchemaSymbols.ATT_FORM);
- if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
- QName eltQName = traverseElementDecl(child);
- index = fSchemaGrammar.addContentSpecNode( XMLContentSpec.CONTENTSPECNODE_LEAF,
- eltQName.localpart,
- eltQName.uri,
- false);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
- index = traverseGroupDecl(child);
- if (index == -1)
- continue;
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_ALL)) {
- index = traverseAll(child);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
- index = traverseChoice(child);
- seeParticle = true;
- }
- else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
- index = traverseSequence(child);
- seeParticle = true;
+ Element child = checkContent( groupDecl, XUtil.getFirstChildElement(groupDecl), true );
- }
- else if (childName.equals(SchemaSymbols.ELT_ANY)) {
- index = traverseAny(child);
- seeParticle = true;
- }
- else {
- reportSchemaError(SchemaMessageProvider.GroupContentRestricted,
- new Object [] { "group", childName });
- }
-
- if (seeParticle) {
- index = expandContentModel( index, child);
- }
- if (left == -2) {
- left = index;
- } else if (right == -2) {
- right = index;
- } else {
- left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
- right = index;
- }
+ String qualifiedGroupName = fTargetNSURIString + "," + groupName;
+ Object contentSpecHolder = fGroupNameRegistry.get(qualifiedGroupName);
+ if(contentSpecHolder != null ) // we've already traversed this group
+ return ((Integer)contentSpecHolder).intValue();
+
+ // if we're here then we're traversing a top-level group that we've never seen before.
+ int index = -2;
+
+ boolean illegalChild = false;
+ String childName =
+ (child != null) ? child.getLocalName() : "";
+ if (childName.equals(SchemaSymbols.ELT_ALL)) {
+ index = traverseAll(child);
+ }
+ else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
+ index = traverseChoice(child);
+ }
+ else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
+ index = traverseSequence(child);
+ }
+ else if (!childName.equals("") || (child != null && XUtil.getNextSiblingElement(child) != null)) {
+ illegalChild = true;
+ reportSchemaError(SchemaMessageProvider.GroupContentRestricted,
+ new Object [] { "group", childName });
+ }
+ if ( ! illegalChild && child != null) {
+ index = expandContentModel( index, child);
}
- if (hadContent && right != -2)
- left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
- fNamespacesScope = saveNSMapping;
- fTargetNSURI = saveTargetNSUri;
- return left;
+ contentSpecHolder = new Integer(index);
+ fGroupNameRegistry.put(qualifiedGroupName, contentSpecHolder);
+ fNamespacesScope = saveNSMapping;
+ fTargetNSURI = saveTargetNSUri;
+ return index;
} // end of method traverseGroupDeclFromAnotherSchema
@@ -4763,11 +4676,9 @@
**/
int traverseAll( Element allDecl) throws Exception {
-
- Element child = XUtil.getFirstChildElement(allDecl);
- while (child != null && child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION))
- child = XUtil.getNextSiblingElement(child);
+ Element child = checkContent(allDecl, XUtil.getFirstChildElement(allDecl), true);
+ if (child == null) return -2;
int allChildren[] = null;
int allChildCount = 0;
@@ -4792,61 +4703,31 @@
seeParticle = true;
}
- // For CR implementation, only elements are permitted
- // TODO - should rewrite this...
- //
- else if (CR_IMPL) {
+ else {
reportGenericSchemaError("Content of all group is restricted to elements only. '" +
childName + "' was seen and is being ignored");
break;
-
}
- else {
-
- if (childName.equals(SchemaSymbols.ELT_GROUP)) {
- index = traverseGroupDecl(child);
- if (index == -1)
- continue;
- seeParticle = true;
- }
- else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
- index = traverseChoice(child);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
- index = traverseSequence(child);
- seeParticle = true;
-
- }
- else if (childName.equals(SchemaSymbols.ELT_ANY)) {
- index = traverseAny(child);
- seeParticle = true;
- }
- else {
- reportSchemaError(SchemaMessageProvider.GroupContentRestricted,
- new Object [] { "group", childName });
- }
- }
-
if (seeParticle) {
index = expandContentModel( index, child);
- }
- try {
- allChildren[allChildCount] = index;
- }
- catch (NullPointerException ne) {
- allChildren = new int[32];
- allChildren[allChildCount] = index;
- }
- catch (ArrayIndexOutOfBoundsException ae) {
- int[] newArray = new int[allChildren.length*2];
- System.arraycopy(allChildren, 0, newArray, 0, allChildren.length);
- allChildren[allChildCount] = index;
}
- allChildCount++;
+ if (index != -2) {
+ try {
+ allChildren[allChildCount] = index;
+ }
+ catch (NullPointerException ne) {
+ allChildren = new int[32];
+ allChildren[allChildCount] = index;
+ }
+ catch (ArrayIndexOutOfBoundsException ae) {
+ int[] newArray = new int[allChildren.length*2];
+ System.arraycopy(allChildren, 0, newArray, 0, allChildren.length);
+ allChildren[allChildCount] = index;
+ }
+ allChildCount++;
+ }
}
// if there were no children, or only invalid children, return...
1.8 +1 -1 xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaMessageProvider.java
Index: SchemaMessageProvider.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaMessageProvider.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SchemaMessageProvider.java 2001/01/25 07:18:49 1.7
+++ SchemaMessageProvider.java 2001/02/09 21:47:09 1.8
@@ -194,7 +194,7 @@
"OrderIsAll", // 11, "{0} not allowed if the order is all."
"DatatypeWithType", // 12, "Datatype qualifiers can only be used if you specify a type attribute."},
"DatatypeQualUnsupported", // 13, "The datatype qualifier {0} is not supported."
- "GroupContentRestricted", // 14, "Error: {0} content must be one of element, group, modelGroupRef. Saw {1}"
+ "GroupContentRestricted", // 14, "Error: {0} content must be one of choice, all or sequence. Saw {1}"
"UnknownBaseDatatype", // 15, "Unknown base type {0} for type {1}." },
"BadAttWithRef", // 16, "ref cannot appear with any of type, abstract, block, final, nullable, default or fixed"},
"NoContentForRef", // 17, "Cannot have child content for an element declaration that has a ref attribute"
1.114 +14 -12 xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
Index: XMLValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- XMLValidator.java 2001/02/07 20:41:39 1.113
+++ XMLValidator.java 2001/02/09 21:47:10 1.114
@@ -121,7 +121,7 @@
/**
* This class is the super all-in-one validator used by the parser.
*
- * @version $Id: XMLValidator.java,v 1.113 2001/02/07 20:41:39 elena Exp $
+ * @version $Id: XMLValidator.java,v 1.114 2001/02/09 21:47:10 neilg Exp $
*/
public final class XMLValidator
implements DefaultEntityHandler.EventHandler,
@@ -1396,16 +1396,14 @@
fCurrentScope = fScopeStack[fElementDepth];
- //if ( DEBUG_SCHEMA_VALIDATION ) {
+ if ( DEBUG_SCHEMA_VALIDATION ) {
-/****
-System.out.println("+++++ currentElement : " + fStringPool.toString(elementType)+
+ System.out.println("+++++ currentElement : " + fStringPool.toString(elementType)+
"\n fCurrentElementIndex : " + fCurrentElementIndex +
"\n fCurrentScope : " + fCurrentScope +
"\n fCurrentContentSpecType : " + fCurrentContentSpecType +
"\n++++++++++++++++++++++++++++++++++++++++++++++++" );
-/****/
- //}
+ }
// if enclosing element's Schema is different, need to switch "context"
if ( fGrammarNameSpaceIndex != fGrammarNameSpaceIndexStack[fElementDepth] ) {
@@ -2330,6 +2328,8 @@
if (fNamespacesScope == null) {
fNamespacesScope = new NamespacesScope(this);
fNamespacesPrefix = fStringPool.addSymbol("xmlns");
+ //fNamespacesScope.setNamespaceForPrefix(fNamespacesPrefix, StringPool.EMPTY_STRING);
+ // xxxxx
fNamespacesScope.setNamespaceForPrefix(fNamespacesPrefix, -1);
int xmlSymbol = fStringPool.addSymbol("xml");
int xmlNamespace = fStringPool.addSymbol("http://www.w3.org/XML/1998/namespace");
@@ -2483,7 +2483,6 @@
//schemaCandidateURIs.removeElement(uri);
}
}
-
//TO DO: This should be a feature that can be turned on or off
/*****
for (int i=0; i< schemaCandidateURIs.size(); i++) {
@@ -2599,7 +2598,7 @@
//e.printStackTrace();
reportRecoverableXMLError( XMLMessages.MSG_GENERIC_SCHEMA_ERROR,
XMLMessages.SCHEMA_GENERIC_ERROR, e.getMessage() );
- }
+ }
Document document = parser.getDocument(); //Our Grammar
@@ -2624,6 +2623,9 @@
grammar = new SchemaGrammar();
grammar.setGrammarDocument(document);
+ // Since we've just constructed a schema grammar, we should make sure we know what we've done.
+ fGrammarIsSchemaGrammar = true;
+ fGrammarIsDTDGrammar = false;
//At this point we should expand the registry table.
@@ -2816,7 +2818,7 @@
boolean skipThisOne = false;
boolean laxThisOne = false;
- if ( fGrammarIsSchemaGrammar && fContentLeafStack[fElementDepth] != null ) {
+ if ( fGrammarIsSchemaGrammar && fElementDepth > -1 && fContentLeafStack[fElementDepth] != null ) {
ContentLeafNameTypeVector cv = fContentLeafStack[fElementDepth];
QName[] fElemMap = cv.leafNames;
@@ -2944,10 +2946,10 @@
}
}
//if still can't resolve it, try TOP_LEVEL_SCOPE AGAIN
- /****
- if ( element.uri == -1 && elementIndex == -1
+ /****/
+ if ( element.uri == StringPool.EMPTY_STRING && elementIndex == -1
&& fNamespacesScope != null
- && fNamespacesScope.getNamespaceForPrefix(StringPool.EMPTY_STRING) != -1 ) {
+ && fNamespacesScope.getNamespaceForPrefix(StringPool.EMPTY_STRING) != StringPool.EMPTY_STRING ) {
elementIndex = fGrammar.getElementDeclIndex(element.localpart, TOP_LEVEL_SCOPE);
// REVISIT:
// this is a hack to handle the situation where namespace prefix "" is bound to nothing, and there
1.8 +2 -2 xml-xerces/java/src/org/apache/xerces/msg/SchemaMessages.java
Index: SchemaMessages.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/msg/SchemaMessages.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SchemaMessages.java 2001/01/25 07:18:31 1.7
+++ SchemaMessages.java 2001/02/09 21:47:11 1.8
@@ -63,7 +63,7 @@
* This file contains error and warning messages for the Schema validator
* The messages are arranged in key and value tuples in a ListResourceBundle.
*
- * @version $Id: SchemaMessages.java,v 1.7 2001/01/25 07:18:31 andyc Exp $
+ * @version $Id: SchemaMessages.java,v 1.8 2001/02/09 21:47:11 neilg Exp $
*/
public class SchemaMessages extends ListResourceBundle {
/** The list resource bundle contents. */
@@ -82,7 +82,7 @@
{ "OrderIsAll", "{0} not allowed if the order is all."},
{ "DatatypeWithType", "Datatype qualifiers can only be used if you specify a type attribute."},
{ "DatatypeQualUnsupported", "The datatype qualifier {0} is not supported."},
- { "GroupContentRestricted", "Error: {0} content must be one of element, group, modelGroupRef. Saw {1}"},
+ { "GroupContentRestricted", "Error: {0} content must be one of choice, all or sequence. Saw {1}"},
{ "UnknownBaseDatatype", "Unknown base type {0} for type {1}." },
{ "BadAttWithRef", "cannot use ref with any of type, block, final, abstract, nullable, default or fixed."},
{ "NoContentForRef", "Cannot have child content for an element declaration that has a ref attribute" },