You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/06/03 04:34:58 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema SchemaGrammar.java SchemaSymbols.java TraverseSchema.java
ericye 00/06/02 19:34:58
Modified: java/src/org/apache/xerces/validators/schema
SchemaGrammar.java SchemaSymbols.java
TraverseSchema.java
Log:
a bunch of bug Fixes on schema validation --ericye
Revision Changes Path
1.7 +3 -3 xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaGrammar.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SchemaGrammar.java 2000/06/02 05:39:07 1.6
+++ SchemaGrammar.java 2000/06/03 02:34:57 1.7
@@ -56,7 +56,7 @@
* <http://www.apache.org/>.
*/
/*
- * @version $Id: SchemaGrammar.java,v 1.6 2000/06/02 05:39:07 jeffreyr Exp $
+ * @version $Id: SchemaGrammar.java,v 1.7 2000/06/03 02:34:57 ericye Exp $
*/
package org.apache.xerces.validators.schema;
@@ -325,7 +325,7 @@
int enumeration, int attDefaultType,
String attDefaultValue, DatatypeValidator dv){
int attrDeclIndex = createAttributeDecl();
- fTempAttributeDecl.name = attQName;
+ fTempAttributeDecl.name.setValues(attQName);
fTempAttributeDecl.datatypeValidator = dv;
fTempAttributeDecl.type = attType;
fTempAttributeDecl.defaultType = attDefaultType;
@@ -343,6 +343,7 @@
int attDefIndex = getFirstAttributeDeclIndex(elementIndex);
while (attDefIndex != -1) {
getAttributeDecl(attDefIndex, fTempAttributeDecl);
+
if (fTempAttributeDecl.name.localpart == attribute.localpart &&
fTempAttributeDecl.name.uri == attribute.uri ) {
return attDefIndex;
@@ -350,7 +351,6 @@
attDefIndex = getNextAttributeDeclIndex(attDefIndex);
}
return -1;
-
} // getAttDef(int,QName)
/**
1.3 +2 -2 xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaSymbols.java
Index: SchemaSymbols.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaSymbols.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SchemaSymbols.java 2000/05/17 18:33:26 1.2
+++ SchemaSymbols.java 2000/06/03 02:34:57 1.3
@@ -94,10 +94,10 @@
public static final String ELT_LENGTH = "length";
public static final String ELT_MAXEXCLUSIVE = "maxExclusive";
public static final String ELT_MAXINCLUSIVE = "maxInclusive";
- public static final String ELT_MAXLENGTH = "maxlength";
+ public static final String ELT_MAXLENGTH = "maxLength";
public static final String ELT_MINEXCLUSIVE = "minExclusive";
public static final String ELT_MININCLUSIVE = "minInclusive";
- public static final String ELT_MINLENGTH = "minlength";
+ public static final String ELT_MINLENGTH = "minLength";
public static final String ELT_NOTATION = "notation";
public static final String ELT_PATTERN = "pattern";
public static final String ELT_PERIOD = "period";
1.12 +39 -20 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TraverseSchema.java 2000/06/02 05:39:07 1.11
+++ TraverseSchema.java 2000/06/03 02:34:57 1.12
@@ -374,7 +374,7 @@
* Eric Ye
* @see org.apache.xerces.validators.common.Grammar
*
- * @version $Id: TraverseSchema.java,v 1.11 2000/06/02 05:39:07 jeffreyr Exp $
+ * @version $Id: TraverseSchema.java,v 1.12 2000/06/03 02:34:57 ericye Exp $
*/
public class TraverseSchema implements
@@ -1272,6 +1272,8 @@
Hashtable facetData = new Hashtable();
Vector enumData = new Vector();
+
+ //REVISIT: there is a better way to do this,
for (child = XUtil.getFirstChildElement(complexTypeDecl);
child != null && (child.getNodeName().equals(SchemaSymbols.ELT_MINEXCLUSIVE) ||
child.getNodeName().equals(SchemaSymbols.ELT_MININCLUSIVE) ||
@@ -1311,16 +1313,18 @@
facetData.put(SchemaSymbols.ELT_ENUMERATION, enumData);
}
- // overide the facets of the baseTypeValidator
- // Talk with Eric - This is not allowed in the new Architecture
//if (numFacets > 0)
// baseTypeValidator.setFacets(facetData, derivedBy );
-
- // now we are ready with our own simpleTypeValidator
- simpleTypeValidator = baseTypeValidator;
+ if (numFacets > 0) {
+ simpleTypeValidator = fDatatypeRegistry.createDatatypeValidator( typeName, baseTypeValidator,
+ facetData, false );
+ }
+ else
+ simpleTypeValidator = baseTypeValidator;
if (child != null) {
- reportGenericSchemaError("Invalid Schema Document");
+ reportGenericSchemaError("Invalid child '"+child.getNodeName()+"' in complexType : '" + typeName
+ + "', because it restricts another complexSimpleType");
}
}
@@ -1330,7 +1334,8 @@
if (base.length() == 0) {
simpleTypeValidator = baseTypeValidator = fDatatypeRegistry.getDatatypeValidator(SchemaSymbols.ATTVAL_STRING);
}
- else if (fDatatypeRegistry.getDatatypeValidator(base) == null) // must be datatype
+ else if (fDatatypeRegistry.getDatatypeValidator(base) == null
+ && baseTypeInfo.datatypeValidator==null ) // must be datatype
reportSchemaError(SchemaMessageProvider.NotADatatype,
new Object [] { base }); //REVISIT check forward refs
//handle datatypes
@@ -1444,7 +1449,11 @@
contentSpecType = fStringPool.addSymbol("ANY");
left = -1;
}
- else { // datatype qual
+ else if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
+ //REVISIT, do nothing for annotation for now.
+ }
+ else { // datatype qual
+ if (!baseIsComplexSimple )
if (base.equals(""))
reportSchemaError(SchemaMessageProvider.DatatypeWithType, null);
else
@@ -1472,7 +1481,7 @@
}
if (seeAll) {
- //TO DO:
+ //TO DO: REVISIT
//check the minOccurs = 1 and maxOccurs = 1
}
@@ -1564,32 +1573,39 @@
traverseAttributeGroupDecl(child,typeInfo);
}
}
- typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);
// merge in base type's attribute decls
if (baseTypeInfo != null && baseTypeInfo.attlistHead > -1 ) {
int attDefIndex = baseTypeInfo.attlistHead;
while ( attDefIndex > -1 ) {
+ fTempAttributeDecl.clear();
fSchemaGrammar.getAttributeDecl(attDefIndex, fTempAttributeDecl);
- attDefIndex = fSchemaGrammar.getNextAttributeDeclIndex(attDefIndex);
// if found a duplicate, if it is derived by restriction. then skip the one from the base type
- if (fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, fTempAttributeDecl.name) > -1) {
+ /**/
+ int temp = fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, fTempAttributeDecl.name);
+ if ( temp > -1) {
if (derivedByRestriction) {
+ attDefIndex = fSchemaGrammar.getNextAttributeDeclIndex(attDefIndex);
continue;
}
}
+ /**/
//REVISIT:
// int enumeration = ????
fSchemaGrammar.addAttDef( typeInfo.templateElementIndex,
fTempAttributeDecl.name, fTempAttributeDecl.type,
-1, fTempAttributeDecl.defaultType,
fTempAttributeDecl.defaultValue, fTempAttributeDecl.datatypeValidator);
+ attDefIndex = fSchemaGrammar.getNextAttributeDeclIndex(attDefIndex);
}
}
+ typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);
+
if (!typeName.startsWith("#")) {
typeName = fTargetNSURIString + "," + typeName;
}
+ typeInfo.typeName = new String(typeName);
fComplexTypeRegistry.put(typeName,typeInfo);
// before exit the complex type definition, restore the scope, mainly for nested Anonymous Types
@@ -1708,8 +1724,8 @@
for (int i=0; i < (min-1); i++) {
index = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_SEQ,
- index,
leafIndex,
+ index,
false);
}
@@ -2335,7 +2351,8 @@
}
}
- ComplexTypeInfo typeInfo = new ComplexTypeInfo();
+ //ComplexTypeInfo typeInfo = new ComplexTypeInfo();
+ ComplexTypeInfo typeInfo = null;
// element has a single child element, either a datatype or a type, null if primitive
Element child = XUtil.getFirstChildElement(elementDecl);
@@ -2351,7 +2368,7 @@
if (childName.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
if (child.getAttribute(SchemaSymbols.ATT_NAME).length() > 0) {
- reportGenericSchemaError("anoymous complexType error element '" + name +"' has a name attribute");
+ reportGenericSchemaError("anonymous complexType in element '" + name +"' has a name attribute");
}
else
typeNameIndex = traverseComplexTypeDecl(child);
@@ -2362,13 +2379,14 @@
else {
reportGenericSchemaError("traverse complexType error in element '" + name +"'");
}
-
+ //System.out.println("typeInfo.scopeDefined : " + typeInfo.typeName+","+"["+typeInfo.scopeDefined+"]"
+ // +", base is " + fSchemaGrammar.getElementDeclIndex(fStringPool.addSymbol("heater"), typeInfo.baseComplexTypeInfo.scopeDefined));
haveAnonType = true;
}
else if (childName.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
// TO DO: the Default and fixed attribute handling should be here.
if (child.getAttribute(SchemaSymbols.ATT_NAME).length() > 0) {
- reportGenericSchemaError("anoymous complexType error element '" + name +"' has a name attribute");
+ reportGenericSchemaError("anonymous simpleType in element '" + name +"' has a name attribute");
}
else
typeNameIndex = traverseSimpleTypeDecl(child);
@@ -2378,7 +2396,7 @@
else {
reportGenericSchemaError("traverse simpleType error in element '" + name +"'");
}
-
+ contentSpecType = XMLElementDecl.TYPE_SIMPLE;
haveAnonType = true;
} else if (type.equals("")) { // "ur-typed" leaf
contentSpecType = XMLElementDecl.TYPE_ANY;
@@ -2392,7 +2410,8 @@
}
if (haveAnonType && (type.length()>0)) {
- reportGenericSchemaError( "can have type when have a annoymous type" );
+ reportGenericSchemaError( "Element '"+ name +
+ "' have both a type attribute and a annoymous type child" );
}
// type specified as an attribute and no child is type decl.
else if (!type.equals("")) {