compactedForUPA = true;
}
}
short type = particle.fType;
CMNode nodeRet = null;
if ((type == XSParticleDecl.PARTICLE_WILDCARD) ||
(type == XSParticleDecl.PARTICLE_ELEMENT)) {
// (task 1) element and wildcard particles should be converted to
// leaf nodes
// REVISIT: Make a clone of the leaf particle, so that if there
// are two references to the same group, we have two different
// leaf particles for the same element or wildcard decl.
// This is useful for checking UPA.
nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
// (task 2) expand occurrence values
nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs);
if (nodeRet != null) {
nodeRet.setIsCompactUPAModel(compactedForUPA);
}
}
else if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
// (task 1,3) convert model groups to binary trees
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
CMNode temp = null;
// when the model group is a choice of more than one particles, but
// only one of the particle is not empty, (for example
// <choice>
// <sequence/>
// <element name="e"/>
// </choice>
// ) we can't not return that one particle ("e"). instead, we should
// treat such particle as optional ("e?").
// the following int variable keeps track of the number of non-empty children
int count = 0;
for (int i = 0; i < group.fParticleCount; i++) {
// first convert each child to a CM tree
temp = buildSyntaxTree(group.fParticles[i], forUPA);
// then combine them using binary operation
if (temp != null) {
compactedForUPA |= temp.isCompactedForUPA();
++count;
if (nodeRet == null) {
nodeRet = temp;
}
else {