Package org.apache.xerces.impl.xs

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


        return;

    }

    private XSParticleDecl getErrorContent() {
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
        particle.fValue = getErrorWildcard();
        particle.fMinOccurs = 0;
        particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
        XSModelGroupImpl group = new XSModelGroupImpl();
        group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
        group.fParticleCount = 1;
        group.fParticles = new XSParticleDecl[1];
        group.fParticles[0] = particle;
        XSParticleDecl errorContent = new XSParticleDecl();
        errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
        errorContent.fValue = group;

        return errorContent;
    }
View Full Code Here


                              grammar);

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

            // This is an RESTRICTION

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

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

            // 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}, complexContent);
                }

            }

            // Create the particle
            if (typeInfo.fParticle == null) {
                typeInfo.fParticle = baseContent;
            }
            else if (baseContent==null) {
            }
            else {
                // if the content of either type is an "all" model group, error.
                if (typeInfo.fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
                    ((XSModelGroupImpl)typeInfo.fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL ||
                    baseType.fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
                    ((XSModelGroupImpl)baseType.fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
                    throw new ComplexTypeRecoverableError("cos-all-limited.1.2",
                          null, complexContent);
                }
                // the "sequence" model group to contain both particles
                XSModelGroupImpl group = new XSModelGroupImpl();
                group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
                group.fParticleCount = 2;
                group.fParticles = new XSParticleDecl[2];
                group.fParticles[0] = baseType.fParticle;
                group.fParticles[1] = typeInfo.fParticle;
                // the particle to contain the above sequence
                XSParticleDecl particle = new XSParticleDecl();
                particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
                particle.fValue = group;
               
                typeInfo.fParticle = particle;
            }
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 synchronized XSParticleDecl getErrorContent() {
        if (fErrorContent==null) {
            fErrorWildcard = new XSWildcardDecl();
            fErrorWildcard.fProcessContents = XSWildcardDecl.PC_SKIP;
            XSParticleDecl particle = new XSParticleDecl();
            particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
            particle.fValue = fErrorWildcard;
            particle.fMinOccurs = 0;
            particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
            XSModelGroupImpl group = new XSModelGroupImpl();
            group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
            group.fParticleCount = 1;
            group.fParticles = new XSParticleDecl[1];
            group.fParticles[0] = particle;
            fErrorContent = new XSParticleDecl();
            fErrorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
            fErrorContent.fValue = group;
        }

        return fErrorContent;
View Full Code Here

                                 XSDocumentInfo schemaDoc,
                                 SchemaGrammar grammar,
                                 int allContextFlags,
                                 XSComplexTypeDecl enclosingCT) {

        XSParticleDecl particle = null;
        if (fSchemaHandler.fDeclPool !=null) {
            particle = fSchemaHandler.fDeclPool.getParticleDecl();
        } else {
            particle = new XSParticleDecl();
        }
        if(fDeferTraversingLocalElements) {
            fSchemaHandler.fillInLocalElemInfo(elmDecl, schemaDoc, allContextFlags, enclosingCT, particle);
        } else {
            traverseLocal(particle, elmDecl, schemaDoc, grammar, allContextFlags, enclosingCT);
View Full Code Here

                traverseAnnotationDecl(child, attrValues, false, schemaDoc);
                child = DOMUtil.getNextSiblingElement(child);
            }
        }
        String childName = null;
        XSParticleDecl particle;
        fPArray.pushContext();

        for (; child != null; child = DOMUtil.getNextSiblingElement(child)) {

            particle = null;
            childName = DOMUtil.getLocalName(child);

            // Only elements are allowed in <all>
            if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
                particle = fSchemaHandler.fElementTraverser.traverseLocal(child, schemaDoc, grammar, PROCESSING_ALL_EL, enclosingCT);
            }
            else {
                Object[] args = {"all", "(annotation?, element*)"};
                reportSchemaError("s4s-elt-must-match", args, child);
            }

            if (particle != null)
                fPArray.addParticle(particle);
        }

        particle = null;
        // REVISIT: model group
        // Quick fix for the case that particle <all> does not have any children.
        // For now we return null. In the future we might want to return model group decl.
        if (fPArray.getParticleCount() != 0) {

            XInt minAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MINOCCURS];
            XInt maxAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
            Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
           
            XSModelGroupImpl group = new XSModelGroupImpl();
            group.fCompositor = XSModelGroupImpl.MODELGROUP_ALL;
            group.fParticleCount = fPArray.getParticleCount();
            group.fParticles = fPArray.popContext();
            particle = new XSParticleDecl();
            particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
            particle.fMinOccurs = minAtt.intValue();
            particle.fMaxOccurs = maxAtt.intValue();
            particle.fValue = group;

View Full Code Here

                child = DOMUtil.getNextSiblingElement(child);
            }
        }
        boolean hadContent = false;
        String childName = null;
        XSParticleDecl particle;
        fPArray.pushContext();

        for (;child != null;child = DOMUtil.getNextSiblingElement(child)) {

            particle = null;

            childName = DOMUtil.getLocalName(child);
            if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
                particle = fSchemaHandler.fElementTraverser.traverseLocal(child, schemaDoc, grammar, NOT_ALL_CONTEXT, enclosingCT);
            }
            else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
                particle = fSchemaHandler.fGroupTraverser.traverseLocal(child, schemaDoc, grammar);

                // A content type of all can only appear
                // as the content type of a complex type definition.
                if (hasAllContent(particle)) {
                    // don't insert the "all" particle, otherwise we won't be
                    // able to create DFA from this content model
                    particle = null;
                    reportSchemaError("cos-all-limited.1.2", null, child);
                }

            }
            else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
                particle = traverseChoice(child, schemaDoc, grammar, NOT_ALL_CONTEXT, enclosingCT);
            }
            else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
                particle = traverseSequence(child, schemaDoc, grammar, NOT_ALL_CONTEXT, enclosingCT);
            }
            else if (childName.equals(SchemaSymbols.ELT_ANY)) {
                particle = fSchemaHandler.fWildCardTraverser.traverseAny(child, schemaDoc, grammar);
            }
            else {
                Object [] args;
                if (choice) {
                    args = new Object[]{"choice", "(annotation?, (element | group | choice | sequence | any)*)"};
                }
                else {
                    args = new Object[]{"sequence", "(annotation?, (element | group | choice | sequence | any)*)"};
                }
                reportSchemaError("s4s-elt-must-match", args, child);
            }

            if (particle != null)
                fPArray.addParticle(particle);
        }

        particle = null;
       
        // REVISIT: model group
        // Quick fix for the case that particles <choice> | <sequence> do not have any children.
        // For now we return null. In the future we might want to return model group decl.
        if (fPArray.getParticleCount() != 0) {

            XInt minAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MINOCCURS];
            XInt maxAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
            Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];

            XSModelGroupImpl group = new XSModelGroupImpl();
            group.fCompositor = choice ? XSModelGroupImpl.MODELGROUP_CHOICE : XSModelGroupImpl.MODELGROUP_SEQUENCE;
            group.fParticleCount = fPArray.getParticleCount();
            group.fParticles = fPArray.popContext();
            particle = new XSParticleDecl();
            particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
            particle.fMinOccurs = minAtt.intValue();
            particle.fMaxOccurs = maxAtt.intValue();
            particle.fValue = group;

View Full Code Here

        if (contentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE ||
            contentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
            return null;
        }

        XSParticleDecl particle = typeDecl.fParticle;
       
        // if the content is element only or mixed, but no particle
        // is defined, return the empty content model
        if (particle == null)
            return fEmptyCM;
View Full Code Here

        // General Attribute Checking for elmNode
        Object[] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc);
        XSWildcardDecl wildcard = traverseWildcardDecl(elmNode, attrValues, schemaDoc, grammar);

        // for <any>, need to create a new particle to reflect the min/max values
        XSParticleDecl particle = null;
        if (wildcard != null) {
            int min = ((XInt)attrValues[XSAttributeChecker.ATTIDX_MINOCCURS]).intValue();
            int max = ((XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS]).intValue();
            if (max != 0) {
                if (fSchemaHandler.fDeclPool !=null) {
                    particle = fSchemaHandler.fDeclPool.getParticleDecl();
                } else {       
                    particle = new XSParticleDecl();
                }
                particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
                particle.fValue = wildcard;
                particle.fMinOccurs = min;
                particle.fMaxOccurs = max;
View Full Code Here

        }

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

        XSParticleDecl particle = null;

        // not empty group, not empty particle
        if (group != null && group.fModelGroup != null &&
            !(minOccurs == 0 && maxOccurs == 0)) {
            // create a particle to contain this model group
            if (fSchemaHandler.fDeclPool != null) {
                particle = fSchemaHandler.fDeclPool.getParticleDecl();
            } else {       
                particle = new XSParticleDecl();
            }
            particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
            particle.fValue = group.fModelGroup;
            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.