Package org.apache.xerces.impl.xs

Examples of org.apache.xerces.impl.xs.XSParticleDecl


                return expandContentModel((XSParticleDecl)right, minOccurs, maxOccurs);

            if (right == null)
                return expandContentModel((XSParticleDecl)left, minOccurs, maxOccurs);

            XSParticleDecl newParticle = new XSParticleDecl();
            newParticle.fType = particle.fType;
            newParticle.fValue = left;
            newParticle.fOtherValue = right;
            return expandContentModel((XSParticleDecl)newParticle, minOccurs, maxOccurs);
        }
View Full Code Here


                gatherAllLeaves ((XSParticleDecl)(particle.fOtherValue), allContent);
                return allContent;

            }
            else if (type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
                 XSParticleDecl left = (XSParticleDecl)particle.fValue;


                // An ALL node can appear under a ZERO_OR_ONE node.
                if (type ==XSParticleDecl.PARTICLE_ALL) {
                    XSAllCM allContent = new XSAllCM(true);
                    gatherAllLeaves (left, allContent);
                    return allContent;

                }
            }
            // otherwise, let fall through to build a DFAContentModel
        }
        else if (type == XSParticleDecl.PARTICLE_ELEMENT) {
            //
            //  Check that the left value is not null, since any content model
            //  with PCDATA should be MIXED, so we should not have gotten here.
            //
            if (particle.fValue == null &&
                particle.fOtherValue == null)
                throw new RuntimeException("ImplementationMessages.VAL_NPCD");

            //
            //  Its a single leaf, so its an 'a' type of content model, i.e.
            //  just one instance of one element. That one is definitely a
            //  simple content model.
            //
            // pass element declaration

            return new XSSimpleCM(type, (XSElementDecl)particle.fValue);
        }
        else if ((type == XSParticleDecl.PARTICLE_CHOICE)
                 ||  (type == XSParticleDecl.PARTICLE_SEQUENCE)) {
            //
            //  Lets see if both of the children are leafs. If so, then it
            //  it has to be a simple content model
            //
            XSParticleDecl left = (XSParticleDecl)particle.fValue;
            XSParticleDecl right = (XSParticleDecl)particle.fOtherValue;

            if ((right.fType == XSParticleDecl.PARTICLE_ELEMENT)
                &&  (left.fType == XSParticleDecl.PARTICLE_ELEMENT)) {
                //
                //  Its a simple choice or sequence, so we can do a simple
                //  content model for it.
                //
                // pass both element decls
                return new XSSimpleCM(type, (XSElementDecl)left.fValue, (XSElementDecl)right.fValue);
            }

        }
    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)) {
            //
            //  Its a repetition, so see if its one child is a leaf. If so
            //  its a repetition of a single element, so we can do a simple
            //  content model for that.
            XSParticleDecl left = (XSParticleDecl) particle.fValue;

            if (left.fType == XSParticleDecl.PARTICLE_ELEMENT) {
                //
                //  It is, so we can create a simple content model here that
                //  will check for this repetition. We pass -1 for the unused
View Full Code Here


    private XSParticleDecl expandContentModel(XSParticleDecl particle,
                                              int minOccurs, int maxOccurs) {

        XSParticleDecl leafParticle = particle;
        XSParticleDecl optional = null;
        if (minOccurs==1 && maxOccurs==1) {
            return particle;
        }
        else if (minOccurs==0 && maxOccurs==1) {
            //zero or one
View Full Code Here

    private XSParticleDecl createParticle (short type,
                                           XSParticleDecl left,
                                           XSParticleDecl right) {

        XSParticleDecl newParticle = new XSParticleDecl();
        newParticle.fType = type;
        newParticle.fValue = (Object) left;
        newParticle.fOtherValue = (Object)right;
        return newParticle;
    }
View Full Code Here

        }
        else {
            //
            //  Its not a leaf, so we have to recurse its left and maybe right
            //  nodes. Save both values before we recurse and trash the node.
            final XSParticleDecl leftNode = ((XSParticleDecl)startNode.fValue);
            final XSParticleDecl rightNode = ((XSParticleDecl)startNode.fOtherValue);

            if ((startNode.fType == XSParticleDecl.PARTICLE_CHOICE)
                ||  (startNode.fType == XSParticleDecl.PARTICLE_SEQUENCE)) {
                //
                //  Recurse on both children, and return a binary op node
View Full Code Here

                              grammar);

        // -----------------------------------------------------------------------
        // Compose the final content and attribute uses
        // -----------------------------------------------------------------------
        XSParticleDecl baseContent = baseType.fParticle;
        if (typeInfo.fDerivedBy==SchemaSymbols.RESTRICTION) {

            // This is an RESTRICTION

            if (typeInfo.fParticle==null && (!(baseContent==null ||
                                               baseContent.emptiable()))) {
                throw new ComplexTypeRecoverableError("derivation-ok-restriction.5.2",
                                          new Object[]{typeName});
            }
            if (typeInfo.fParticle!=null && baseContent==null) {
                //REVISIT - need better error msg
                throw new ComplexTypeRecoverableError("derivation-ok-restriction.5.3",
                                          new Object[]{typeName});
            }

            mergeAttributes(baseType.fAttrGrp, typeInfo.fAttrGrp, typeName, false);
            String error = typeInfo.fAttrGrp.validRestrictionOf(baseType.fAttrGrp);
            if (error != null) {
                throw new ComplexTypeRecoverableError(error,
                          new Object[]{typeName});
            }

            // Remove prohibited uses.   Must be done after merge for RESTRICTION.
            typeInfo.fAttrGrp.removeProhibitedAttrs();

        }
        else {

            // This is an EXTENSION

            //
            // Check if the contentType of the base is consistent with the new type
            // cos-ct-extends.1.4.2.2
            if (baseType.fContentType != XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
                if (((baseType.fContentType ==
                      XSComplexTypeDecl.CONTENTTYPE_ELEMENT) &&
                     mixedContent) ||
                    ((baseType.fContentType ==
                      XSComplexTypeDecl.CONTENTTYPE_MIXED) && !mixedContent)) {

                    throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.2.2.2.2.1",
                          new Object[]{typeName});
                }

            }

            // Create the particle
            if (typeInfo.fParticle == null) {
                typeInfo.fParticle = baseContent;
            }
            else if (baseContent==null) {
            }
            else {
                if (typeInfo.fParticle.fType == XSParticleDecl.PARTICLE_ALL ||
                    baseType.fParticle.fType == XSParticleDecl.PARTICLE_ALL) {
                    throw new ComplexTypeRecoverableError("cos-all-limited.1.2",
                          new Object[]{typeName});
                }
                XSParticleDecl temp = new XSParticleDecl();
                temp.fType = XSParticleDecl.PARTICLE_SEQUENCE;
                temp.fValue = baseContent;
                temp.fOtherValue = typeInfo.fParticle;
                typeInfo.fParticle = temp;
            }
View Full Code Here

                                       boolean isMixed, boolean isDerivation,
                                       XSDocumentInfo schemaDoc, SchemaGrammar grammar)
    throws ComplexTypeRecoverableError {

        Element attrNode = null;
        XSParticleDecl particle = null;
        String typeName = typeInfo.fName;

        if (complexContentChild != null) {
            // -------------------------------------------------------------
            // GROUP, ALL, SEQUENCE or CHOICE, followed by attributes, if specified.
View Full Code Here

    }

    private static XSParticleDecl getErrorContent() {
        if (fErrorContent==null) {
            fErrorContent = new XSParticleDecl();
            fErrorContent.fType = XSParticleDecl.PARTICLE_SEQUENCE;
            XSParticleDecl particle = new XSParticleDecl();
            XSWildcardDecl wildcard = new XSWildcardDecl();
            wildcard.fProcessContents = XSWildcardDecl.WILDCARD_SKIP;
            particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
            particle.fValue = wildcard;
            particle.fMinOccurs = 0;
View Full Code Here

            // optimization from Henry Zongaro:
            //fElemMap[outIndex] = new Object ();
            fElemMap[outIndex] = null;

            int inIndex = 0;
            final XSParticleDecl decl = fLeafList[outIndex].getLeaf();
            for (; inIndex < fElemMapSize; inIndex++) {
                if (decl == fElemMap[inIndex])
                    break;
            }

            // If it was not in the list, then add it, if not the EOC node
            if (inIndex == fElemMapSize) {
                fElemMap[fElemMapSize] = decl;
                fElemMapType[fElemMapSize] = fLeafListType[outIndex];
                fElemMapSize++;
            }
        }

        // the last entry in the element map must be the EOC element.
        // remove it from the map.
        if (DEBUG) {
            if (fElemMap[fElemMapSize-1] != fEOCParticle)
                System.err.println("interal error in DFA: last element is not EOC.");
        }
        fElemMapSize--;

        /***
         * Optimization(Jan, 2001); We sort fLeafList according to
         * elemIndex which is *uniquely* associated to each leaf.
         * We are *assuming* that each element appears in at least one leaf.
         **/

        int[] fLeafSorter = new int[fLeafCount + fElemMapSize];
        int fSortCount = 0;

        for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
            final XSParticleDecl decl = fElemMap[elemIndex];
            for (int leafIndex = 0; leafIndex < fLeafCount; leafIndex++) {
                if (decl == fLeafList[leafIndex].getLeaf())
                    fLeafSorter[fSortCount++] = leafIndex;
            }
            fLeafSorter[fSortCount++] = -1;
View Full Code Here

        }

        int minOccurs = minAttr.intValue();
        int maxOccurs = maxAttr.intValue();

        XSParticleDecl particle = null;

        if (group != null) {
            // empty particle
            if (minOccurs == 0 && maxOccurs == 0) {
            } else if (minOccurs == 1 && maxOccurs == 1) {
                particle = group.fParticle;
            }
            else if (!( minOccurs == 1 && maxOccurs == 1)) {
                // if minOccurs==maxOccurs==1 we don't need to create new particle
                // create new particle in the grammar if minOccurs<maxOccurs
                particle = new XSParticleDecl();
                particle.fType = group.fParticle.fType;
                particle.fValue = group.fParticle;
                particle.fMinOccurs = minOccurs;
                particle.fMaxOccurs = maxOccurs;
            }
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xs.XSParticleDecl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.