Qt 4.8
Functions
qxsdschemahelper.cpp File Reference
#include "qxsdschemahelper_p.h"
#include "qbuiltintypes_p.h"
#include "qvaluefactory_p.h"
#include "qxsdcomplextype_p.h"
#include "qxsdmodelgroup_p.h"
#include "qxsdsimpletype_p.h"
#include "qxsdtypechecker_p.h"

Go to the source code of this file.

Functions

template<class T >
static bool containsSet (const QSet< T > &super, const QSet< T > &sub)
 
static SchemaType::DerivationConstraints convertBlockingConstraints (const NamedSchemaComponent::BlockingConstraints &constraints)
 
static unsigned int effectiveTotalRangeMinimum (const XsdParticle::Ptr &particle)
 

Function Documentation

◆ containsSet()

template<class T >
static bool containsSet ( const QSet< T > &  super,
const QSet< T > &  sub 
)
inlinestatic

Definition at line 163 of file qxsdschemahelper.cpp.

164 {
165  QSetIterator<T> it(sub);
166  while (it.hasNext()) {
167  if (!super.contains(it.next()))
168  return false;
169  }
170 
171  return true;
172 }
#define it(className, varName)
bool contains(const T &value) const
Definition: qset.h:91

◆ convertBlockingConstraints()

static SchemaType::DerivationConstraints convertBlockingConstraints ( const NamedSchemaComponent::BlockingConstraints &  constraints)
static

Definition at line 404 of file qxsdschemahelper.cpp.

Referenced by QPatternist::XsdSchemaHelper::isValidlySubstitutable().

405 {
406  SchemaType::DerivationConstraints result = 0;
407 
408  if (constraints & NamedSchemaComponent::RestrictionConstraint)
409  result |= SchemaType::RestrictionConstraint;
410  if (constraints & NamedSchemaComponent::ExtensionConstraint)
411  result |= SchemaType::ExtensionConstraint;
412 
413  return result;
414 }

◆ effectiveTotalRangeMinimum()

static unsigned int effectiveTotalRangeMinimum ( const XsdParticle::Ptr particle)
inlinestatic

Definition at line 59 of file qxsdschemahelper.cpp.

Referenced by QPatternist::XsdSchemaHelper::isParticleEmptiable().

60 {
61  const XsdModelGroup::Ptr group = particle->term();
62 
63  if (group->compositor() == XsdModelGroup::ChoiceCompositor) {
64  // @see http://www.w3.org/TR/xmlschema11-1/# cos-choice-range
65 
66  int minValue = -1;
67 
68  const XsdParticle::List particles = group->particles();
69  if (particles.isEmpty())
70  minValue = 0;
71 
72  for (int i = 0; i < particles.count(); ++i) {
73  const XsdParticle::Ptr particle = particles.at(i);
74 
75  if (particle->term()->isElement() || particle->term()->isWildcard()) {
76  if (minValue == -1) {
77  minValue = particle->minimumOccurs();
78  } else {
79  minValue = qMin((unsigned int)minValue, particle->minimumOccurs());
80  }
81  } else if (particle->term()->isModelGroup()) {
82  if (minValue == -1) {
83  minValue = effectiveTotalRangeMinimum(particle);
84  } else {
85  minValue = qMin((unsigned int)minValue, effectiveTotalRangeMinimum(particle));
86  }
87  }
88  }
89 
90  return (particle->minimumOccurs() * minValue);
91 
92  } else {
93  // @see http://www.w3.org/TR/xmlschema11-1/# cos-seq-range
94 
95  unsigned int sum = 0;
96  const XsdParticle::List particles = group->particles();
97  for (int i = 0; i < particles.count(); ++i) {
98  const XsdParticle::Ptr particle = particles.at(i);
99 
100  if (particle->term()->isElement() || particle->term()->isWildcard())
101  sum += particle->minimumOccurs();
102  else if (particle->term()->isModelGroup())
103  sum += effectiveTotalRangeMinimum(particle);
104  }
105 
106  return (particle->minimumOccurs() * sum);
107  }
108 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
XsdTerm::Ptr term() const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
virtual bool isWildcard() const
Definition: qxsdterm.cpp:58
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
virtual bool isElement() const
Definition: qxsdterm.cpp:48
unsigned int minimumOccurs() const
XsdParticle::List particles() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static unsigned int effectiveTotalRangeMinimum(const XsdParticle::Ptr &particle)
virtual bool isModelGroup() const
Definition: qxsdterm.cpp:53
ModelCompositor compositor() const