Qt 4.8
Functions
qxsdschemachecker_helper.cpp File Reference

Go to the source code of this file.

Functions

QSet< XsdElement::PtrcollectAllElements (const XsdParticle::Ptr &particle)
 
QSet< XsdElement::PtrcollectAllElements (const XsdSchema::Ptr &schema)
 

Function Documentation

◆ collectAllElements() [1/2]

QSet<XsdElement::Ptr> collectAllElements ( const XsdParticle::Ptr particle)

Definition at line 194 of file qxsdschemachecker_helper.cpp.

Referenced by QPatternist::XsdSchemaChecker::checkElementConstraints(), and collectAllElements().

195 {
197 
198  const XsdTerm::Ptr term(particle->term());
199  if (term->isElement()) {
200  elements.insert(XsdElement::Ptr(term));
201  } else if (term->isModelGroup()) {
202  const XsdModelGroup::Ptr group(term);
203 
204  for (int i = 0; i < group->particles().count(); ++i)
205  elements.unite(collectAllElements(group->particles().at(i)));
206  }
207 
208  return elements;
209 }
QSet< T > & unite(const QSet< T > &other)
Definition: qset.h:244
XsdTerm::Ptr term() const
QSet< XsdElement::Ptr > collectAllElements(const XsdParticle::Ptr &particle)
const_iterator insert(const T &value)
Definition: qset.h:179
static const QTextHtmlElement elements[Html_NumElements]

◆ collectAllElements() [2/2]

QSet<XsdElement::Ptr> collectAllElements ( const XsdSchema::Ptr schema)

Definition at line 211 of file qxsdschemachecker_helper.cpp.

212 {
214 
215  // collect global elements
216  const XsdElement::List elementList = schema->elements();
217  for (int i = 0; i < elementList.count(); ++i)
218  elements.insert(elementList.at(i));
219 
220  // collect all elements from global groups
221  const XsdModelGroup::List groupList = schema->elementGroups();
222  for (int i = 0; i < groupList.count(); ++i) {
223  const XsdModelGroup::Ptr group(groupList.at(i));
224 
225  for (int j = 0; j < group->particles().count(); ++j)
226  elements.unite(collectAllElements(group->particles().at(j)));
227  }
228 
229  // collect all elements from complex type definitions
231  types << schema->types() << schema->anonymousTypes();
232 
233  for (int i = 0; i < types.count(); ++i) {
234  if (types.at(i)->isComplexType() && types.at(i)->isDefinedBySchema()) {
235  const XsdComplexType::Ptr complexType(types.at(i));
236  if (complexType->contentType()->particle())
237  elements.unite(collectAllElements(complexType->contentType()->particle()));
238  }
239  }
240 
241  return elements;
242 }
QSet< T > & unite(const QSet< T > &other)
Definition: qset.h:244
SchemaType::List anonymousTypes() const
Definition: qxsdschema.cpp:181
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QSet< XsdElement::Ptr > collectAllElements(const XsdParticle::Ptr &particle)
XsdModelGroup::List elementGroups() const
Definition: qxsdschema.cpp:223
virtual bool isComplexType() const
Definition: qschematype.cpp:70
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
const_iterator insert(const T &value)
Definition: qset.h:179
static const struct @32 types[]
static const QTextHtmlElement elements[Html_NumElements]
virtual bool isDefinedBySchema() const
Definition: qschematype.cpp:75
SchemaType::List types() const
Definition: qxsdschema.cpp:131
XsdElement::List elements() const
Definition: qxsdschema.cpp:89