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/07/04 01:41:49 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema SchemaGrammar.java SchemaSymbols.java TraverseSchema.java
ericye 00/07/03 16:41:45
Modified: java/src/org/apache/xerces/validators/schema
SchemaGrammar.java SchemaSymbols.java
TraverseSchema.java
Log:
1. parse out block, final, abstract for both element and type, and nullable for element,
2. save these properties in the SchemaGrammar
--ericye
Revision Changes Path
1.9 +86 -25 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SchemaGrammar.java 2000/06/29 20:29:56 1.8
+++ SchemaGrammar.java 2000/07/03 23:41:33 1.9
@@ -56,7 +56,7 @@
* <http://www.apache.org/>.
*/
/*
- * @version $Id: SchemaGrammar.java,v 1.8 2000/06/29 20:29:56 ericye Exp $
+ * @version $Id: SchemaGrammar.java,v 1.9 2000/07/03 23:41:33 ericye Exp $
*/
package org.apache.xerces.validators.schema;
@@ -109,6 +109,9 @@
new TraverseSchema.ComplexTypeInfo[INITIAL_CHUNK_COUNT][];
private int fElementDeclDefaultType[][] = new int[INITIAL_CHUNK_COUNT][];
private String fElementDeclDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
+ private int fElementDeclBlockSet[][] = new int[INITIAL_CHUNK_COUNT][];
+ private int fElementDeclFinalSet[][] = new int[INITIAL_CHUNK_COUNT][];
+ private int fElementDeclMiscFlags[][] = new int[INITIAL_CHUNK_COUNT][];
//ComplexType and SimpleTypeRegistries
private Hashtable fComplexTypeRegistry = null;
@@ -156,6 +159,7 @@
return fScopeDefinedByElement[chunk][index];
}
+
public int getElementDefaultTYpe(int elementDeclIndex) {
if (elementDeclIndex < -1) {
@@ -167,6 +171,36 @@
}
+ public int getElementDeclBlockSet(int elementDeclIndex) {
+
+ if (elementDeclIndex < -1) {
+ return -1;
+ }
+ int chunk = elementDeclIndex >> CHUNK_SHIFT;
+ int index = elementDeclIndex & CHUNK_MASK;
+ return fElementDeclBlockSet[chunk][index];
+ }
+
+ public int getElementDeclFinalSet(int elementDeclIndex) {
+
+ if (elementDeclIndex < -1) {
+ return -1;
+ }
+ int chunk = elementDeclIndex >> CHUNK_SHIFT;
+ int index = elementDeclIndex & CHUNK_MASK;
+ return fElementDeclFinalSet[chunk][index];
+ }
+
+ public int getElementDeclMiscFlags(int elementDeclIndex) {
+
+ if (elementDeclIndex < -1) {
+ return -1;
+ }
+ int chunk = elementDeclIndex >> CHUNK_SHIFT;
+ int index = elementDeclIndex & CHUNK_MASK;
+ return fElementDeclMiscFlags[chunk][index];
+ }
+
public String getElementFromAnotherSchemaURI(int elementDeclIndex) {
if (elementDeclIndex < 0 ) {
@@ -256,46 +290,65 @@
protected void setElementDefinedScope(int elementDeclIndex, int scopeDefined) {
int chunk = elementDeclIndex >> CHUNK_SHIFT;
int index = elementDeclIndex & CHUNK_MASK;
- //if ( ensureElementDeclCapacity(chunk) ) { // create an ElementDecl
ensureElementDeclCapacity(chunk);
- if (elementDeclIndex > -1 ) {
- fScopeDefinedByElement[chunk][index] = scopeDefined;
- }
- //}
+ if (elementDeclIndex > -1 ) {
+ fScopeDefinedByElement[chunk][index] = scopeDefined;
+ }
}
protected void setElementFromAnotherSchemaURI(int elementDeclIndex, String anotherSchemaURI) {
int chunk = elementDeclIndex >> CHUNK_SHIFT;
int index = elementDeclIndex & CHUNK_MASK;
- //if ( ensureElementDeclCapacity(chunk) ) { // create an ElementDecl
ensureElementDeclCapacity(chunk);
- if (elementDeclIndex > -1 ) {
- fFromAnotherSchemaURI[chunk][index] = anotherSchemaURI;
- }
- //}
+ if (elementDeclIndex > -1 ) {
+ fFromAnotherSchemaURI[chunk][index] = anotherSchemaURI;
+ }
}
protected void setElementComplexTypeInfo(int elementDeclIndex, TraverseSchema.ComplexTypeInfo typeInfo){
int chunk = elementDeclIndex >> CHUNK_SHIFT;
int index = elementDeclIndex & CHUNK_MASK;
- //if ( ensureElementDeclCapacity(chunk) ) { // create an ElementDecl
- ensureElementDeclCapacity(chunk);
- if (elementDeclIndex > -1 ) {
- fComplexTypeInfo[chunk][index] = typeInfo;
- }
- //}
+ ensureElementDeclCapacity(chunk);
+ if (elementDeclIndex > -1 ) {
+ fComplexTypeInfo[chunk][index] = typeInfo;
+ }
}
protected void setElementDefault(int elementDeclIndex, int defaultType, String defaultValue) {
int chunk = elementDeclIndex >> CHUNK_SHIFT;
int index = elementDeclIndex & CHUNK_MASK;
- //if ( ensureElementDeclCapacity(chunk) ) { // create an ElementDecl
- ensureElementDeclCapacity(chunk);
- if (elementDeclIndex > -1 ) {
- fElementDeclDefaultType[chunk][index] = defaultType;
- fElementDeclDefaultValue[chunk][index] = defaultValue;
- }
- //}
+ ensureElementDeclCapacity(chunk);
+ if (elementDeclIndex > -1 ) {
+ fElementDeclDefaultType[chunk][index] = defaultType;
+ fElementDeclDefaultValue[chunk][index] = defaultValue;
+ }
+ }
+
+ protected void setElementDeclBlockSet(int elementDeclIndex, int blockSet) {
+ int chunk = elementDeclIndex >> CHUNK_SHIFT;
+ int index = elementDeclIndex & CHUNK_MASK;
+ ensureElementDeclCapacity(chunk);
+ if (elementDeclIndex > -1 ) {
+ fElementDeclBlockSet[chunk][index] = blockSet;
+ }
+ }
+
+ protected void setElementDeclFinalSet(int elementDeclIndex, int finalSet) {
+ int chunk = elementDeclIndex >> CHUNK_SHIFT;
+ int index = elementDeclIndex & CHUNK_MASK;
+ ensureElementDeclCapacity(chunk);
+ if (elementDeclIndex > -1 ) {
+ fElementDeclFinalSet[chunk][index] = finalSet;
+ }
+ }
+
+ protected void setElementDeclMiscFlags(int elementDeclIndex, int miscFlags) {
+ int chunk = elementDeclIndex >> CHUNK_SHIFT;
+ int index = elementDeclIndex & CHUNK_MASK;
+ ensureElementDeclCapacity(chunk);
+ if (elementDeclIndex > -1 ) {
+ fElementDeclMiscFlags[chunk][index] = miscFlags;
+ }
}
//add methods for TraverseSchema
@@ -404,16 +457,24 @@
fComplexTypeInfo = resize(fComplexTypeInfo, fComplexTypeInfo.length *2);
fElementDeclDefaultType = resize(fElementDeclDefaultType,fElementDeclDefaultType.length*2);
fElementDeclDefaultValue = resize(fElementDeclDefaultValue,fElementDeclDefaultValue.length*2);
+ fElementDeclBlockSet = resize(fElementDeclBlockSet,fElementDeclBlockSet.length*2);
+ fElementDeclFinalSet = resize(fElementDeclFinalSet,fElementDeclFinalSet.length*2);
+ fElementDeclMiscFlags = resize(fElementDeclMiscFlags,fElementDeclMiscFlags.length*2);
}
catch (NullPointerException ex) {
// ignore
}
fScopeDefinedByElement[chunk] = new int[CHUNK_SIZE];
for (int i=0; i<CHUNK_SIZE; i++) {
- fScopeDefinedByElement[chunk][i] = -2;
+ fScopeDefinedByElement[chunk][i] = -2; //-1, 0 are all valid scope value.
}
fFromAnotherSchemaURI[chunk] = new String[CHUNK_SIZE];
fComplexTypeInfo[chunk] = new TraverseSchema.ComplexTypeInfo[CHUNK_SIZE];
+ fElementDeclDefaultType[chunk] = new int[CHUNK_SIZE];
+ fElementDeclDefaultValue[chunk] = new String[CHUNK_SIZE];
+ fElementDeclBlockSet[chunk] = new int[CHUNK_SIZE]; // initialized to 0
+ fElementDeclFinalSet[chunk] = new int[CHUNK_SIZE]; // initialized to 0
+ fElementDeclMiscFlags[chunk] = new int[CHUNK_SIZE]; // initialized to 0
return true;
}
1.4 +4 -0 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SchemaSymbols.java 2000/06/03 02:34:57 1.3
+++ SchemaSymbols.java 2000/07/03 23:41:34 1.4
@@ -145,6 +145,7 @@
public static final String ATTVAL_ELEMENTONLY = "elementOnly";
public static final String ATTVAL_EMPTY = "empty";
public static final String ATTVAL_EXTENSION = "extension";
+ public static final String ATTVAL_FALSE = "false";
public static final String ATTVAL_FIXED = "fixed";
public static final String ATTVAL_HEX = "hex";
public static final String ATTVAL_ID = "ID";
@@ -164,6 +165,7 @@
public static final String ATTVAL_STRING = "string";
public static final String ATTVAL_TEXTONLY = "textOnly";
public static final String ATTVAL_TIMEDURATION = "timeDuration";
+ public static final String ATTVAL_TRUE = "true";
public static final String ATTVAL_UNQUALIFIED = "unqualified";
public static final String ATTVAL_URI = "uri";
public static final String ATTVAL_URIREFERENCE = "uriReference";
@@ -184,5 +186,7 @@
public static final int INFINITY = -1; // used for maxOccurs
+ public static final int NULLABLE = 1;
+ public static final int ABSTRACT = 2;
}
1.32 +38 -7 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.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- TraverseSchema.java 2000/06/30 01:26:28 1.31
+++ TraverseSchema.java 2000/07/03 23:41:34 1.32
@@ -374,7 +374,7 @@
* Eric Ye
* @see org.apache.xerces.validators.common.Grammar
*
- * @version $Id: TraverseSchema.java,v 1.31 2000/06/30 01:26:28 ericye Exp $
+ * @version $Id: TraverseSchema.java,v 1.32 2000/07/03 23:41:34 ericye Exp $
*/
public class TraverseSchema implements
@@ -431,10 +431,13 @@
public DatatypeValidator baseDataTypeValidator;
public ComplexTypeInfo baseComplexTypeInfo;
- public int derivedBy;
- public int blockSet;
- public int finalSet;
+ public int derivedBy = 0;
+ public int blockSet = 0;
+ public int finalSet = 0;
+
+ public boolean isAbstract = false;
+
public int scopeDefined = -1;
public int contentType;
@@ -1664,6 +1667,7 @@
typeInfo.datatypeValidator = simpleTypeValidator;
typeInfo.blockSet = parseBlockSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_BLOCK));
typeInfo.finalSet = parseFinalSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_FINAL));
+ typeInfo.isAbstract = isAbstract.equals(SchemaSymbols.ATTVAL_TRUE) ? true:false ;
//add a template element to the grammar element decl pool.
int typeNameIndex = fStringPool.addSymbol(typeName);
@@ -1687,7 +1691,11 @@
if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
if ((baseIsComplexSimple||baseIsSimpleSimple) && derivedByRestriction) {
// REVISIT: Localize
- reportGenericSchemaError("In complexType "+typeName+", base type has simpleType content and derivation method is 'restriction', can't have any attribute children at all");
+ reportGenericSchemaError("In complexType "+typeName+
+ ", base type has simpleType "+
+ "content and derivation method is"+
+ " 'restriction', can't have any "+
+ "attribute children at all");
break;
}
traverseAttributeDecl(child, typeInfo);
@@ -1695,7 +1703,10 @@
else if ( childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ) {
if ((baseIsComplexSimple||baseIsSimpleSimple) && derivedByRestriction) {
// REVISIT: Localize
- reportGenericSchemaError("In complexType "+typeName+", base type has simpleType content and derivation method is 'restriction', can't have any attribute children at all");
+ reportGenericSchemaError("In complexType "+typeName+", base "+
+ "type has simpleType content and "+
+ "derivation method is 'restriction',"+
+ " can't have any attribute children at all");
break;
}
traverseAttributeGroupDecl(child,typeInfo);
@@ -2410,7 +2421,23 @@
return new QName(-1,nameIndex,nameIndex,fTargetNSURI);
}
}
+
+ // parse out 'block', 'final', 'nullable', 'abstract'
+ int blockSet = parseBlockSet(elementDecl.getAttribute(SchemaSymbols.ATT_BLOCK));
+ int finalSet = parseFinalSet(elementDecl.getAttribute(SchemaSymbols.ATT_FINAL));
+ boolean isNullable = elementDecl.getAttribute
+ (SchemaSymbols.ATT_NULLABLE).equals(SchemaSymbols.ATTVAL_TRUE)? true:false;
+ boolean isAbstract = elementDecl.getAttribute
+ (SchemaSymbols.ATT_ABSTRACT).equals(SchemaSymbols.ATTVAL_TRUE)? true:false;
+ int elementMiscFlags = 0;
+ if (isNullable) {
+ elementMiscFlags += SchemaSymbols.NULLABLE;
+ }
+ if (isAbstract) {
+ elementMiscFlags += SchemaSymbols.ABSTRACT;
+ }
+ //if this is a reference to a global element
int attrCount = 0;
if (!ref.equals("")) attrCount++;
if (!type.equals("")) attrCount++;
@@ -2727,7 +2754,11 @@
// mark element if its type belongs to different Schema.
fSchemaGrammar.setElementFromAnotherSchemaURI(elementIndex, fromAnotherSchema);
-
+ // set BlockSet, FinalSet, Nullable and Abstract for this element decl
+ fSchemaGrammar.setElementDeclBlockSet(elementIndex, blockSet);
+ fSchemaGrammar.setElementDeclFinalSet(elementIndex, finalSet);
+ fSchemaGrammar.setElementDeclMiscFlags(elementIndex, elementMiscFlags);
+
return eltQName;
}// end of method traverseElementDecl(Element)