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/10/18 20:41:18 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 XSDHandler.java XSDFACM.java XSDElementTraverser.java XSDComplexTypeTraverser.java XSDAttributeTraverser.java XSDAbstractTraverser.java XSCMLeaf.java SchemaValidator.java CMBuilder.java
sandygao 01/10/18 11:41:18
Modified: java/src/org/apache/xerces/impl/v2 XSDHandler.java
XSDFACM.java XSDElementTraverser.java
XSDComplexTypeTraverser.java
XSDAttributeTraverser.java
XSDAbstractTraverser.java XSCMLeaf.java
SchemaValidator.java CMBuilder.java
Log:
bug fixes, especially for DFA content model with wildcard.
Revision Changes Path
1.45 +2 -1 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- XSDHandler.java 2001/10/17 21:46:09 1.44
+++ XSDHandler.java 2001/10/18 18:41:18 1.45
@@ -97,7 +97,7 @@
* schema, other grammars may be constructed as a side-effect.
*
* @author Neil Graham, IBM
- * @version $Id: XSDHandler.java,v 1.44 2001/10/17 21:46:09 sandygao Exp $
+ * @version $Id: XSDHandler.java,v 1.45 2001/10/18 18:41:18 sandygao Exp $
*/
class XSDHandler {
@@ -1012,6 +1012,7 @@
fLocalElementDecl = newStackE;
int[] newStackI = new int[fLocalElemStackPos+INC_STACK_SIZE];
System.arraycopy(fAllContext, 0, newStackI, 0, fLocalElemStackPos);
+ fAllContext = newStackI;
String [][] newStackN = new String [fLocalElemStackPos+INC_STACK_SIZE][];
System.arraycopy(fLocalElemNamespaceContext, 0, newStackN, 0, fLocalElemStackPos);
fLocalElemNamespaceContext = newStackN;
1.7 +39 -39 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDFACM.java
Index: XSDFACM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDFACM.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSDFACM.java 2001/10/18 16:11:37 1.6
+++ XSDFACM.java 2001/10/18 18:41:18 1.7
@@ -69,7 +69,7 @@
* it then uses in its validation algorithm.
*
* @author Neil Graham, IBM
- * @version $Id: XSDFACM.java,v 1.6 2001/10/18 16:11:37 neilg Exp $
+ * @version $Id: XSDFACM.java,v 1.7 2001/10/18 18:41:18 sandygao Exp $
*/
public class XSDFACM
implements XSCMValidator {
@@ -94,16 +94,12 @@
// Data
//
- /* this is the SubstitutionGroupComparator object */
- // REVISIT: incorporate substitutionGroup handlling
-
/**
* This is the map of unique input symbol elements to indices into
* each state's per-input symbol transition table entry. This is part
* of the built DFA information that must be kept around to do the
* actual validation. Note tat since either XSElementDecl or XSParticleDecl object
* can live here, we've got to use an Object.
- * REVISIT: change XSElementDecl/XSParticleDecl so one inherits from the other.
*/
private Object fElemMap[] = null;
@@ -561,32 +557,31 @@
//fElemMap[outIndex] = new Object ();
fElemMap[outIndex] = null;
- /****
- This code commented out in the DTD version...
- if ( (fLeafListType[outIndex] & 0x0f) != 0 ) {
- if (fLeafNameTypeVector == null) {
- fLeafNameTypeVector = new ContentLeafNameTypeVector();
- }
- }
- ***/
-
- // Get the current leaf's element
- final XSElementDecl element = fLeafList[outIndex].getElement();
- if (element.fName == fEOCString)
- continue;
-
- // See if the current leaf node's element index is in the list
int inIndex = 0;
- for (; inIndex < fElemMapSize; inIndex++) {
- if (fElemMapType[inIndex] == fLeafListType[outIndex] &&
- ((XSElementDecl)fElemMap[inIndex]).fTargetNamespace == element.fTargetNamespace &&
+ final Object decl = fLeafList[outIndex].getDecl();
+ if (fLeafListType[outIndex] == XSParticleDecl.PARTICLE_WILDCARD) {
+ for (; inIndex < fElemMapSize; inIndex++) {
+ if (decl == fLeafList[inIndex])
+ break;
+ }
+ } else {
+ // Get the current leaf's element
+ final XSElementDecl element = (XSElementDecl)decl;
+ if (element.fName == fEOCString)
+ continue;
+
+ // See if the current leaf node's element index is in the list
+ for (; inIndex < fElemMapSize; inIndex++) {
+ if (fElemMapType[inIndex] == fLeafListType[outIndex] &&
+ ((XSElementDecl)fElemMap[inIndex]).fTargetNamespace == element.fTargetNamespace &&
((XSElementDecl)fElemMap[inIndex]).fName == element.fName)
- break;
+ break;
+ }
}
// If it was not in the list, then add it, if not the EOC node
if (inIndex == fElemMapSize) {
- fElemMap[fElemMapSize] = element;
+ fElemMap[fElemMapSize] = decl;
fElemMapType[fElemMapSize] = fLeafListType[outIndex];
fElemMapSize++;
}
@@ -608,14 +603,21 @@
int fSortCount = 0;
for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
+ final Object decl = fElemMap[elemIndex];
for (int leafIndex = 0; leafIndex < fLeafCount; leafIndex++) {
- final XSElementDecl leaf = fLeafList[leafIndex].getElement();
- final int leafType = fLeafListType[leafIndex];
- final XSElementDecl element = (XSElementDecl)fElemMap[elemIndex];
- if (fElemMapType[elemIndex] == fLeafListType[leafIndex] &&
- leaf.fTargetNamespace == element.fTargetNamespace &&
+ if (fElemMapType[elemIndex] != fLeafListType[leafIndex])
+ continue;
+
+ if (fLeafListType[leafIndex] == XSParticleDecl.PARTICLE_WILDCARD) {
+ if (decl == fLeafList[leafIndex].getDecl())
+ fLeafSorter[fSortCount++] = leafIndex;
+ } else {
+ final XSElementDecl leaf = (XSElementDecl)fLeafList[leafIndex].getDecl();
+ final XSElementDecl element = (XSElementDecl)decl;
+ if (leaf.fTargetNamespace == element.fTargetNamespace &&
leaf.fName == element.fName ) {
- fLeafSorter[fSortCount++] = leafIndex;
+ fLeafSorter[fSortCount++] = leafIndex;
+ }
}
}
fLeafSorter[fSortCount++] = -1;
@@ -945,9 +947,9 @@
"Leaf: (pos="
+ ((XSCMLeaf)nodeCur).getPosition()
+ "), "
- + ((XSCMLeaf)nodeCur).getElement()
+ + ((XSCMLeaf)nodeCur).getDecl()
+ "(elemIndex="
- + ((XSCMLeaf)nodeCur).getElement()
+ + ((XSCMLeaf)nodeCur).getDecl()
+ ") "
);
@@ -996,11 +998,9 @@
// Recurse as required
if (nodeCur.type() == XSParticleDecl.PARTICLE_WILDCARD) {
- // REVISIT: Don't waste these structures.
- fElementDecl = (XSWildcardDecl)((XSCMLeaf)nodeCur).getURI();
- // REVISIT: depends on result of XSDElement->XSDWildcard discussions...
- fLeafList[curIndex] = new XSCMLeaf(XSParticleDecl.PARTICLE_WILDCARD, fElementDecl, ((XSCMLeaf)nodeCur).getPosition());
- fLeafListType[curIndex] = nodeCur.type();
+ fElementDecl = ((XSCMLeaf)nodeCur).getDecl();
+ fLeafList[curIndex] = (XSCMLeaf)nodeCur;
+ fLeafListType[curIndex] = XSParticleDecl.PARTICLE_WILDCARD;
curIndex++;
}
else if ((nodeCur.type() == XSParticleDecl.PARTICLE_CHOICE)
@@ -1020,7 +1020,7 @@
// Put this node in the leaf list at the current index if its
// a non-epsilon leaf.
//
- final XSElementDecl elementDecl = ((XSCMLeaf)nodeCur).getElement();
+ final XSElementDecl elementDecl = (XSElementDecl)((XSCMLeaf)nodeCur).getDecl();
if (elementDecl.fName != fEpsilonString) {
fLeafList[curIndex] = (XSCMLeaf)nodeCur;
fLeafListType[curIndex] = XSParticleDecl.PARTICLE_ELEMENT;
1.25 +8 -10 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java
Index: XSDElementTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XSDElementTraverser.java 2001/10/17 23:07:14 1.24
+++ XSDElementTraverser.java 2001/10/18 18:41:18 1.25
@@ -89,7 +89,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDElementTraverser.java,v 1.24 2001/10/17 23:07:14 sandygao Exp $
+ * @version $Id: XSDElementTraverser.java,v 1.25 2001/10/18 18:41:18 sandygao Exp $
*/
class XSDElementTraverser extends XSDAbstractTraverser {
@@ -337,7 +337,7 @@
// see if there's something here; it had better be key, keyref or unique.
if (child != null) {
- String childName = fSymbolTable.addSymbol(DOMUtil.getLocalName(child));
+ String childName = DOMUtil.getLocalName(child);
while (child != null &&
(childName.equals(SchemaSymbols.ELT_KEY) ||
childName.equals(SchemaSymbols.ELT_KEYREF) ||
@@ -357,7 +357,7 @@
}
child = DOMUtil.getNextSiblingElement(child);
if (child != null) {
- childName = fSymbolTable.addSymbol(DOMUtil.getLocalName(child));
+ childName = DOMUtil.getLocalName(child);
}
}
}
@@ -466,9 +466,8 @@
}
// 2.2.2 If the {content type} is mixed, then the {content type}'s particle must be �emptiable� as defined by Particle Emptiable (�3.9.6).
else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED) {
- //REVISIT: to implement
- //if (!particleEmptiable(typeInfo.contentSpecHandle))
- // reportSchemaError ("cos-valid-default.2.2.2", new Object[]{element.fName});
+ if (!ctype.fParticle.emptiable())
+ reportSchemaError ("cos-valid-default.2.2.2", new Object[]{element.fName});
}
else {
reportSchemaError ("cos-valid-default.2.1", new Object[]{element.fName});
@@ -478,14 +477,13 @@
// get the simple type declaration, and validate
boolean ret = true;
if (dv != null) {
- // REVISIT: we'll be able to do this once he datatype redesign is implemented
- /******
try {
- element.fDefault = dv.validate((String)element.fDefault, null);
+ // REVISIT: we'll be able to do this once he datatype redesign is implemented
+ //element.fDefault = dv.validate((String)element.fDefault, null);
+ dv.validate((String)element.fDefault, null);
} catch (InvalidDatatypeValueException ide) {
ret = false;
}
- ***/
}
return ret;
1.28 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- XSDComplexTypeTraverser.java 2001/10/17 21:46:09 1.27
+++ XSDComplexTypeTraverser.java 2001/10/18 18:41:18 1.28
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.27 2001/10/17 21:46:09 sandygao Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.28 2001/10/18 18:41:18 sandygao Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -664,8 +664,8 @@
if (toAttrGrp.fAttributeWC==null) {
toAttrGrp.fAttributeWC = fromAttrGrp.fAttributeWC;
}
- else {
- toAttrGrp.fAttributeWC.performUnionWith(fromAttrGrp.fAttributeWC);
+ else if (fromAttrGrp.fAttributeWC != null) {
+ toAttrGrp.fAttributeWC = toAttrGrp.fAttributeWC.performUnionWith(fromAttrGrp.fAttributeWC);
}
}
1.19 +1 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAttributeTraverser.java
Index: XSDAttributeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAttributeTraverser.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XSDAttributeTraverser.java 2001/10/17 21:46:09 1.18
+++ XSDAttributeTraverser.java 2001/10/18 18:41:18 1.19
@@ -82,7 +82,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDAttributeTraverser.java,v 1.18 2001/10/17 21:46:09 sandygao Exp $
+ * @version $Id: XSDAttributeTraverser.java,v 1.19 2001/10/18 18:41:18 sandygao Exp $
*/
class XSDAttributeTraverser extends XSDAbstractTraverser {
@@ -148,7 +148,6 @@
// 1 default and fixed must not both be present.
if (defaultAtt != null && fixedAtt != null) {
- // REVISIT: localize
reportSchemaError("src-attribute.1", new Object[]{nameAtt});
}
1.31 +8 -8 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- XSDAbstractTraverser.java 2001/10/18 16:04:36 1.30
+++ XSDAbstractTraverser.java 2001/10/18 18:41:18 1.31
@@ -77,7 +77,7 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.30 2001/10/18 16:04:36 elena Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.31 2001/10/18 18:41:18 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
@@ -231,11 +231,11 @@
String localpart = enumVal;
int colonptr = enumVal.indexOf(":");
if (colonptr > 0) {
- prefix = enumVal.substring(0,colonptr);
+ prefix = fSymbolTable.addSymbol(enumVal.substring(0,colonptr));
localpart = enumVal.substring(colonptr+1);
}
- String uriStr = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
+ String uriStr = schemaDoc.fNamespaceSupport.getURI(prefix);
fQName.setValues(prefix, localpart, null, uriStr );
XSNotationDecl notation = (XSNotationDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.NOTATION_TYPE , fQName);
if (notation == null) {
@@ -245,7 +245,7 @@
}
// REVISIT: we need to store QNames in Notation validator to be able
// to validation notations. This is just a temp. fix.
- //String fullName = (uriStr!=null)?(uriStr+":"+localpart):localpart;
+ //String fullName = (uriStr!=null)?(uriStr+":"+localpart):localpart;
enumVal = localpart;
}
enumData.addElement(enumVal);
@@ -358,7 +358,7 @@
String childName;
for (child=firstAttr; child!=null; child=DOMUtil.getNextSiblingElement(child)) {
- childName = DOMUtil.getLocalName(child);
+ childName = DOMUtil.getLocalName(child);
if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
tempAttrUse = fSchemaHandler.fAttributeTraverser.traverseLocal(child,
schemaDoc, grammar);
@@ -406,7 +406,7 @@
} // for
if (child != null) {
- childName = DOMUtil.getLocalName(child);
+ childName = DOMUtil.getLocalName(child);
if (childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE)) {
XSWildcardDecl tempAttrWC = fSchemaHandler.fWildCardTraverser.
traverseAnyAttribute(child, schemaDoc, grammar);
@@ -415,8 +415,8 @@
}
// perform intersection of attribute wildcard
else {
- attrGrp.fAttributeWC = attrGrp.fAttributeWC.
- performIntersectionWith(tempAttrWC);
+ attrGrp.fAttributeWC = tempAttrWC.
+ performIntersectionWith(attrGrp.fAttributeWC);
}
child = DOMUtil.getNextSiblingElement(child);
}
1.3 +7 -15 xml-xerces/java/src/org/apache/xerces/impl/v2/XSCMLeaf.java
Index: XSCMLeaf.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSCMLeaf.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSCMLeaf.java 2001/10/18 16:11:37 1.2
+++ XSCMLeaf.java 2001/10/18 18:41:18 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
+ * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -66,7 +66,7 @@
* @author Neil Graham, IBM
* @version $$
*/
-public class XSCMLeaf
+public class XSCMLeaf
extends CMNode {
//
@@ -108,16 +108,8 @@
// Package methods
//
- // THIS METHOD ASSUMES THAT fElement IS AN XSElementDecl.
- // If not, you'll get a ClassCastException...
- final XSElementDecl getElement() {
- return (XSElementDecl)fElement;
- }
-
- // THIS METHOD ASSUMES THAT fElement IS AN XSWildcardDecl.
- // If not, you'll get a ClassCastException...
- final XSWildcardDecl getURI() {
- return (XSWildcardDecl)fElement;
+ final Object getDecl() {
+ return fElement;
}
final int getPosition() {
1.32 +2 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java
Index: SchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- SchemaValidator.java 2001/10/17 23:07:14 1.31
+++ SchemaValidator.java 2001/10/18 18:41:18 1.32
@@ -114,7 +114,7 @@
* @author Andy Clark, IBM
* @author Jeffrey Rodriguez IBM
*
- * @version $Id: SchemaValidator.java,v 1.31 2001/10/17 23:07:14 sandygao Exp $
+ * @version $Id: SchemaValidator.java,v 1.32 2001/10/18 18:41:18 sandygao Exp $
*/
public class SchemaValidator
implements XMLComponent, XMLDocumentFilter,
@@ -1086,7 +1086,6 @@
if (fCurrentCM != null) {
Object decl = fCurrentCM.oneTransition(element, fCurrCMState, fSubGroupHandler);
// it could be an element decl or a wildcard decl
- // REVISIT: is there a more efficient way than 'instanceof'
if (decl == null) {
if (fCurrCMState[0] == XSCMValidator.FIRST_ERROR && fDoValidation) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
@@ -1329,7 +1328,6 @@
}
// add prefix declaration to the namespace support
- // REVISIT: should it be null or ""
fNamespaceSupport.declarePrefix(prefix, uri.length() != 0 ? uri : null);
}
@@ -1500,7 +1498,7 @@
// if can't find
if (currDecl == null) {
// if strict, report error
- if (attrWildcard.fType == XSWildcardDecl.WILDCARD_STRICT)
+ if (attrWildcard.fProcessContents == XSWildcardDecl.WILDCARD_STRICT)
reportSchemaError("cvc-complex-type.3.2.2", new Object[]{element.rawname, fTempQName.rawname});
// then continue to the next attribute
continue;
1.13 +37 -44 xml-xerces/java/src/org/apache/xerces/impl/v2/CMBuilder.java
Index: CMBuilder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/CMBuilder.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- CMBuilder.java 2001/10/18 16:11:37 1.12
+++ CMBuilder.java 2001/10/18 18:41:18 1.13
@@ -64,7 +64,7 @@
* This class constructs content models for a given grammar.
*
* @author Elena Litani, IBM
- * @version $Id: CMBuilder.java,v 1.12 2001/10/18 16:11:37 neilg Exp $
+ * @version $Id: CMBuilder.java,v 1.13 2001/10/18 18:41:18 sandygao Exp $
*/
public class CMBuilder {
@@ -76,8 +76,6 @@
// needed for DFA construction
private int fLeafCount;
- //REVISIT: add substitution comparator!!
-
public CMBuilder (XSDeclarationPool pool){
fDeclPool = pool;
}
@@ -103,12 +101,12 @@
XSCMValidator cmValidator = null;
XSParticleDecl particle = typeDecl.fParticle;
-
+
// This check is performed in XSComplexTypeDecl.
//if (cmValidator != null)
// return cmValidator;
-
-
+
+
if (particle != null)
particle = expandParticleTree( (XSParticleDecl)particle);
@@ -124,8 +122,8 @@
else if (contentType == XSComplexTypeDecl.CONTENTTYPE_MIXED) {
//
// Create a child model as
- // per the element-only case
- cmValidator = createChildModel(particle, true);
+ // per the element-only case
+ cmValidator = createChildModel(particle, true);
}
else if (contentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) {
// This method will create an optimal model for the complexity
@@ -166,7 +164,7 @@
//if (grammar.fUPAChecking) {
// REVISIT: implement
//}
-
+
return expandContentModel(particle, minOccurs, maxOccurs);
}
else if (type == XSParticleDecl.PARTICLE_CHOICE ||
@@ -176,15 +174,14 @@
Object left = particle.fValue;
Object right = particle.fOtherValue;
- //REVISIT: look at uri and switch grammar if necessary
left = expandParticleTree( (XSParticleDecl)left);
- if (right != null)
+ if (right != null)
right = expandParticleTree( (XSParticleDecl)right);
-
+
// At this point, by expanding the particle tree, we may have a null left or right
- if (left==null && right==null)
+ if (left==null && right==null)
return null;
-
+
if (left == null)
return expandContentModel((XSParticleDecl)right, minOccurs, maxOccurs);
@@ -250,8 +247,8 @@
XSAllCM allContent = new XSAllCM(false);
gatherAllLeaves ((XSParticleDecl)(particle.fValue), allContent);
gatherAllLeaves ((XSParticleDecl)(particle.fOtherValue), allContent);
- return allContent;
-
+ return allContent;
+
}
else if (type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
XSParticleDecl left = (XSParticleDecl)particle.fValue;
@@ -282,7 +279,7 @@
// simple content model.
//
// pass element declaration
-
+
return new XSSimpleCM(type, (XSElementDecl)particle.fValue);
}
else if ((type == XSParticleDecl.PARTICLE_CHOICE)
@@ -305,11 +302,11 @@
}
}
- else if (type == XSParticleDecl.PARTICLE_ALL) {
-
+ else if (type == XSParticleDecl.PARTICLE_ALL) {
+
XSParticleDecl left = (XSParticleDecl)particle.fValue;
XSParticleDecl right = (XSParticleDecl)particle.fOtherValue;
-
+
XSAllCM allContent = new XSAllCM(false);
gatherAllLeaves (left, allContent);
@@ -334,7 +331,7 @@
return new XSSimpleCM(type, (XSElementDecl)left.fValue);
}
else if (left.fType==XSParticleDecl.PARTICLE_ALL) {
- XSAllCM allContent = new XSAllCM(true);
+ XSAllCM allContent = new XSAllCM(true);
gatherAllLeaves (left, allContent);
return allContent;
}
@@ -351,7 +348,6 @@
// encapsulates all of the work to create the DFA.
//
- //REVISIT: add DFA Content Model
fLeafCount = 0;
CMNode node = buildSyntaxTree(particle);
return new XSDFACM(node, fLeafCount, isMixed);
@@ -362,10 +358,6 @@
private XSParticleDecl expandContentModel(XSParticleDecl particle,
int minOccurs, int maxOccurs) {
-
- // REVISIT: should we handle (maxOccurs - minOccurs) = {1,2} as
- // separate case?
-
XSParticleDecl leafParticle = particle;
XSParticleDecl optional = null;
if (minOccurs==1 && maxOccurs==1) {
@@ -384,8 +376,9 @@
return createParticle (XSParticleDecl.PARTICLE_ONE_OR_MORE, particle, null);
}
else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
+ // REVISIT: should we handle (maxOccurs - minOccurs) = {1,2} as
+ // separate case?
if (minOccurs<2) {
- //REVISIT
}
// => a,a,..,a+
@@ -442,35 +435,35 @@
private void gatherAllLeaves(XSParticleDecl particle,
XSAllCM allContent) {
Object left = particle.fValue;
- Object right = particle.fOtherValue;
+ Object right = particle.fOtherValue;
int type = particle.fType;
if (type == XSParticleDecl.PARTICLE_ALL) {
-
+
// At an all node, visit left and right subtrees
gatherAllLeaves ((XSParticleDecl)left, allContent);
gatherAllLeaves ((XSParticleDecl) particle.fOtherValue, allContent);
}
else if (type == XSParticleDecl.PARTICLE_ELEMENT) {
-
+
// At leaf, add the element to list of elements permitted in the all
allContent.addElement ((XSElementDecl)left, false);
}
else if (type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
-
+
// At ZERO_OR_ONE node, subtree must be an element
// that was specified with minOccurs=0, maxOccurs=1
// Add the optional element to list of elements permitted in the all
-
+
if (((XSParticleDecl)left).fType == XSParticleDecl.PARTICLE_ELEMENT) {
allContent.addElement ((XSElementDecl)(((XSParticleDecl)left).fValue), true);
}
else {
// report error
- throw new RuntimeException("ImplementationMessages.VAL_CST");
- }
+ throw new RuntimeException("ImplementationMessages.VAL_CST");
+ }
}
- else {
+ else {
// report error
throw new RuntimeException("ImplementationMessages.VAL_CSTA");
}
@@ -494,7 +487,7 @@
// We will build a node at this level for the new tree
CMNode nodeRet = null;
if (startNode.fType == XSParticleDecl.PARTICLE_WILDCARD) {
- nodeRet = new XSCMAny(startNode.fType, ((XSWildcardDecl)startNode.fValue), fLeafCount++);
+ nodeRet = new XSCMLeaf(XSParticleDecl.PARTICLE_WILDCARD, startNode.fValue, fLeafCount++);
}
//
// If this node is a leaf, then its an easy one. We just add it
@@ -507,8 +500,8 @@
// storing it. This makes the positions zero based since we
// store first and then increment.
//
- nodeRet = new XSCMLeaf(XSParticleDecl.PARTICLE_ELEMENT, (XSElementDecl)(startNode.fValue), fLeafCount++);
- }
+ nodeRet = new XSCMLeaf(XSParticleDecl.PARTICLE_ELEMENT, startNode.fValue, fLeafCount++);
+ }
else {
//
// Its not a leaf, so we have to recurse its left and maybe right
@@ -526,18 +519,18 @@
nodeRet = new XSCMBinOp( startNode.fType, buildSyntaxTree(leftNode)
, buildSyntaxTree(rightNode));
- }
+ }
else if (startNode.fType == XSParticleDecl.PARTICLE_ZERO_OR_MORE
- || startNode.fType == XSParticleDecl.PARTICLE_ZERO_OR_ONE
- || startNode.fType == XSParticleDecl.PARTICLE_ONE_OR_MORE) {
+ || startNode.fType == XSParticleDecl.PARTICLE_ZERO_OR_ONE
+ || startNode.fType == XSParticleDecl.PARTICLE_ONE_OR_MORE) {
nodeRet = new XSCMUniOp(startNode.fType, buildSyntaxTree(leftNode));
- }
+ }
else {
- throw new RuntimeException("ImplementationMessages.VAL_CST");
+ throw new RuntimeException("ImplementationMessages.VAL_CST");
}
}
// And return our new node for this level
return nodeRet;
}
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org