Qt 4.8
Functions
qxsdschemachecker.cpp File Reference
#include "qxsdschemachecker_p.h"
#include "qderivedinteger_p.h"
#include "qderivedstring_p.h"
#include "qpatternplatform_p.h"
#include "qqnamevalue_p.h"
#include "qsourcelocationreflection_p.h"
#include "qvaluefactory_p.h"
#include "qxsdattributereference_p.h"
#include "qxsdparticlechecker_p.h"
#include "qxsdreference_p.h"
#include "qxsdschemacontext_p.h"
#include "qxsdschemahelper_p.h"
#include "qxsdschemaparsercontext_p.h"
#include "qxsdschematypesfactory_p.h"
#include "qxsdtypechecker_p.h"
#include "qxsdschemachecker_helper.cpp"

Go to the source code of this file.

Functions

static bool hasCircularUnionInheritance (const XsdSimpleType::Ptr &type, const SchemaType::Ptr &otherType, NamePool::Ptr &namePool)
 
static bool matchesType (const SchemaType::Ptr &myType, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > visitedTypes)
 
static bool wxsTypeMatches (const SchemaType::Ptr &type, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > &visitedTypes, SchemaType::Ptr &conflictingType)
 

Function Documentation

◆ hasCircularUnionInheritance()

static bool hasCircularUnionInheritance ( const XsdSimpleType::Ptr type,
const SchemaType::Ptr otherType,
NamePool::Ptr namePool 
)
static

Checks whether there is a circular inheritance for the union inheritance.

Definition at line 162 of file qxsdschemachecker.cpp.

Referenced by QPatternist::XsdSchemaChecker::checkCircularInheritances().

163 {
164  if (type == otherType) {
165  return true;
166  }
167 
168  if (!otherType->isSimpleType() || !otherType->isDefinedBySchema()) {
169  return false;
170  }
171 
172  const XsdSimpleType::Ptr simpleOtherType = otherType;
173 
174  if (simpleOtherType->category() == XsdSimpleType::SimpleTypeUnion) {
175  const XsdSimpleType::List memberTypes = simpleOtherType->memberTypes();
176  for (int i = 0; i < memberTypes.count(); ++i) {
177  if (otherType->wxsSuperType() == type) {
178  return true;
179  }
180  if (hasCircularUnionInheritance(type, memberTypes.at(i), namePool)) {
181  return true;
182  }
183  }
184  }
185 
186  return false;
187 }
int type
Definition: qmetatype.cpp:239
virtual TypeCategory category() const
virtual bool isSimpleType() const
Definition: qschematype.cpp:56
static bool hasCircularUnionInheritance(const XsdSimpleType::Ptr &type, const SchemaType::Ptr &otherType, NamePool::Ptr &namePool)
AnySimpleType::List memberTypes() const
virtual bool isDefinedBySchema() const
Definition: qschematype.cpp:75
virtual SchemaType::Ptr wxsSuperType() const =0

◆ matchesType()

static bool matchesType ( const SchemaType::Ptr myType,
const SchemaType::Ptr otherType,
QSet< SchemaType::Ptr visitedTypes 
)
static

Checks whether the otherType is the same as myType or if one of its ancestors is the same as myType.

Definition at line 117 of file qxsdschemachecker.cpp.

Referenced by QPatternist::XsdSchemaChecker::checkCircularInheritances().

118 {
119  bool retval = false;
120 
121  if (otherType) {
122  if (visitedTypes.contains(otherType)) {
123  return true;
124  } else {
125  visitedTypes.insert(otherType);
126  }
127  // simple types can have different varieties, so we have to check each of them
128  if (otherType->isSimpleType()) {
129  const XsdSimpleType::Ptr simpleType = otherType;
130  if (simpleType->category() == XsdSimpleType::SimpleTypeAtomic) {
131  // for atomic type we use the same test as in SchemaType::wxsTypeMatches
132  retval = (myType == simpleType ? true : matchesType(myType, simpleType->wxsSuperType(), visitedTypes));
133  } else if (simpleType->category() == XsdSimpleType::SimpleTypeList) {
134  // for list type we test against the itemType property
135  retval = (myType == simpleType->itemType() ? true : matchesType(myType, simpleType->itemType()->wxsSuperType(), visitedTypes));
136  } else if (simpleType->category() == XsdSimpleType::SimpleTypeUnion) {
137  // for union type we test against each member type
138  const XsdSimpleType::List members = simpleType->memberTypes();
139  for (int i = 0; i < members.count(); ++i) {
140  if (myType == members.at(i) ? true : matchesType(myType, members.at(i)->wxsSuperType(), visitedTypes)) {
141  retval = true;
142  break;
143  }
144  }
145  } else {
146  // reached xsAnySimple type whichs category is None
147  retval = false;
148  }
149  } else {
150  // if no simple type we handle it like in SchemaType::wxsTypeMatches
151  retval = (myType == otherType ? true : matchesType(myType, otherType->wxsSuperType(), visitedTypes));
152  }
153  } else // if otherType is null it doesn't match
154  retval = false;
155 
156  return retval;
157 }
virtual TypeCategory category() const
virtual SchemaType::Ptr wxsSuperType() const
virtual bool isSimpleType() const
Definition: qschematype.cpp:56
static bool matchesType(const SchemaType::Ptr &myType, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > visitedTypes)
virtual SchemaType::Ptr wxsSuperType() const
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179
AnySimpleType::List memberTypes() const
virtual SchemaType::Ptr wxsSuperType() const =0
AnySimpleType::Ptr itemType() const

◆ wxsTypeMatches()

static bool wxsTypeMatches ( const SchemaType::Ptr type,
const SchemaType::Ptr otherType,
QSet< SchemaType::Ptr > &  visitedTypes,
SchemaType::Ptr conflictingType 
)
inlinestatic

Definition at line 189 of file qxsdschemachecker.cpp.

Referenced by QPatternist::XsdSchemaChecker::checkAttributeConstraints(), QPatternist::XsdSchemaChecker::checkBasicCircularInheritances(), QPatternist::XsdTypeChecker::checkConstrainingFacets(), QPatternist::XsdSchemaChecker::checkConstrainingFacets(), QPatternist::XsdTypeChecker::checkConstrainingFacetsList(), QPatternist::ConstructorFunctionsFactory::ConstructorFunctionsFactory(), QPatternist::XsdSchemaChecker::hasConstraintIDAttributeUse(), hasIDAttributeUse(), QPatternist::XsdSchemaChecker::hasMultipleIDAttributeUses(), QPatternist::XsdTypeChecker::isValidString(), PerformComparison::operator()(), QPatternist::XsdSchemaResolver::resolveEnumerationFacetValues(), QPatternist::XsdValidatingInstanceReader::selectNodeSets(), QPatternist::XsdValidatingInstanceReader::validateAttribute(), QPatternist::XsdValidatingInstanceReader::validateElementComplexType(), QPatternist::XsdValidatingInstanceReader::validateElementSimpleType(), QPatternist::XsdTypeChecker::valuesAreEqual(), and QPatternist::yyparse().

190 {
191  if (!otherType)
192  return false;
193 
194  if (visitedTypes.contains(otherType)) { // inheritance loop detected
195  conflictingType = otherType;
196  return true;
197  } else {
198  visitedTypes.insert(otherType);
199  }
200 
201  if (type == otherType)
202  return true;
203 
204  return wxsTypeMatches(type, otherType->wxsSuperType(), visitedTypes, conflictingType);
205 }
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179
static bool wxsTypeMatches(const SchemaType::Ptr &type, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > &visitedTypes, SchemaType::Ptr &conflictingType)
virtual SchemaType::Ptr wxsSuperType() const =0