Exemplo n.º 1
0
void XsdSchemaDebugger::dumpElement(const XsdElement::Ptr &element)
{
    QStringList disallowedSubstGroup;
    if (element->disallowedSubstitutions() & XsdElement::RestrictionConstraint)
        disallowedSubstGroup << QLatin1String("restriction");
    if (element->disallowedSubstitutions() & XsdElement::ExtensionConstraint)
        disallowedSubstGroup << QLatin1String("extension");
    if (element->disallowedSubstitutions() & XsdElement::SubstitutionConstraint)
        disallowedSubstGroup << QLatin1String("substitution");


    qDebug() << "Name:" << element->displayName(m_namePool);
    qDebug() << "IsAbstract:" << (element->isAbstract() ? "yes" : "no");
    qDebug() << "Type:" << element->type()->displayName(m_namePool);
    qDebug() << "DisallowedSubstitutionGroups:" << disallowedSubstGroup.join(QLatin1String("' "));
}
Exemplo n.º 2
0
bool XsdSchemaChecker::elementSequenceAccepted(const XsdModelGroup::Ptr &sequence, const XsdParticle::Ptr &particle) const
{
    // @see http://www.w3.org/TR/xmlschema11-1/#cvc-accept

    if (particle->term()->isWildcard()) { // 1
        const XsdWildcard::Ptr wildcard(particle->term());

        // 1.1
        if ((unsigned int)sequence->particles().count() < particle->minimumOccurs())
            return false;

        // 1.2
        if (!particle->maximumOccursUnbounded()) {
            if ((unsigned int)sequence->particles().count() > particle->maximumOccurs())
                return false;
        }

        // 1.3
        const XsdParticle::List particles(sequence->particles());
        for (int i = 0; i < particles.count(); ++i) {
            if (particles.at(i)->term()->isElement()) {
                if (!XsdSchemaHelper::wildcardAllowsExpandedName(XsdElement::Ptr(particles.at(i)->term())->name(m_namePool), wildcard, m_namePool))
                    return false;
            }
        }
    } else if (particle->term()->isElement()) { // 2
        const XsdElement::Ptr element(particle->term());

        // 2.1
        if ((unsigned int)sequence->particles().count() < particle->minimumOccurs())
            return false;

        // 2.2
        if (!particle->maximumOccursUnbounded()) {
            if ((unsigned int)sequence->particles().count() > particle->maximumOccurs())
                return false;
        }

        // 2.3
        const XsdParticle::List particles(sequence->particles());
        for (int i = 0; i < particles.count(); ++i) {
            bool isValid = false;
            if (particles.at(i)->term()->isElement()) {
                const XsdElement::Ptr seqElement(particles.at(i)->term());

                // 2.3.1
                if (element->name(m_namePool) == seqElement->name(m_namePool))
                    isValid = true;

                // 2.3.2
                if (element->scope() && element->scope()->variety() == XsdElement::Scope::Global) {
                    if (!(element->disallowedSubstitutions() & NamedSchemaComponent::SubstitutionConstraint)) {
                        //TODO: continue
                    }
                }
            }
        }
    }

    return true;
}