51 #include <QtCore/QFile> 95 if (element->
name(namePool) == otherElement->
name(namePool))
136 if (!intersectionWildcard ||
163 if (derivedParticle && baseParticle) {
165 errorMsg = QtXmlPatterns::tr(
"Empty particle cannot be derived from non-empty particle.");
179 if (element->
name(namePool) != derivedElement->
name(namePool)) {
187 errorMsg = QtXmlPatterns::tr(
"Derived element %1 is missing value constraint as defined in base particle.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
192 errorMsg = QtXmlPatterns::tr(
"Derived element %1 has weaker value constraint than base particle.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
199 errorMsg = QtXmlPatterns::tr(
"Fixed value constraint of element %1 differs from value constraint in base particle.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
206 errorMsg = QtXmlPatterns::tr(
"Derived element %1 cannot be nillable as base element is not nillable.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
216 errorMsg = QtXmlPatterns::tr(
"Block constraints of derived element %1 must not be more weaker than in the base element.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
221 if (element->
type()->
name(namePool) == derivedElement->
type()->
name(namePool))
227 errorMsg = QtXmlPatterns::tr(
"Simple type of derived element %1 cannot be validly derived from base element.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
232 errorMsg = QtXmlPatterns::tr(
"Complex type of derived element %1 cannot be validly derived from base element.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
274 errorMsg = QtXmlPatterns::tr(
"Element %1 does not match namespace constraint of wildcard in base particle.").
arg(
formatKeyword(derivedElement->
displayName(namePool)));
285 errorMsg = QtXmlPatterns::tr(
"Wildcard in derived particle is not a valid subset of wildcard in base particle.");
290 errorMsg = QtXmlPatterns::tr(
"processContent of wildcard in derived particle is weaker than wildcard in base particle.");
314 substGroups << mainElement.
data();
316 for (
int i = 0; i < substGroups.
count(); ++i) {
318 if (hash.
contains(element->name(namePool))) {
319 if (element->type()->name(namePool) != hash.
value(element->name(namePool))->
type()->name(namePool)) {
320 conflictingElement = element;
324 hash.
insert(element->name(namePool), element);
330 for (
int i = 0; i < particles.
count(); ++i) {
398 while (stateIt.hasNext()) {
403 QHashIterator<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > transitionIt(currentTransitions);
404 while (transitionIt.hasNext()) {
407 if (transitionIt.value().size() > 1) {
413 QHashIterator<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > innerTransitionIt(currentTransitions);
414 while (innerTransitionIt.hasNext()) {
415 innerTransitionIt.next();
417 if (transitionIt.key() == innerTransitionIt.key())
421 if (
termMatches(transitionIt.key(), innerTransitionIt.key(), namePool))
437 const int count = particles.
count();
465 baseStateMachine = baseStateMachine.toDFA();
473 derivedStateMachine = derivedStateMachine.
toDFA();
521 QHashIterator<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > derivedIt(derivedTrans);
525 while (derivedIt.hasNext()) {
529 QHashIterator<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > baseIt(baseTrans);
530 while (baseIt.hasNext()) {
532 if (
derivedTermValid(baseIt.key(), derivedIt.key(), particlesHash, context, errorMsg)) {
534 qMakePair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId>(baseIt.value().first(), derivedIt.value().first());
537 processedSet.
append(endSet);
552 while (it.hasNext()) {
556 for (
int i = 0; i < processedSet.
count(); ++i) {
557 if (processedSet.
at(i).second == it.key() &&
560 errorMsg = QtXmlPatterns::tr(
"Derived particle allows content that is not allowed in the base particle.");
static uint hash(const uchar *p, int n)
The complex type has further elements or attributes and text as content.
XsdElement::WeakList substitutionGroups() const
XsdStateMachine< TransitionType > toDFA() const
XsdStateMachine< XsdTerm::Ptr >::StateId addStartState(XsdStateMachine< XsdTerm::Ptr >::StateId state)
static QString absentNamespace()
#define QT_END_NAMESPACE
This macro expands to.
XsdStateMachine< XsdTerm::Ptr >::StateId reset()
virtual bool isSimpleType() const
static XsdWildcard::Ptr wildcardIntersection(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &otherWildcard)
QString formatKeyword(const QString &keyword)
#define it(className, varName)
static bool hasDuplicatedElements(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool, XsdElement::Ptr &conflictingElement)
XsdTerm::Ptr term() const
static bool subsumes(const XsdParticle::Ptr &particle, const XsdParticle::Ptr &derivedParticle, const XsdSchemaContext::Ptr &context, QString &errorMsg)
The model group contains elements only.
XsdStateMachine< XsdTerm::Ptr >::StateId buildParticle(const XsdParticle::Ptr &particle, XsdStateMachine< XsdTerm::Ptr >::StateId endState)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QXmlName::NamespaceCode allocateNamespace(const QString &uri)
int count(const T &t) const
Returns the number of occurrences of value in the list.
virtual NamePool::Ptr namePool() const
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
virtual bool isWildcard() const
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const T value(const Key &key) const
Returns the value associated with the key.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
static bool termMatches(const XsdTerm::Ptr &term, const XsdTerm::Ptr &otherTerm, const NamePool::Ptr &namePool)
SchemaType::Ptr type() const
void append(const T &t)
Inserts value at the end of the list.
T * data() const
Returns a pointer to the shared data object.
virtual bool isElement() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
QString transitionTypeToString(TransitionType type) const
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
static bool checkWildcardProcessContents(const XsdWildcard::Ptr &baseWildcard, const XsdWildcard::Ptr &derivedWildcard)
XsdParticle::List particles() const
Namespaces in the namespaces set are not allowed.
T takeFirst()
Removes the first item in the list and returns it.
virtual bool isComplexType() const
const T & at(int i) const
Returns the item at index position i in the list.
QHash< StateId, StateType > states() const
static bool derivedTermValid(const XsdTerm::Ptr &baseTerm, const XsdTerm::Ptr &derivedTerm, const QHash< XsdTerm::Ptr, XsdParticle::Ptr > &particles, const XsdSchemaContext::Ptr &context, QString &errorMsg)
The namespace for the internal API of QtXmlPatterns.
virtual QString displayName(const NamePool::Ptr &namePool) const
The element has a fixed value set.
The QSourceLocation class identifies a location in a resource by URI, line, and column.
static bool isComplexDerivationOk(const SchemaType::Ptr &derivedType, const SchemaType::Ptr &baseType, const SchemaType::DerivationConstraints &constraints)
static bool isUPAConform(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool)
virtual QXmlName name(const NamePool::Ptr &namePool) const
static bool isSimpleDerivationOk(const SchemaType::Ptr &derivedType, const SchemaType::Ptr &baseType, const SchemaType::DerivationConstraints &constraints)
static bool isUPAConformXsdAll(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool)
NamespaceCode namespaceURI() const
static bool isWildcardSubset(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &otherWildcard)
bool valuesAreEqual(const QString &value, const QString &otherValue, const AnySimpleType::Ptr &type) const
NamespaceConstraint::Ptr namespaceConstraint() const
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
QHash< StateId, QHash< TransitionType, QVector< StateId > > > transitions() const
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
QHash< QXmlName, XsdElement::Ptr > ElementHash
ValueConstraint::Ptr valueConstraint() const
virtual bool isModelGroup() const
QExplicitlySharedDataPointer< XsdElement > Ptr
StateId startState() const
A state machine used for evaluation.
static QHash< XsdTerm::Ptr, XsdParticle::Ptr > particleLookupMap(const XsdParticle::Ptr &particle)
BlockingConstraints disallowedSubstitutions() const
A helper class to build up validation state machines.
static bool isParticleEmptiable(const XsdParticle::Ptr &particle)
static bool wildcardAllowsExpandedName(const QXmlName &name, const XsdWildcard::Ptr &wildcard, const NamePool::Ptr &namePool)
virtual bool isDefinedBySchema() const
The complex type has further elements or attributes but no text as content.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The class that provides methods for checking a string against a type.
static bool hasDuplicatedElementsInternal(const XsdParticle::Ptr &particle, const NamePool::Ptr &namePool, ElementHash &hash, XsdElement::Ptr &conflictingElement)
void setNamespaceURI(const NamespaceCode c)
virtual QXmlName name(const NamePool::Ptr &np) const =0
Returns the name of the type.
QHash< Key, T > & unite(const QHash< Key, T > &other)
Inserts all the items in the other hash into this hash.
The QList class is a template class that provides lists.