XSCMValidator createDFACM(XSParticleDecl particle, boolean forUPA, XSOpenContentDecl openContent) { fLeafCount = 0; fParticleCount = 0; // convert particle tree to CM tree CMNode node = useRepeatingLeafNodes(particle) ? buildCompactSyntaxTree(particle) : buildSyntaxTree(particle, forUPA); if (node == null) return null; // build DFA content model from the CM tree return new XSDFACM(node, fLeafCount, fSchemaVersion, openContent); }
private CMNode multiNodes(CMNode node, int num, boolean copyFirst) { if (num == 0) { return null; } if (num == 1) { return copyFirst ? copyNode(node) : node; } int num1 = num/2; return fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE, multiNodes(node, num1, copyFirst), multiNodes(node, num-num1, true)); }
((XSModelGroupImpl)particle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) { if (fSchemaVersion < Constants.SCHEMA_VERSION_1_1) { cmValidator = createAllCM(particle); cmValidator = createAll11CM(particle, openContent); cmValidator = createDFACM(particle, forUPA, openContent);
nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs); if (nodeRet != null) { nodeRet.setIsCompactUPAModel(compactedForUPA); for (int i = 0; i < group.fParticleCount; i++) { temp = buildSyntaxTree(group.fParticles[i], forUPA); nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet); nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs); nodeRet.setIsCompactUPAModel(compactedForUPA);
return buildCompactSyntaxTree2(particle, minOccurs, maxOccurs); return buildCompactSyntaxTree2(group.fParticles[0], minOccurs, maxOccurs); for (int i = 0; i < group.fParticleCount; i++) { temp = buildCompactSyntaxTree(group.fParticles[i]);
public synchronized XSCMValidator getContentModel(CMBuilder cmBuilder, boolean forUPA) { if (fCMValidator == null) { if (forUPA) { if (fUPACMValidator == null) { fUPACMValidator = cmBuilder.getContentModel(this, true); if (fUPACMValidator != null && !fUPACMValidator.isCompactedForUPA()) { fCMValidator = fUPACMValidator; } } return fUPACMValidator; } else { fCMValidator = cmBuilder.getContentModel(this, false); } } return fCMValidator; }
private CMNode copyNode(CMNode node) { int type = node.type(); // for choice or sequence, copy the two subtrees, and combine them if (type == XSModelGroupImpl.MODELGROUP_CHOICE || type == XSModelGroupImpl.MODELGROUP_SEQUENCE) { XSCMBinOp bin = (XSCMBinOp)node; node = fNodeFactory.getCMBinOpNode(type, copyNode(bin.getLeft()), copyNode(bin.getRight())); } // for ?+*, copy the subtree, and put it in a new ?+* node else if (type == XSParticleDecl.PARTICLE_ZERO_OR_MORE || type == XSParticleDecl.PARTICLE_ONE_OR_MORE || type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) { XSCMUniOp uni = (XSCMUniOp)node; node = fNodeFactory.getCMUniOpNode(type, copyNode(uni.getChild())); } // for element/wildcard (leaf), make a new leaf node, // with a distinct position else if (type == XSParticleDecl.PARTICLE_ELEMENT || type == XSParticleDecl.PARTICLE_WILDCARD) { XSCMLeaf leaf = (XSCMLeaf)node; node = fNodeFactory.getCMLeafNode(leaf.type(), leaf.getLeaf(), leaf.getParticleId(), fLeafCount++); } return node; }
builder = new CMBuilder(nodeFactory);
protected void groupSubsumption(XSParticleDecl dParticle, XSParticleDecl bParticle, XSGrammarBucket grammarBucket, SubstitutionGroupHandler SGHandler, CMBuilder cmBuilder, XMLErrorReporter errorReporter, String dName, SimpleLocator locator) { // When we get here, particles are not null. Neither are content models. XSCMValidator cmd = cmBuilder.getContentModel(dParticle); XSCMValidator cmb = cmBuilder.getContentModel(bParticle); if (!new XS11CMRestriction(cmb, cmd, SGHandler, grammarBucket, cmBuilder, this).check()) { reportSchemaError(errorReporter, locator, "src-redefine.6.2.2", new Object[]{dName, ""}); } }
/** * Get content model for a given type * * @param typeDecl get content model for which complex type * @return a content model validator */ public XSCMValidator getContentModel(XSComplexTypeDecl typeDecl, boolean forUPA) { // for complex type with empty or simple content, // there is no content model validator short contentType = typeDecl.getContentType(); if (contentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE || contentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) { return null; } return getContentModel((XSParticleDecl)typeDecl.getParticle(), (XSOpenContentDecl)typeDecl.getOpenContent(), forUPA); }