Please find the attached patch for CMBuilder.
Pavani
--
Pavani Mukthipudi
Sun Microsystems Inc.
Phone: 080 - 2298989 Extn: 87390
Index: CMBuilder.java
===================================================================
RCS file:
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/v2/CMBuilder.java,v
retrieving revision 1.6
diff -u -r1.6 CMBuilder.java
--- CMBuilder.java 2001/09/25 21:33:40 1.6
+++ CMBuilder.java 2001/09/26 15:13:45
@@ -204,6 +204,16 @@
}
}
+ else if (type == XSParticleDecl.PARTICLE_ALL) {
+
+ XSParticleDecl left = (XSParticleDecl)particle.fValue;
+ XSParticleDecl right = (XSParticleDecl)particle.fOtherValue;
+
+ XSAllCM allContent = new XSAllCM(false);
+ gatherAllLeaves (left, allContent);
+ gatherAllLeaves (right, allContent);
+ return allContent;
+ }
else if ((type == XSParticleDecl.PARTICLE_ZERO_OR_ONE)
|| (type == XSParticleDecl.PARTICLE_ZERO_OR_MORE)
|| (type == XSParticleDecl.PARTICLE_ONE_OR_MORE)) {
@@ -222,7 +232,9 @@
return new XSSimpleCM(type, (XSElementDecl)left.fValue);
}
else if (left.fType==XSParticleDecl.PARTICLE_ALL) {
- // REVISIT: add ALL content model
+ XSAllCM allContent = new XSAllCM(true);
+ gatherAllLeaves (left, allContent);
+ return allContent;
}
@@ -382,6 +394,50 @@
}
return particle;
+ }
+
+ /**
+ * Recursively builds an AllContentModel based on a particle tree
+ * rooted at an ALL node.
+ */
+ private void gatherAllLeaves(XSParticleDecl particle,
+ XSAllCM allContent) {
+
+ XSParticleDecl left = (XSParticleDecl) particle.fValue;
+ XSParticleDecl right = (XSParticleDecl) particle.fOtherValue;
+ int type = particle.fType;
+
+ if (type == XSParticleDecl.PARTICLE_ALL) {
+
+ // At an all node, visit left and right subtrees
+
+ gatherAllLeaves (left, allContent);
+ gatherAllLeaves (right, 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 (left.fType == XSParticleDecl.PARTICLE_ELEMENT) {
+ allContent.addElement ((XSElementDecl)left.fValue, true);
+ }
+ else {
+ // report error
+ throw new RuntimeException("ImplementationMessages.VAL_CST");
+ }
+ }
+ else {
+ // report error
+ throw new RuntimeException("ImplementationMessages.VAL_CST");
+ }
}
private XSParticleDecl createParticle (short type,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]