Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.QNameSetBuilder


        switch (contentModel.getParticleType())
        {
            case SchemaParticle.ALL:
            case SchemaParticle.SEQUENCE:
            case SchemaParticle.CHOICE:
                QNameSetBuilder set = new QNameSetBuilder();
                boolean hasWildcards = false;
                for (int i = 0; i < contentModel.countOfParticleChild(); i++)
                {
                    WildcardResult inner = summarizeEltWildcards(contentModel.getParticleChild(i));
                    set.addAll(inner.typedWildcards);
                    hasWildcards |= inner.hasWildcards;
                }
                return new WildcardResult(set.toQNameSet(), hasWildcards);
            case SchemaParticle.WILDCARD:
                return new WildcardResult(
                    (contentModel.getWildcardProcess() == SchemaParticle.SKIP) ?
                    QNameSet.EMPTY : contentModel.getWildcardSet(), true);
                // otherwise fallthrough
View Full Code Here


        SchemaParticleImpl partImpl = (SchemaParticleImpl)contentModel;
        if (partImpl.hasTransitionNotes())
            return;

        QNameSetBuilder start = new QNameSetBuilder();
        QNameSetBuilder excludenext = new QNameSetBuilder();
        boolean deterministic = true;
        SchemaParticle[] children = null;
        boolean canskip = (partImpl.getMinOccurs().signum() == 0);

        switch (partImpl.getParticleType())
        {
            case SchemaParticle.ELEMENT:
                // compute start and excludeNext; canskip is already correct
                if (partImpl.hasTransitionRules())
                    start.addAll(partImpl.acceptedStartNames());
                else
                    start.add(partImpl.getName());

                break;

            case SchemaParticle.WILDCARD:
                // compute start and excludeNext; canskip is already correct
                start.addAll(partImpl.getWildcardSet());
                break;

            case SchemaParticle.SEQUENCE:
                children = ensureStateMachine(partImpl.getParticleChildren());

                // adjust canskip if all children are skippable
                canskip = true;
                for (int i = 0; canskip && i < children.length; i++)
                {
                    if (!(children[i]).isSkippable())
                        canskip = false;
                }
               
                // bubble up nondeterministic bit
                for (int i = 0; deterministic && i < children.length; i++)
                {
                    if (!((SchemaParticleImpl)children[i]).isDeterministic())
                        deterministic = false;
                }
               
                // verify deterministic and compute excludeNext set
                for (int i = 1; i < children.length; i++)
                {
                    excludenext.addAll(((SchemaParticleImpl)children[i - 1]).getExcludeNextSet());
                    if (deterministic && !excludenext.isDisjoint((children[i]).acceptedStartNames()))
                        deterministic = false;
                    if ((children[i]).isSkippable())
                        excludenext.addAll((children[i]).acceptedStartNames());
                    else
                        excludenext.clear();
                }

                // next, compute start set
                for (int i = 0; i < children.length; i++)
                {
                    start.addAll((children[i]).acceptedStartNames());
                    if (!(children[i]).isSkippable())
                        break;
                }
                break;

            case SchemaParticle.CHOICE:
                children = ensureStateMachine(partImpl.getParticleChildren());

                // adjust canskip if any children are skippable
                canskip = false;
                for (int i = 0; !canskip && i < children.length; i++)
                {
                    if ((children[i]).isSkippable())
                        canskip = true;
                }

                // bubble up nondeterministic bit
                for (int i = 0; deterministic && i < children.length; i++)
                {
                    if (!((SchemaParticleImpl)children[i]).isDeterministic())
                        deterministic = false;
                }
               
                // compute start and excludeNext sets, verify deterministic
                for (int i = 0; i < children.length; i++)
                {
                    if (deterministic && !start.isDisjoint((children[i]).acceptedStartNames()))
                        deterministic = false;
                    start.addAll((children[i]).acceptedStartNames());
                    excludenext.addAll(((SchemaParticleImpl)children[i]).getExcludeNextSet());
                }

                break;

            case SchemaParticle.ALL:
                children = ensureStateMachine(partImpl.getParticleChildren());

                // adjust canskip if all children are skippable
                canskip = true;
                for (int i = 0; !canskip && i < children.length; i++)
                {
                    if (!(children[i]).isSkippable())
                        canskip = false;
                }

                // bubble up nondeterministic bit
                for (int i = 0; deterministic && i < children.length; i++)
                {
                    if (!((SchemaParticleImpl)children[i]).isDeterministic())
                        deterministic = false;
                }
               
                // compute start and excludeNext sets, verify deterministic
                for (int i = 0; i < children.length; i++)
                {
                    if (deterministic && !start.isDisjoint((children[i]).acceptedStartNames()))
                        deterministic = false;
                    start.addAll((children[i]).acceptedStartNames());
                    excludenext.addAll(((SchemaParticleImpl)children[i]).getExcludeNextSet());
                }
                if (canskip)
                    excludenext.addAll(start);

                break;

            default:
                throw new IllegalStateException("Unrecognized schema particle");
        }

        // apply looping logic

        BigInteger minOccurs = partImpl.getMinOccurs();
        BigInteger maxOccurs = partImpl.getMaxOccurs();
        boolean canloop = (maxOccurs == null || maxOccurs.compareTo(BigInteger.ONE) > 0);
        boolean varloop = (maxOccurs == null || minOccurs.compareTo(maxOccurs) < 0);

        if (canloop && deterministic && !excludenext.isDisjoint(start))
        {
            // we have a possible looping nondeterminism.
            // let's take some time now to see if it's actually caused
            // by non-unique-particle-attribute or not.
            QNameSet suspectSet = excludenext.intersect(start);
           
            // compute the set of all particles that could start this group
            Map startMap = new HashMap();
            particlesMatchingStart(partImpl, suspectSet, startMap, new QNameSetBuilder());
           
            // compute the set of all particles that could have been repeated rather than ending this group
            Map afterMap = new HashMap();
            particlesMatchingAfter(partImpl, suspectSet, afterMap, new QNameSetBuilder(), true);
           
            // see if we can find a member of after that is not a member of start
            // if we can, then particle attribution is not unique
            deterministic = afterMapSubsumedByStartMap(startMap, afterMap);
        }

        if (varloop)
            excludenext.addAll(start);

        canskip = canskip || minOccurs.signum() == 0;

        partImpl.setTransitionRules(start.toQNameSet(), canskip);
        partImpl.setTransitionNotes(excludenext.toQNameSet(), deterministic);
    }
View Full Code Here

                    if (!children[0].isSkippable())
                    {
                        particlesMatchingStart(children[0], suspectSet, result, eliminate);
                        return;
                    }
                    QNameSetBuilder remainingSuspects = new QNameSetBuilder(suspectSet);
                    QNameSetBuilder suspectsToEliminate = new QNameSetBuilder();
                    for (int i = 0; i < children.length; i++)
                    {
                        particlesMatchingStart(children[i], remainingSuspects, result, suspectsToEliminate);
                        eliminate.addAll(suspectsToEliminate);
                        if (!children[i].isSkippable())
                            return;
                        remainingSuspects.removeAll(suspectsToEliminate);
                        if (remainingSuspects.isEmpty())
                            return;
                        suspectsToEliminate.clear();
                    }
                    return;
                }
        }
    }
View Full Code Here

                    if (!children[children.length - 1].isSkippable())
                    {
                        particlesMatchingAfter(children[0], suspectSet, result, eliminate, false);
                        break recurse;
                    }
                    QNameSetBuilder remainingSuspects = new QNameSetBuilder(suspectSet);
                    QNameSetBuilder suspectsToEliminate = new QNameSetBuilder();
                    for (int i = children.length - 1; i >= 0; i--)
                    {
                        particlesMatchingAfter(children[i], remainingSuspects, result, suspectsToEliminate, false);
                        eliminate.addAll(suspectsToEliminate);
                        if (!children[i].isSkippable())
                            break recurse;
                        remainingSuspects.removeAll(suspectsToEliminate);
                        if (remainingSuspects.isEmpty())
                            break recurse;
                        suspectsToEliminate.clear();
                    }
                    break recurse;
                }
        }
View Full Code Here

        switch (contentModel.getParticleType())
        {
            case SchemaParticle.ALL:
            case SchemaParticle.SEQUENCE:
            case SchemaParticle.CHOICE:
                QNameSetBuilder set = new QNameSetBuilder();
                boolean hasWildcards = false;
                for (int i = 0; i < contentModel.countOfParticleChild(); i++)
                {
                    WildcardResult inner = summarizeEltWildcards(contentModel.getParticleChild(i));
                    set.addAll(inner.typedWildcards);
                    hasWildcards |= inner.hasWildcards;
                }
                return new WildcardResult(set.toQNameSet(), hasWildcards);
            case SchemaParticle.WILDCARD:
                return new WildcardResult(
                    (contentModel.getWildcardProcess() == SchemaParticle.SKIP) ?
                    QNameSet.EMPTY : contentModel.getWildcardSet(), true);
                // otherwise fallthrough
View Full Code Here

        SchemaParticleImpl partImpl = (SchemaParticleImpl)contentModel;
        if (partImpl.hasTransitionNotes())
            return;

        QNameSetBuilder start = new QNameSetBuilder();
        QNameSetBuilder excludenext = new QNameSetBuilder();
        boolean deterministic = true;
        SchemaParticle[] children = null;
        boolean canskip = (partImpl.getMinOccurs().signum() == 0);

        switch (partImpl.getParticleType())
        {
            case SchemaParticle.ELEMENT:
                // compute start and excludeNext; canskip is already correct
                if (partImpl.hasTransitionRules())
                    start.addAll(partImpl.acceptedStartNames());
                else
                    start.add(partImpl.getName());

                break;

            case SchemaParticle.WILDCARD:
                // compute start and excludeNext; canskip is already correct
                start.addAll(partImpl.getWildcardSet());
                break;

            case SchemaParticle.SEQUENCE:
                children = ensureStateMachine(partImpl.getParticleChildren());

                // adjust canskip if all children are skippable
                canskip = true;
                for (int i = 0; canskip && i < children.length; i++)
                {
                    if (!(children[i]).isSkippable())
                        canskip = false;
                }
               
                // bubble up nondeterministic bit
                for (int i = 0; deterministic && i < children.length; i++)
                {
                    if (!((SchemaParticleImpl)children[i]).isDeterministic())
                        deterministic = false;
                }
               
                // verify deterministic and compute excludeNext set
                for (int i = 1; i < children.length; i++)
                {
                    excludenext.addAll(((SchemaParticleImpl)children[i - 1]).getExcludeNextSet());
                    if (deterministic && !excludenext.isDisjoint((children[i]).acceptedStartNames()))
                        deterministic = false;
                    if ((children[i]).isSkippable())
                        excludenext.addAll((children[i]).acceptedStartNames());
                    else
                        excludenext.clear();
                }

                // next, compute start set
                for (int i = 0; i < children.length; i++)
                {
                    start.addAll((children[i]).acceptedStartNames());
                    if (!(children[i]).isSkippable())
                        break;
                }
                break;

            case SchemaParticle.CHOICE:
                children = ensureStateMachine(partImpl.getParticleChildren());

                // adjust canskip if any children are skippable
                canskip = false;
                for (int i = 0; !canskip && i < children.length; i++)
                {
                    if ((children[i]).isSkippable())
                        canskip = true;
                }

                // bubble up nondeterministic bit
                for (int i = 0; deterministic && i < children.length; i++)
                {
                    if (!((SchemaParticleImpl)children[i]).isDeterministic())
                        deterministic = false;
                }
               
                // compute start and excludeNext sets, verify deterministic
                for (int i = 0; i < children.length; i++)
                {
                    if (deterministic && !start.isDisjoint((children[i]).acceptedStartNames()))
                        deterministic = false;
                    start.addAll((children[i]).acceptedStartNames());
                    excludenext.addAll(((SchemaParticleImpl)children[i]).getExcludeNextSet());
                }

                break;

            case SchemaParticle.ALL:
                children = ensureStateMachine(partImpl.getParticleChildren());

                // adjust canskip if all children are skippable
                canskip = true;
                for (int i = 0; !canskip && i < children.length; i++)
                {
                    if (!(children[i]).isSkippable())
                        canskip = false;
                }

                // bubble up nondeterministic bit
                for (int i = 0; deterministic && i < children.length; i++)
                {
                    if (!((SchemaParticleImpl)children[i]).isDeterministic())
                        deterministic = false;
                }
               
                // compute start and excludeNext sets, verify deterministic
                for (int i = 0; i < children.length; i++)
                {
                    if (deterministic && !start.isDisjoint((children[i]).acceptedStartNames()))
                        deterministic = false;
                    start.addAll((children[i]).acceptedStartNames());
                    excludenext.addAll(((SchemaParticleImpl)children[i]).getExcludeNextSet());
                }
                if (canskip)
                    excludenext.addAll(start);

                break;

            default:
                // wildcard, all cases nyi
                throw new IllegalStateException("Unrecognized schema particle");
        }

        // apply looping logic

        BigInteger minOccurs = partImpl.getMinOccurs();
        BigInteger maxOccurs = partImpl.getMaxOccurs();
        boolean canloop = (maxOccurs == null || maxOccurs.compareTo(BigInteger.ONE) > 0);
        boolean varloop = (maxOccurs == null || minOccurs.compareTo(maxOccurs) < 0);

        if (canloop && deterministic && !excludenext.isDisjoint(start))
        {
            // we have a possible looping nondeterminism.
            // let's take some time now to see if it's actually caused
            // by non-unique-particle-attribute or not.
            QNameSet suspectSet = excludenext.intersect(start);
           
            // compute the set of all particles that could start this group
            Map startMap = new HashMap();
            particlesMatchingStart(partImpl, suspectSet, startMap, new QNameSetBuilder());
           
            // compute the set of all particles that could have been repeated rather than ending this group
            Map afterMap = new HashMap();
            particlesMatchingAfter(partImpl, suspectSet, afterMap, new QNameSetBuilder(), true);
           
            // see if we can find a member of after that is not a member of start
            // if we can, then particle attribution is not unique
            deterministic = afterMapSubsumedByStartMap(startMap, afterMap);
        }

        if (varloop)
            excludenext.addAll(start);

        canskip = canskip || minOccurs.signum() == 0;

        partImpl.setTransitionRules(start.toQNameSet(), canskip);
        partImpl.setTransitionNotes(excludenext.toQNameSet(), deterministic);
    }
View Full Code Here

                    if (!children[0].isSkippable())
                    {
                        particlesMatchingStart(children[0], suspectSet, result, eliminate);
                        return;
                    }
                    QNameSetBuilder remainingSuspects = new QNameSetBuilder(suspectSet);
                    QNameSetBuilder suspectsToEliminate = new QNameSetBuilder();
                    for (int i = 0; i < children.length; i++)
                    {
                        particlesMatchingStart(children[i], remainingSuspects, result, suspectsToEliminate);
                        eliminate.addAll(suspectsToEliminate);
                        if (!children[i].isSkippable())
                            return;
                        remainingSuspects.removeAll(suspectsToEliminate);
                        if (remainingSuspects.isEmpty())
                            return;
                        suspectsToEliminate.clear();
                    }
                    return;
                }
        }
    }
View Full Code Here

                    if (!children[children.length - 1].isSkippable())
                    {
                        particlesMatchingAfter(children[0], suspectSet, result, eliminate, false);
                        break recurse;
                    }
                    QNameSetBuilder remainingSuspects = new QNameSetBuilder(suspectSet);
                    QNameSetBuilder suspectsToEliminate = new QNameSetBuilder();
                    for (int i = children.length - 1; i >= 0; i--)
                    {
                        particlesMatchingAfter(children[i], remainingSuspects, result, suspectsToEliminate, false);
                        eliminate.addAll(suspectsToEliminate);
                        if (!children[i].isSkippable())
                            break recurse;
                        remainingSuspects.removeAll(suspectsToEliminate);
                        if (remainingSuspects.isEmpty())
                            break recurse;
                        suspectsToEliminate.clear();
                    }
                    break recurse;
                }
        }
View Full Code Here

            // Set subst group members
            qname = QNameHelper.forLNS(name, targetNamespace);
            SchemaTypeImpl docType = (SchemaTypeImpl)outerType;

            QName[] sgMembers = docType.getSubstitutionGroupMembers();
            QNameSetBuilder transitionRules = new QNameSetBuilder();
            transitionRules.add(qname);

            for (int i = 0 ; i < sgMembers.length ; i++)
            {
                gelt.addSubstitutionGroupMember(sgMembers[i]);
                transitionRules.add(sgMembers[i]);
            }

            impl.setTransitionRules(QNameSet.forSpecification(transitionRules), false);
            impl.setTransitionNotes(QNameSet.EMPTY, true);
View Full Code Here

        for (int i = 0; i < eltProps.length; i++)
        {
            SchemaPropertyImpl sImpl = (SchemaPropertyImpl)eltProps[i];
            QNameSet nde = computeNondelimitingElements(sImpl.getName(), contentModel, state);
            QNameSetBuilder builder = new QNameSetBuilder(allContents);
            builder.removeAll(nde);
            sImpl.setJavaSetterDelimiter(builder.toQNameSet());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.QNameSetBuilder

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.