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 2001/11/01 22:24:27 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs SchemaGrammar.java
sandygao 01/11/01 13:24:27
Modified: java/src/org/apache/xerces/impl/xs SchemaGrammar.java
Log:
Store substitution group information in the grammar.
We'll need to collect such information from different grammars, so that
substitution group handle can calculate {substitution group} for a given
global element decl.
Revision Changes Path
1.2 +33 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SchemaGrammar.java 2001/10/25 20:36:02 1.1
+++ SchemaGrammar.java 2001/11/01 21:24:27 1.2
@@ -71,7 +71,7 @@
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
- * @version $Id: SchemaGrammar.java,v 1.1 2001/10/25 20:36:02 elena Exp $
+ * @version $Id: SchemaGrammar.java,v 1.2 2001/11/01 21:24:27 sandygao Exp $
*/
public class SchemaGrammar {
@@ -305,6 +305,14 @@
*/
public final void addGlobalElementDecl(XSElementDecl decl) {
fGlobalElemDecls.put(decl.fName, decl);
+
+ // if there is a substitution group affiliation, store in an array,
+ // for further constraint checking: UPA, PD, EDC
+ if (decl.fSubGroup != null) {
+ if (fSubGroupCount == fSubGroups.length)
+ fSubGroups = resize(fSubGroups, fSubGroupCount+INC_SIZE);
+ fSubGroups[fSubGroupCount++] = decl;
+ }
}
/**
@@ -387,6 +395,8 @@
// array to store complex type decls
private static final int INITIAL_SIZE = 16;
+ private static final int INC_SIZE = 16;
+
private int fCTCount = 0;
private XSComplexTypeDecl[] fComplexTypeDecls = new XSComplexTypeDecl[INITIAL_SIZE];
@@ -395,7 +405,7 @@
*/
final void addComplexTypeDecl(XSComplexTypeDecl decl) {
if (fCTCount == fComplexTypeDecls.length)
- fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount*2);
+ fComplexTypeDecls = resize(fComplexTypeDecls, fCTCount+INC_SIZE);
fComplexTypeDecls[fCTCount++] = decl;
}
@@ -408,6 +418,20 @@
return fComplexTypeDecls;
}
+ // used to store all substitution group information declared in
+ // this namespace
+ private int fSubGroupCount = 0;
+ private XSElementDecl[] fSubGroups = new XSElementDecl[INITIAL_SIZE];
+
+ /**
+ * get all substitution group information: for the 3 constraint checking
+ */
+ final XSElementDecl[] getSubstitutionGroups() {
+ if (fSubGroupCount < fSubGroups.length)
+ fSubGroups = resize(fSubGroups, fSubGroupCount);
+ return fSubGroups;
+ }
+
// anyType and anySimpleType: because there are so many places where
// we need direct access to these two types
public final static XSComplexTypeDecl fAnyType = new XSComplexTypeDecl();
@@ -442,5 +466,11 @@
System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
return newArray;
}
+
+ static final XSElementDecl[] resize(XSElementDecl[] oldArray, int newSize) {
+ XSElementDecl[] newArray = new XSElementDecl[newSize];
+ System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
+ return newArray;
+ }
-} // class SchemaGrammar
+ } // class SchemaGrammar
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org