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/11/03 03:17:29 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/validation/grammars SchemaGrammar.java
ericye 00/11/02 18:17:29
Modified: java/src/org/apache/xerces/impl/validation/grammars Tag:
xerces_j_2 SchemaGrammar.java
Log:
beginning to flesh out SchemaGrammar
Revision Changes Path
No revision
No revision
1.1.2.3 +128 -1 xml-xerces/java/src/org/apache/xerces/impl/validation/grammars/Attic/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/grammars/Attic/SchemaGrammar.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- SchemaGrammar.java 2000/10/02 00:40:10 1.1.2.2
+++ SchemaGrammar.java 2000/11/03 02:17:28 1.1.2.3
@@ -59,15 +59,78 @@
import org.apache.xerces.impl.validation.Grammar;
import org.apache.xerces.impl.validation.GrammarPool;
+
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.impl.validation.XMLContentSpec;
+import org.apache.xerces.impl.validation.DatatypeValidator;
+import org.apache.xerces.impl.validation.datatypes.DatatypeValidatorFactoryImpl;
+import org.apache.xerces.impl.validation.XMLAttributeDecl;
+import org.apache.xerces.impl.validation.ContentModelValidator;
+import org.apache.xerces.impl.validation.XMLElementDecl;
+
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.xml.sax.helpers.NamespaceSupport;
+import java.util.Hashtable;
+
/**
+ * @author ericye, IBM
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
- * @version $Id: SchemaGrammar.java,v 1.1.2.2 2000/10/02 00:40:10 lehors Exp $
+ * @version $Id: SchemaGrammar.java,v 1.1.2.3 2000/11/03 02:17:28 ericye Exp $
*/
public class SchemaGrammar
extends Grammar {
+ // Constants
+ //
+
+ private static final int CHUNK_SHIFT = 8; // 2^8 = 256
+ private static final int CHUNK_SIZE = (1 << CHUNK_SHIFT);
+ private static final int CHUNK_MASK = CHUNK_SIZE - 1;
+ private static final int INITIAL_CHUNK_COUNT = (1 << (10 - CHUNK_SHIFT)); // 2^10 = 1k
+
+ //Temp objects for decls structs.
+ private XMLContentSpec fTempContentSpecNode = new XMLContentSpec();
+ private XMLElementDecl fTempElementDecl = new XMLElementDecl();
+ private XMLAttributeDecl fTempAttributeDecl = new XMLAttributeDecl();
+
+ //
+ // Data
+ //
+
+ // basic information
+
+ // private Element fGrammarDocument;
+
+ // element decl tables that used only by Schemas
+ // these arrays are indexed by elementdeclindex.
+
+ private int fScopeDefinedByElement[][] = new int[INITIAL_CHUNK_COUNT][];
+ private String fFromAnotherSchemaURI[][] = new String[INITIAL_CHUNK_COUNT][];
+ //private TraverseSchema.ComplexTypeInfo fComplexTypeInfo[][] =
+ //new TraverseSchema.ComplexTypeInfo[INITIAL_CHUNK_COUNT][];
+ private int fElementDeclDefaultType[][] = new int[INITIAL_CHUNK_COUNT][];
+ private String fElementDeclDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
+ private String fElementDeclEquivClassFullName[][] = 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;
+ private Hashtable fAttributeDeclRegistry = null;
+ private DatatypeValidatorFactoryImpl fDatatypeRegistry = null;
+
+ // Hashes top level group , attributegroup, and attribute components (dom elements) by their name
+ Hashtable topLevelGroupDecls = new Hashtable();
+ Hashtable topLevelAttrDecls = new Hashtable();
+ Hashtable topLevelAttrGrpDecls = new Hashtable();
+
+ private NamespaceSupport fNamespacesMaps = null;
+ private String fTargetNamespaceURI = "";
+
//
// Constructors
//
@@ -94,5 +157,69 @@
*/
public SchemaGrammar(Document grammarDocument, GrammarPool grammarPool) {
}
+
+ //
+ // Private methods
+ //
+
+ // ensure capacity
+
+ private boolean ensureElementDeclCapacity(int chunk) {
+ try {
+ return fScopeDefinedByElement[chunk][0] == -2;
+ }
+ catch (ArrayIndexOutOfBoundsException ex) {
+ fScopeDefinedByElement= resize(fScopeDefinedByElement, fScopeDefinedByElement.length * 2);
+ fFromAnotherSchemaURI = resize(fFromAnotherSchemaURI, fFromAnotherSchemaURI.length *2);
+ //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);
+ fElementDeclEquivClassFullName = resize(fElementDeclEquivClassFullName,fElementDeclEquivClassFullName.length*2);
+ }
+ catch (NullPointerException ex) {
+ // ignore
+ }
+ fScopeDefinedByElement[chunk] = new int[CHUNK_SIZE];
+ for (int i=0; i<CHUNK_SIZE; i++) {
+ 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];
+ fElementDeclEquivClassFullName[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;
+ }
+
+
+ // resize initial chunk
+
+ private int[][] resize(int array[][], int newsize) {
+ int newarray[][] = new int[newsize][];
+ System.arraycopy(array, 0, newarray, 0, array.length);
+ return newarray;
+ }
+
+
+ private String[][] resize(String array[][], int newsize) {
+ String newarray[][] = new String[newsize][];
+ System.arraycopy(array, 0, newarray, 0, array.length);
+ return newarray;
+ }
+
+ /***
+ private TraverseSchema.ComplexTypeInfo[][] resize(TraverseSchema.ComplexTypeInfo array[][], int newsize) {
+ TraverseSchema.ComplexTypeInfo newarray[][] = new TraverseSchema.ComplexTypeInfo[newsize][];
+ System.arraycopy(array, 0, newarray, 0, array.length);
+ return newarray;
+ }
+ /****/
+
} // class SchemaGrammar