Qt 4.8
qxsdschemaresolver.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qxsdschemaresolver_p.h"
43 
44 #include "qderivedinteger_p.h"
45 #include "qderivedstring_p.h"
46 #include "qqnamevalue_p.h"
48 #include "qxsdparticlechecker_p.h"
49 #include "qxsdreference_p.h"
50 #include "qxsdschemacontext_p.h"
51 #include "qxsdschemahelper_p.h"
54 
56 
57 using namespace QPatternist;
58 
60  : m_context(context)
61  , m_checker(parserContext->checker())
62  , m_namePool(parserContext->namePool())
63  , m_schema(parserContext->schema())
64 {
65  m_keyReferences.reserve(20);
66  m_simpleRestrictionBases.reserve(20);
67  m_simpleListTypes.reserve(20);
68  m_simpleUnionTypes.reserve(20);
69  m_elementTypes.reserve(20);
70  m_complexBaseTypes.reserve(20);
71  m_attributeTypes.reserve(20);
72  m_alternativeTypes.reserve(20);
73  m_alternativeTypeElements.reserve(20);
75 
77 }
78 
80 {
81 }
82 
84 {
86 
87  // resolve the base types for all types
90 
91  // do the basic checks which depend on having a base type available
93 
94  // resolve further types that only map a type name to a type object
100 
101  // resolve objects that do not need information about inheritance
104 
105  // resolve objects that do need information about inheritance
108 
109  // resolve objects which replace place holders
112 
113  // resolve additional objects that do need information about inheritance
117 
119 
122 
123  // check the constraining facets before we resolve them
125 
126  // add it again, as we may have added new components in the meantime
128 
129  m_checker->check();
130 }
131 
133 {
134  KeyReference item;
135  item.element = element;
136  item.keyRef = keyRef;
137  item.reference = reference;
138  item.location = location;
139 
140  m_keyReferences.append(item);
141 }
142 
144 {
146  item.simpleType = simpleType;
147  item.baseName = baseName;
148  item.location = location;
149 
150  m_simpleRestrictionBases.append(item);
151 }
152 
154 {
155  for (int i = 0; i < m_simpleRestrictionBases.count(); ++i) {
156  if (m_simpleRestrictionBases.at(i).simpleType == type) {
157  m_simpleRestrictionBases.remove(i);
158  break;
159  }
160  }
161 }
162 
164 {
165  SimpleListType item;
166  item.simpleType = simpleType;
167  item.typeName = typeName;
168  item.location = location;
169 
170  m_simpleListTypes.append(item);
171 }
172 
174 {
175  SimpleUnionType item;
176  item.simpleType = simpleType;
177  item.typeNames = typeNames;
178  item.location = location;
179 
180  m_simpleUnionTypes.append(item);
181 }
182 
184 {
185  ElementType item;
186  item.element = element;
187  item.typeName = typeName;
188  item.location = location;
189 
190  m_elementTypes.append(item);
191 }
192 
193 void XsdSchemaResolver::addComplexBaseType(const XsdComplexType::Ptr &complexType, const QXmlName &baseName, const QSourceLocation &location, const XsdFacet::Hash &facets)
194 {
195  ComplexBaseType item;
196  item.complexType = complexType;
197  item.baseName = baseName;
198  item.location = location;
199  item.facets = facets;
200 
201  m_complexBaseTypes.append(item);
202 }
203 
205 {
206  for (int i = 0; i < m_complexBaseTypes.count(); ++i) {
207  if (m_complexBaseTypes.at(i).complexType == type) {
208  m_complexBaseTypes.remove(i);
209  break;
210  }
211  }
212 }
213 
214 void XsdSchemaResolver::addComplexContentType(const XsdComplexType::Ptr &complexType, const XsdParticle::Ptr &content, bool mixed)
215 {
216  ComplexContentType item;
217  item.complexType = complexType;
218  item.explicitContent = content;
219  item.effectiveMixed = mixed;
220  m_complexContentTypes.append(item);
221 }
222 
224 {
225  AttributeType item;
226  item.attribute = attribute;
227  item.typeName = typeName;
228  item.location = location;
229 
230  m_attributeTypes.append(item);
231 }
232 
234 {
235  AlternativeType item;
236  item.alternative = alternative;
237  item.typeName = typeName;
238  item.location = location;
239 
240  m_alternativeTypes.append(item);
241 }
242 
244 {
246  item.alternative = alternative;
247  item.element = element;
248 
249  m_alternativeTypeElements.append(item);
250 }
251 
253 {
255  item.element = element;
256  item.elementNames = elementNames;
257  item.location = location;
258 
259  m_substitutionGroupAffiliations.append(item);
260 }
261 
263 {
264  m_substitutionGroupTypes.append(element);
265 }
266 
268 {
270 }
271 
272 void XsdSchemaResolver::addEnumerationFacetValue(const AtomicValue::Ptr &facetValue, const NamespaceSupport &namespaceSupport)
273 {
274  m_enumerationFacetValues.insert(facetValue, namespaceSupport);
275 }
276 
278 {
279  RedefinedGroups item;
280  item.redefinedGroup = redefinedGroup;
281  item.group = group;
282 
283  m_redefinedGroups.append(item);
284 }
285 
287 {
289  item.redefinedGroup = redefinedGroup;
290  item.group = group;
291 
292  m_redefinedAttributeGroups.append(item);
293 }
294 
296 {
297  m_allGroups.insert(reference);
298 }
299 
301 {
306  other->m_elementTypes << m_elementTypes;
314 }
315 
317 {
318  for (int i = 0; i < m_simpleRestrictionBases.count(); ++i) {
319  if (m_simpleRestrictionBases.at(i).simpleType == type)
320  return m_simpleRestrictionBases.at(i).baseName;
321  }
322 
323  for (int i = 0; i < m_complexBaseTypes.count(); ++i) {
324  if (m_complexBaseTypes.at(i).complexType == type)
325  return m_complexBaseTypes.at(i).baseName;
326  }
327 
328  return QXmlName();
329 }
330 
332 {
333  for (int i = 0; i < m_attributeTypes.count(); ++i) {
334  if (m_attributeTypes.at(i).attribute == attribute)
335  return m_attributeTypes.at(i).typeName;
336  }
337 
338  return QXmlName();
339 }
340 
342 {
343  m_defaultOpenContent = openContent;
344  m_defaultOpenContentAppliesToEmpty = appliesToEmpty;
345 }
346 
348 {
349  for (int i = 0; i < m_keyReferences.count(); ++i) {
350  const KeyReference ref = m_keyReferences.at(i);
351 
353  if (!constraint) {
354  m_context->error(QtXmlPatterns::tr("%1 references unknown %2 or %3 element %4.")
356  .arg(formatElement("key"))
357  .arg(formatElement("unique"))
358  .arg(formatKeyword(m_namePool, ref.reference)),
360  return;
361  }
362 
363  if (constraint->category() != XsdIdentityConstraint::Key && constraint->category() != XsdIdentityConstraint::Unique) { // only key and unique can be referenced
364  m_context->error(QtXmlPatterns::tr("%1 references identity constraint %2 that is no %3 or %4 element.")
367  .arg(formatElement("key"))
368  .arg(formatElement("unique")),
370  return;
371  }
372 
373  if (constraint->fields().count() != ref.keyRef->fields().count()) {
374  m_context->error(QtXmlPatterns::tr("%1 has a different number of fields from the identity constraint %2 that it references.")
376  .arg(formatKeyword(m_namePool, ref.reference)),
378  return;
379  }
380 
381  ref.keyRef->setReferencedKey(constraint);
382  }
383 }
384 
386 {
387  // iterate over all simple types that are derived by restriction
388  for (int i = 0; i < m_simpleRestrictionBases.count(); ++i) {
390 
391  // find the base type
393  if (!type) {
394  // maybe it's a basic type...
396  if (!type) {
397  m_context->error(QtXmlPatterns::tr("Base type %1 of %2 element cannot be resolved.")
398  .arg(formatType(m_namePool, item.baseName))
399  .arg(formatElement("restriction")),
401  return;
402  }
403  }
404 
405  item.simpleType->setWxsSuperType(type);
406  }
407 }
408 
410 {
411  XsdSimpleType::List simpleTypes;
412 
413  // first collect the global simple types
415  for (int i = 0; i < types.count(); ++i) {
416  if (types.at(i)->isSimpleType() && (types.at(i)->derivationMethod() == SchemaType::DerivationRestriction))
417  simpleTypes.append(types.at(i));
418  }
419 
420  // then collect all anonymous simple types
421  const SchemaType::List anonymousTypes = m_schema->anonymousTypes();
422  for (int i = 0; i < anonymousTypes.count(); ++i) {
423  if (anonymousTypes.at(i)->isSimpleType() && (anonymousTypes.at(i)->derivationMethod() == SchemaType::DerivationRestriction))
424  simpleTypes.append(anonymousTypes.at(i));
425  }
426 
427  QSet<XsdSimpleType::Ptr> visitedTypes;
428  for (int i = 0; i < simpleTypes.count(); ++i) {
429  resolveSimpleRestrictions(simpleTypes.at(i), visitedTypes);
430  }
431 }
432 
434 {
435  if (visitedTypes.contains(simpleType))
436  return;
437  else
438  visitedTypes.insert(simpleType);
439 
441  return;
442 
443  // as xs:NMTOKENS, xs:ENTITIES and xs:IDREFS are provided by our XsdSchemaTypesFactory, they are
444  // setup correctly already and shouldn't be handled here
445  if (m_predefinedSchemaTypes.contains(simpleType))
446  return;
447 
448  const SchemaType::Ptr baseType = simpleType->wxsSuperType();
449  Q_ASSERT(baseType);
450 
451  if (baseType->isDefinedBySchema())
452  resolveSimpleRestrictions(XsdSimpleType::Ptr(baseType), visitedTypes);
453 
454  simpleType->setCategory(baseType->category());
455 
456  if (simpleType->category() == XsdSimpleType::SimpleTypeAtomic) {
457  QSet<AnySimpleType::Ptr> visitedPrimitiveTypes;
458  const AnySimpleType::Ptr primitiveType = findPrimitiveType(baseType, visitedPrimitiveTypes);
459  simpleType->setPrimitiveType(primitiveType);
460  } else if (simpleType->category() == XsdSimpleType::SimpleTypeList) {
461  const XsdSimpleType::Ptr simpleBaseType = baseType;
462  simpleType->setItemType(simpleBaseType->itemType());
463  } else if (simpleType->category() == XsdSimpleType::SimpleTypeUnion) {
464  const XsdSimpleType::Ptr simpleBaseType = baseType;
465  simpleType->setMemberTypes(simpleBaseType->memberTypes());
466  }
467 }
468 
470 {
471  // iterate over all simple types where the item type shall be resolved
472  for (int i = 0; i < m_simpleListTypes.count(); ++i) {
473  const SimpleListType item = m_simpleListTypes.at(i);
474 
475  // try to resolve the name
477  if (!type) {
478  // maybe it's a basic type...
480  if (!type) {
481  m_context->error(QtXmlPatterns::tr("Item type %1 of %2 element cannot be resolved.")
482  .arg(formatType(m_namePool, item.typeName))
483  .arg(formatElement("list")),
485  return;
486  }
487  }
488 
489  item.simpleType->setItemType(type);
490  }
491 }
492 
494 {
495  // iterate over all simple types where the union member types shall be resolved
496  for (int i = 0; i < m_simpleUnionTypes.count(); ++i) {
497  const SimpleUnionType item = m_simpleUnionTypes.at(i);
498 
499  AnySimpleType::List memberTypes;
500 
501  // iterate over all union member type names
502  const QList<QXmlName> typeNames = item.typeNames;
503  for (int j = 0; j < typeNames.count(); ++j) {
504  const QXmlName typeName = typeNames.at(j);
505 
506  // try to resolve the name
507  SchemaType::Ptr type = m_schema->type(typeName);
508  if (!type) {
509  // maybe it's a basic type...
510  type = m_context->schemaTypeFactory()->createSchemaType(typeName);
511  if (!type) {
512  m_context->error(QtXmlPatterns::tr("Member type %1 of %2 element cannot be resolved.")
513  .arg(formatType(m_namePool, typeName))
514  .arg(formatElement("union")),
516  return;
517  }
518  }
519 
520  memberTypes.append(type);
521  }
522 
523  // append the types that have been defined as <simpleType> children
524  memberTypes << item.simpleType->memberTypes();
525 
526  item.simpleType->setMemberTypes(memberTypes);
527  }
528 }
529 
531 {
532  for (int i = 0; i < m_elementTypes.count(); ++i) {
533  const ElementType item = m_elementTypes.at(i);
534 
536  if (!type) {
537  // maybe it's a basic type...
539  if (!type) {
540  m_context->error(QtXmlPatterns::tr("Type %1 of %2 element cannot be resolved.")
541  .arg(formatType(m_namePool, item.typeName))
542  .arg(formatElement("element")),
544  return;
545  }
546  }
547 
548  item.element->setType(type);
549  }
550 }
551 
553 {
554  for (int i = 0; i < m_complexBaseTypes.count(); ++i) {
555  const ComplexBaseType item = m_complexBaseTypes.at(i);
556 
558  if (!type) {
559  // maybe it's a basic type...
561  if (!type) {
562  m_context->error(QtXmlPatterns::tr("Base type %1 of complex type cannot be resolved.").arg(formatType(m_namePool, item.baseName)), XsdSchemaContext::XSDError, item.location);
563  return;
564  }
565  }
566 
567  if (item.complexType->contentType()->variety() == XsdComplexType::ContentType::Simple) {
568  if (type->isComplexType() && type->isDefinedBySchema()) {
569  const XsdComplexType::Ptr baseType = type;
570  if (baseType->contentType()->variety() != XsdComplexType::ContentType::Simple) {
571  m_context->error(QtXmlPatterns::tr("%1 cannot have complex base type that has a %2.")
572  .arg(formatElement("simpleContent"))
573  .arg(formatElement("complexContent")),
575  return;
576  }
577  }
578  }
579 
580  item.complexType->setWxsSuperType(type);
581  }
582 }
583 
585 {
586  XsdComplexType::List complexTypes;
587 
588  // first collect the global complex types
590  for (int i = 0; i < types.count(); ++i) {
591  if (types.at(i)->isComplexType() && types.at(i)->isDefinedBySchema())
592  complexTypes.append(types.at(i));
593  }
594 
595  // then collect all anonymous simple types
596  const SchemaType::List anonymousTypes = m_schema->anonymousTypes();
597  for (int i = 0; i < anonymousTypes.count(); ++i) {
598  if (anonymousTypes.at(i)->isComplexType() && anonymousTypes.at(i)->isDefinedBySchema())
599  complexTypes.append(anonymousTypes.at(i));
600  }
601 
602  QSet<XsdComplexType::Ptr> visitedTypes;
603  for (int i = 0; i < complexTypes.count(); ++i) {
604  if (XsdComplexType::Ptr(complexTypes.at(i))->contentType()->variety() == XsdComplexType::ContentType::Simple)
605  resolveSimpleContentComplexTypes(complexTypes.at(i), visitedTypes);
606  }
607 }
608 
610 {
611  if (visitedTypes.contains(complexType))
612  return;
613  else
614  visitedTypes.insert(complexType);
615 
616  const SchemaType::Ptr baseType = complexType->wxsSuperType();
617 
618  // at this point simple types have been resolved already, so we care about
619  // complex types here only
620 
621  // http://www.w3.org/TR/xmlschema11-1/#dcl.ctd.ctsc
622  // 1
623  if (baseType->isComplexType() && baseType->isDefinedBySchema()) {
624  const XsdComplexType::Ptr complexBaseType = baseType;
625 
626  resolveSimpleContentComplexTypes(complexBaseType, visitedTypes);
627 
628  if (complexBaseType->contentType()->variety() == XsdComplexType::ContentType::Simple) {
630  if (complexType->contentType()->simpleType()) {
631  // 1.1 contains the content of the <simpleType> already
632  } else {
633  // 1.2
634  const XsdSimpleType::Ptr anonType(new XsdSimpleType());
635  XsdSimpleType::TypeCategory baseCategory = complexBaseType->contentType()->simpleType()->category();
636  anonType->setCategory(baseCategory);
637 
638  if (baseCategory == XsdSimpleType::SimpleTypeList) {
639  const XsdSimpleType::Ptr baseSimpleType = complexBaseType->contentType()->simpleType();
640  anonType->setItemType(baseSimpleType->itemType());
641  }
642 
644  anonType->setWxsSuperType(complexBaseType->contentType()->simpleType());
645  anonType->setFacets(complexTypeFacets(complexType));
646 
647  QSet<AnySimpleType::Ptr> visitedPrimitiveTypes;
648  const AnySimpleType::Ptr primitiveType = findPrimitiveType(anonType->wxsSuperType(), visitedPrimitiveTypes);
649  anonType->setPrimitiveType(primitiveType);
650 
651  complexType->contentType()->setSimpleType(anonType);
652 
653  m_schema->addAnonymousType(anonType);
655  }
656  } else if (complexBaseType->derivationMethod() == XsdComplexType::DerivationExtension) { // 3
657  complexType->contentType()->setSimpleType(complexBaseType->contentType()->simpleType());
658  }
659  } else if (complexBaseType->contentType()->variety() == XsdComplexType::ContentType::Mixed &&
661  XsdSchemaHelper::isParticleEmptiable(complexBaseType->contentType()->particle())) { // 2
662  // simple type was already set in parser
663 
664  const XsdSimpleType::Ptr anonType(new XsdSimpleType());
665  anonType->setCategory(complexType->contentType()->simpleType()->category());
667  anonType->setWxsSuperType(complexType->contentType()->simpleType());
668  anonType->setFacets(complexTypeFacets(complexType));
669 
670  QSet<AnySimpleType::Ptr> visitedPrimitiveTypes;
671  const AnySimpleType::Ptr primitiveType = findPrimitiveType(anonType->wxsSuperType(), visitedPrimitiveTypes);
672  anonType->setPrimitiveType(primitiveType);
673 
674  complexType->contentType()->setSimpleType(anonType);
675 
676  m_schema->addAnonymousType(anonType);
678  } else {
679  complexType->contentType()->setSimpleType(BuiltinTypes::xsAnySimpleType);
680  }
681  } else if (baseType->isSimpleType()) { // 4
682  complexType->contentType()->setSimpleType(baseType);
683  } else { // 5
684  complexType->contentType()->setSimpleType(BuiltinTypes::xsAnySimpleType);
685  }
686 }
687 
689 {
690  XsdComplexType::List complexTypes;
691 
692  // first collect the global complex types
694  for (int i = 0; i < types.count(); ++i) {
695  if (types.at(i)->isComplexType() && types.at(i)->isDefinedBySchema())
696  complexTypes.append(types.at(i));
697  }
698 
699  // then collect all anonymous simple types
700  const SchemaType::List anonymousTypes = m_schema->anonymousTypes();
701  for (int i = 0; i < anonymousTypes.count(); ++i) {
702  if (anonymousTypes.at(i)->isComplexType() && anonymousTypes.at(i)->isDefinedBySchema())
703  complexTypes.append(anonymousTypes.at(i));
704  }
705 
706  QSet<XsdComplexType::Ptr> visitedTypes;
707  for (int i = 0; i < complexTypes.count(); ++i) {
708  if (XsdComplexType::Ptr(complexTypes.at(i))->contentType()->variety() != XsdComplexType::ContentType::Simple)
709  resolveComplexContentComplexTypes(complexTypes.at(i), visitedTypes);
710  }
711 }
712 
714 {
715  if (visitedTypes.contains(complexType))
716  return;
717  else
718  visitedTypes.insert(complexType);
719 
720  ComplexContentType item;
721  bool foundCorrespondingItem = false;
722  for (int i = 0; i < m_complexContentTypes.count(); ++i) {
723  if (m_complexContentTypes.at(i).complexType == complexType) {
724  item = m_complexContentTypes.at(i);
725  foundCorrespondingItem = true;
726  break;
727  }
728  }
729 
730  if (!foundCorrespondingItem)
731  return;
732 
733  const SchemaType::Ptr baseType = complexType->wxsSuperType();
734 
735  // at this point simple types have been resolved already, so we care about
736  // complex types here only
737  if (baseType->isComplexType() && baseType->isDefinedBySchema())
739 
740 
741  // @see http://www.w3.org/TR/xmlschema11-1/#dcl.ctd.ctcc.common
742 
743  // 3
744  XsdParticle::Ptr effectiveContent;
745  if (!item.explicitContent) { // 3.1
746  if (item.effectiveMixed == true) { // 3.1.1
747  const XsdParticle::Ptr particle(new XsdParticle());
748  particle->setMinimumOccurs(1);
749  particle->setMaximumOccurs(1);
750  particle->setMaximumOccursUnbounded(false);
751 
752  const XsdModelGroup::Ptr sequence(new XsdModelGroup());
754  particle->setTerm(sequence);
755 
756  effectiveContent = particle;
757  } else { // 3.1.2
758  effectiveContent = XsdParticle::Ptr();
759  }
760  } else { // 3.2
761  effectiveContent = item.explicitContent;
762  }
763 
764  // 4
767  if (!effectiveContent) { // 4.1.1
768  explicitContentType->setVariety(XsdComplexType::ContentType::Empty);
769  } else { // 4.1.2
770  if (item.effectiveMixed == true)
771  explicitContentType->setVariety(XsdComplexType::ContentType::Mixed);
772  else
773  explicitContentType->setVariety(XsdComplexType::ContentType::ElementOnly);
774 
775  explicitContentType->setParticle(effectiveContent);
776  }
778  const SchemaType::Ptr baseType = item.complexType->wxsSuperType();
779  if (baseType->isSimpleType() || (baseType->isComplexType() && baseType->isDefinedBySchema() && (XsdComplexType::Ptr(baseType)->contentType()->variety() == XsdComplexType::ContentType::Empty ||
780  XsdComplexType::Ptr(baseType)->contentType()->variety() == XsdComplexType::ContentType::Simple))) { // 4.2.1
781  if (!effectiveContent) {
782  explicitContentType->setVariety(XsdComplexType::ContentType::Empty);
783  } else {
784  if (item.effectiveMixed == true)
785  explicitContentType->setVariety(XsdComplexType::ContentType::Mixed);
786  else
787  explicitContentType->setVariety(XsdComplexType::ContentType::ElementOnly);
788 
789  explicitContentType->setParticle(effectiveContent);
790  }
791  } else if (baseType->isComplexType() && baseType->isDefinedBySchema() && (XsdComplexType::Ptr(baseType)->contentType()->variety() == XsdComplexType::ContentType::ElementOnly ||
792  XsdComplexType::Ptr(baseType)->contentType()->variety() == XsdComplexType::ContentType::Mixed) && !effectiveContent) { // 4.2.2
793  const XsdComplexType::Ptr complexBaseType(baseType);
794 
795  explicitContentType = complexBaseType->contentType();
796  } else { // 4.2.3
798 
799  XsdParticle::Ptr baseParticle;
800  if (baseType == BuiltinTypes::xsAnyType) {
801  // we need a workaround here, since the xsAnyType is no real (aka XsdComplexType) complex type...
802 
803  baseParticle = XsdParticle::Ptr(new XsdParticle());
804  baseParticle->setMinimumOccurs(1);
805  baseParticle->setMaximumOccurs(1);
806  baseParticle->setMaximumOccursUnbounded(false);
807 
808  const XsdModelGroup::Ptr group(new XsdModelGroup());
810 
811  const XsdParticle::Ptr particle(new XsdParticle());
812  particle->setMinimumOccurs(0);
813  particle->setMaximumOccursUnbounded(true);
814 
815  const XsdWildcard::Ptr wildcard(new XsdWildcard());
818 
819  particle->setTerm(wildcard);
820  XsdParticle::List particles;
821  particles.append(particle);
822  group->setParticles(particles);
823  baseParticle->setTerm(group);
824  } else {
825  const XsdComplexType::Ptr complexBaseType(baseType);
826  baseParticle = complexBaseType->contentType()->particle();
827  }
828  if (baseParticle && baseParticle->term()->isModelGroup() && (XsdModelGroup::Ptr(baseParticle->term())->compositor() == XsdModelGroup::AllCompositor) &&
829  (!item.explicitContent)) { // 4.2.3.1
830 
831  explicitContentType->setParticle(baseParticle);
832  } else if (baseParticle && baseParticle->term()->isModelGroup() && (XsdModelGroup::Ptr(baseParticle->term())->compositor() == XsdModelGroup::AllCompositor) &&
833  (effectiveContent->term()->isModelGroup() && (XsdModelGroup::Ptr(effectiveContent->term())->compositor() == XsdModelGroup::AllCompositor))) { // 4.2.3.2
834  const XsdParticle::Ptr particle(new XsdParticle());
835  particle->setMinimumOccurs(effectiveContent->minimumOccurs());
836  particle->setMaximumOccurs(1);
837  particle->setMaximumOccursUnbounded(false);
838 
839  const XsdModelGroup::Ptr group(new XsdModelGroup());
841  XsdParticle::List particles = XsdModelGroup::Ptr(baseParticle->term())->particles();
842  particles << XsdModelGroup::Ptr(effectiveContent->term())->particles();
843  group->setParticles(particles);
844  particle->setTerm(group);
845 
846  explicitContentType->setParticle(particle);
847  } else { // 4.2.3.3
848  const XsdParticle::Ptr particle(new XsdParticle());
849  particle->setMinimumOccurs(1);
850  particle->setMaximumOccurs(1);
851  particle->setMaximumOccursUnbounded(false);
852 
853  const XsdModelGroup::Ptr group(new XsdModelGroup());
855 
856  if (effectiveContent && effectiveContent->term()->isModelGroup() && XsdModelGroup::Ptr(effectiveContent->term())->compositor() == XsdModelGroup::AllCompositor) {
857  m_context->error(QtXmlPatterns::tr("Content model of complex type %1 contains %2 element, so it cannot be derived by extension from a non-empty type.")
858  .arg(formatType(m_namePool, complexType)).arg(formatKeyword("all")), XsdSchemaContext::XSDError, sourceLocation(complexType));
859  return;
860  }
861 
862  if (baseParticle && baseParticle->term()->isModelGroup() && XsdModelGroup::Ptr(baseParticle->term())->compositor() == XsdModelGroup::AllCompositor) {
863  m_context->error(QtXmlPatterns::tr("Complex type %1 cannot be derived by extension from %2 as the latter contains %3 element in its content model.")
864  .arg(formatType(m_namePool, complexType))
865  .arg(formatType(m_namePool, baseType))
866  .arg(formatKeyword("all")), XsdSchemaContext::XSDError, sourceLocation(complexType));
867  return;
868  }
869 
870  XsdParticle::List particles;
871  if (baseParticle)
872  particles << baseParticle;
873  if (effectiveContent)
874  particles << effectiveContent;
875  group->setParticles(particles);
876  particle->setTerm(group);
877 
878  explicitContentType->setParticle(particle);
879  }
880 
881  if (baseType->isDefinedBySchema()) { // xs:anyType has no open content
882  const XsdComplexType::Ptr complexBaseType(baseType);
883  explicitContentType->setOpenContent(complexBaseType->contentType()->openContent());
884  }
885  }
886  }
887 
888  // 5
889  XsdComplexType::OpenContent::Ptr wildcardElement;
890  if (item.complexType->contentType()->openContent()) { // 5.1
891  wildcardElement = item.complexType->contentType()->openContent();
892  } else {
893  if (m_defaultOpenContent) { // 5.2
894  if ((explicitContentType->variety() != XsdComplexType::ContentType::Empty) || // 5.2.1
895  (explicitContentType->variety() == XsdComplexType::ContentType::Empty && m_defaultOpenContentAppliesToEmpty)) { // 5.2.2
896  wildcardElement = m_defaultOpenContent;
897  }
898  }
899  }
900 
901  // 6
902  if (!wildcardElement) { // 6.1
903  item.complexType->setContentType(explicitContentType);
904  } else {
905  if (wildcardElement->mode() == XsdComplexType::OpenContent::None) { // 6.2
907  contentType->setVariety(explicitContentType->variety());
908  contentType->setParticle(explicitContentType->particle());
909 
910  item.complexType->setContentType(contentType);
911  } else { // 6.3
913 
914  if (explicitContentType->variety() == XsdComplexType::ContentType::Empty)
915  contentType->setVariety(XsdComplexType::ContentType::ElementOnly);
916  else
917  contentType->setVariety(explicitContentType->variety());
918 
919  if (explicitContentType->variety() == XsdComplexType::ContentType::Empty) {
920  const XsdParticle::Ptr particle(new XsdParticle());
921  particle->setMinimumOccurs(1);
922  particle->setMaximumOccurs(1);
923  const XsdModelGroup::Ptr sequence(new XsdModelGroup());
925  particle->setTerm(sequence);
926  contentType->setParticle(particle);
927  } else {
928  contentType->setParticle(explicitContentType->particle());
929  }
930 
932  if (wildcardElement)
933  openContent->setMode(wildcardElement->mode());
934  else
935  openContent->setMode(XsdComplexType::OpenContent::Interleave);
936 
937  if (wildcardElement)
938  openContent->setWildcard(wildcardElement->wildcard());
939 
940  item.complexType->setContentType(contentType);
941  }
942  }
943 }
944 
946 {
947  for (int i = 0; i < m_attributeTypes.count(); ++i) {
948  const AttributeType item = m_attributeTypes.at(i);
949 
951  if (!type) {
952  // maybe it's a basic type...
954  if (!type) {
955  m_context->error(QtXmlPatterns::tr("Type %1 of %2 element cannot be resolved.")
956  .arg(formatType(m_namePool, item.typeName))
957  .arg(formatElement("attribute")),
959  return;
960  }
961  }
962 
963  if (!type->isSimpleType() && type->category() != SchemaType::None) {
964  m_context->error(QtXmlPatterns::tr("Type of %1 element must be a simple type, %2 is not.")
965  .arg(formatElement("attribute"))
966  .arg(formatType(m_namePool, item.typeName)),
968  return;
969  }
970 
971  item.attribute->setType(type);
972  }
973 }
974 
976 {
977  for (int i = 0; i < m_alternativeTypes.count(); ++i) {
978  const AlternativeType item = m_alternativeTypes.at(i);
979 
981  if (!type) {
982  // maybe it's a basic type...
984  if (!type) {
985  m_context->error(QtXmlPatterns::tr("Type %1 of %2 element cannot be resolved.")
986  .arg(formatType(m_namePool, item.typeName))
987  .arg(formatElement("alternative")),
989  return;
990  }
991  }
992 
993  item.alternative->setType(type);
994  }
995 
996  for (int i = 0; i < m_alternativeTypeElements.count(); ++i) {
998  item.alternative->setType(item.element->type());
999  }
1000 }
1001 
1002 bool hasCircularSubstitutionGroup(const XsdElement::Ptr &current, const XsdElement::Ptr &head, const NamePool::Ptr &namePool)
1003 {
1004  if (current == head)
1005  return true;
1006  else {
1008  for (int i = 0; i < elements.count(); ++i) {
1009  if (hasCircularSubstitutionGroup(elements.at(i), head, namePool))
1010  return true;
1011  }
1012  }
1013 
1014  return false;
1015 }
1016 
1018 {
1019  for (int i = 0; i < m_substitutionGroupAffiliations.count(); ++i) {
1021 
1022  XsdElement::List affiliations;
1023  for (int j = 0; j < item.elementNames.count(); ++j) {
1024  const XsdElement::Ptr element = m_schema->element(item.elementNames.at(j));
1025  if (!element) {
1026  m_context->error(QtXmlPatterns::tr("Substitution group %1 of %2 element cannot be resolved.")
1027  .arg(formatKeyword(m_namePool, item.elementNames.at(j)))
1028  .arg(formatElement("element")),
1030  return;
1031  }
1032 
1033  // @see http://www.w3.org/TR/xmlschema11-1/#e-props-correct 5)
1034  if (hasCircularSubstitutionGroup(element, item.element, m_namePool)) {
1035  m_context->error(QtXmlPatterns::tr("Substitution group %1 has circular definition.").arg(formatKeyword(m_namePool, item.elementNames.at(j))), XsdSchemaContext::XSDError, item.location);
1036  return;
1037  }
1038 
1039  affiliations.append(element);
1040  }
1041 
1042  item.element->setSubstitutionGroupAffiliations(affiliations);
1043  }
1044 
1045  for (int i = 0; i < m_substitutionGroupTypes.count(); ++i) {
1046  const XsdElement::Ptr element = m_substitutionGroupTypes.at(i);
1047  element->setType(element->substitutionGroupAffiliations().first()->type());
1048  }
1049 }
1050 
1051 bool isSubstGroupHeadOf(const XsdElement::Ptr &head, const XsdElement::Ptr &element, const NamePool::Ptr &namePool)
1052 {
1053  if (head->name(namePool) == element->name(namePool))
1054  return true;
1055 
1056  const XsdElement::List affiliations = element->substitutionGroupAffiliations();
1057  for (int i = 0; i < affiliations.count(); ++i) {
1058  if (isSubstGroupHeadOf(head, affiliations.at(i), namePool))
1059  return true;
1060  }
1061 
1062  return false;
1063 }
1064 
1066 {
1068  for (int i = 0; i < elements.count(); ++i) {
1069  const XsdElement::Ptr element = elements.at(i);
1070 
1071  // the element is always itself in the substitution group
1072  element->addSubstitutionGroup(element);
1073 
1074  for (int j = 0; j < elements.count(); ++j) {
1075  if (i == j)
1076  continue;
1077 
1078  if (isSubstGroupHeadOf(element, elements.at(j), m_namePool))
1079  element->addSubstitutionGroup(elements.at(j));
1080  }
1081  }
1082 }
1083 
1085 {
1086  // first the global complex types
1087  const SchemaType::List types = m_schema->types();
1088  for (int i = 0; i < types.count(); ++i) {
1089  if (!(types.at(i)->isComplexType()) || !types.at(i)->isDefinedBySchema())
1090  continue;
1091 
1092  const XsdComplexType::Ptr complexType = types.at(i);
1093  if (complexType->contentType()->variety() != XsdComplexType::ContentType::ElementOnly && complexType->contentType()->variety() != XsdComplexType::ContentType::Mixed)
1094  continue;
1095 
1096  resolveTermReference(complexType->contentType()->particle(), QSet<QXmlName>());
1097  }
1098 
1099  // then all anonymous complex types
1100  const SchemaType::List anonymousTypes = m_schema->anonymousTypes();
1101  for (int i = 0; i < anonymousTypes.count(); ++i) {
1102  if (!(anonymousTypes.at(i)->isComplexType()) || !anonymousTypes.at(i)->isDefinedBySchema())
1103  continue;
1104 
1105  const XsdComplexType::Ptr complexType = anonymousTypes.at(i);
1106  if (complexType->contentType()->variety() != XsdComplexType::ContentType::ElementOnly && complexType->contentType()->variety() != XsdComplexType::ContentType::Mixed)
1107  continue;
1108 
1109  resolveTermReference(complexType->contentType()->particle(), QSet<QXmlName>());
1110  }
1111 
1112  const XsdModelGroup::List groups = m_schema->elementGroups();
1113  for (int i = 0; i < groups.count(); ++i) {
1114  const XsdParticle::Ptr particle(new XsdParticle());
1115  particle->setTerm(groups.at(i));
1116  resolveTermReference(particle, QSet<QXmlName>());
1117  }
1118 }
1119 
1121 {
1122  if (!particle)
1123  return;
1124 
1125  const XsdTerm::Ptr term = particle->term();
1126 
1127  // if it is a model group, we iterate over it recursive...
1128  if (term->isModelGroup()) {
1129  const XsdModelGroup::Ptr modelGroup = term;
1130  const XsdParticle::List particles = modelGroup->particles();
1131 
1132  for (int i = 0; i < particles.count(); ++i) {
1133  resolveTermReference(particles.at(i), visitedGroups);
1134  }
1135 
1136  // check for unique names of elements inside all compositor
1137  if (modelGroup->compositor() != XsdModelGroup::ChoiceCompositor) {
1138  for (int i = 0; i < particles.count(); ++i) {
1139  const XsdParticle::Ptr particle = particles.at(i);
1140  const XsdTerm::Ptr term = particle->term();
1141 
1142  if (!(term->isElement()))
1143  continue;
1144 
1145  for (int j = 0; j < particles.count(); ++j) {
1146  const XsdParticle::Ptr otherParticle = particles.at(j);
1147  const XsdTerm::Ptr otherTerm = otherParticle->term();
1148 
1149  if (otherTerm->isElement() && i != j) {
1150  const XsdElement::Ptr element = term;
1151  const XsdElement::Ptr otherElement = otherTerm;
1152 
1153  if (element->name(m_namePool) == otherElement->name(m_namePool)) {
1154  if (modelGroup->compositor() == XsdModelGroup::AllCompositor) {
1155  m_context->error(QtXmlPatterns::tr("Duplicated element names %1 in %2 element.")
1156  .arg(formatKeyword(element->displayName(m_namePool)))
1157  .arg(formatElement("all")),
1159  return;
1160  } else if (modelGroup->compositor() == XsdModelGroup::SequenceCompositor) {
1161  if (element->type() != otherElement->type()) { // not same variety
1162  m_context->error(QtXmlPatterns::tr("Duplicated element names %1 in %2 element.")
1163  .arg(formatKeyword(element->displayName(m_namePool)))
1164  .arg(formatElement("sequence")),
1166  return;
1167  }
1168  }
1169  }
1170  }
1171  }
1172  }
1173  }
1174 
1175  return;
1176  }
1177 
1178  // ...otherwise we have reached the end of recursion...
1179  if (!term->isReference())
1180  return;
1181 
1182  // ...or we have reached a reference term that must be resolved
1183  const XsdReference::Ptr reference = term;
1184  switch (reference->type()) {
1185  case XsdReference::Element:
1186  {
1187  const XsdElement::Ptr element = m_schema->element(reference->referenceName());
1188  if (element) {
1189  particle->setTerm(element);
1190  } else {
1191  m_context->error(QtXmlPatterns::tr("Reference %1 of %2 element cannot be resolved.")
1192  .arg(formatKeyword(m_namePool, reference->referenceName()))
1193  .arg(formatElement("element")),
1194  XsdSchemaContext::XSDError, reference->sourceLocation());
1195  return;
1196  }
1197  }
1198  break;
1200  {
1201  const XsdModelGroup::Ptr modelGroup = m_schema->elementGroup(reference->referenceName());
1202  if (modelGroup) {
1203  if (visitedGroups.contains(modelGroup->name(m_namePool))) {
1204  m_context->error(QtXmlPatterns::tr("Circular group reference for %1.").arg(formatKeyword(modelGroup->displayName(m_namePool))),
1205  XsdSchemaContext::XSDError, reference->sourceLocation());
1206  } else {
1207  visitedGroups.insert(modelGroup->name(m_namePool));
1208  }
1209 
1210  particle->setTerm(modelGroup);
1211 
1212  // start recursive iteration here as well to get all references resolved
1213  const XsdParticle::List particles = modelGroup->particles();
1214  for (int i = 0; i < particles.count(); ++i) {
1215  resolveTermReference(particles.at(i), visitedGroups);
1216  }
1217 
1218  if (modelGroup->compositor() == XsdModelGroup::AllCompositor) {
1219  if (m_allGroups.contains(reference)) {
1220  m_context->error(QtXmlPatterns::tr("%1 element is not allowed in this scope").arg(formatElement("all.")),
1221  XsdSchemaContext::XSDError, reference->sourceLocation());
1222  return;
1223  }
1224  if (particle->maximumOccursUnbounded() || particle->maximumOccurs() != 1) {
1225  m_context->error(QtXmlPatterns::tr("%1 element cannot have %2 attribute with value other than %3.")
1226  .arg(formatElement("all"))
1227  .arg(formatAttribute("maxOccurs"))
1228  .arg(formatData("1")),
1229  XsdSchemaContext::XSDError, reference->sourceLocation());
1230  return;
1231  }
1232  if (particle->minimumOccurs() != 0 && particle->minimumOccurs() != 1) {
1233  m_context->error(QtXmlPatterns::tr("%1 element cannot have %2 attribute with value other than %3 or %4.")
1234  .arg(formatElement("all"))
1235  .arg(formatAttribute("minOccurs"))
1236  .arg(formatData("0"))
1237  .arg(formatData("1")),
1238  XsdSchemaContext::XSDError, reference->sourceLocation());
1239  return;
1240  }
1241  }
1242  } else {
1243  m_context->error(QtXmlPatterns::tr("Reference %1 of %2 element cannot be resolved.")
1244  .arg(formatKeyword(m_namePool, reference->referenceName()))
1245  .arg(formatElement("group")),
1246  XsdSchemaContext::XSDError, reference->sourceLocation());
1247  return;
1248  }
1249  }
1250  break;
1251  }
1252 }
1253 
1255 {
1256  // first all global attribute groups
1257  const XsdAttributeGroup::List attributeGroups = m_schema->attributeGroups();
1258  for (int i = 0; i < attributeGroups.count(); ++i) {
1259  XsdWildcard::Ptr wildcard = attributeGroups.at(i)->wildcard();
1260  const XsdAttributeUse::List uses = resolveAttributeTermReferences(attributeGroups.at(i)->attributeUses(), wildcard, QSet<QXmlName>());
1261  attributeGroups.at(i)->setAttributeUses(uses);
1262  attributeGroups.at(i)->setWildcard(wildcard);
1263  }
1264 
1265  // then the global complex types
1266  const SchemaType::List types = m_schema->types();
1267  for (int i = 0; i < types.count(); ++i) {
1268  if (!(types.at(i)->isComplexType()) || !types.at(i)->isDefinedBySchema())
1269  continue;
1270 
1271  const XsdComplexType::Ptr complexType = types.at(i);
1272  const XsdAttributeUse::List attributeUses = complexType->attributeUses();
1273 
1274  XsdWildcard::Ptr wildcard = complexType->attributeWildcard();
1275  const XsdAttributeUse::List uses = resolveAttributeTermReferences(attributeUses, wildcard, QSet<QXmlName>());
1276  complexType->setAttributeUses(uses);
1277  complexType->setAttributeWildcard(wildcard);
1278  }
1279 
1280  // and afterwards all anonymous complex types
1281  const SchemaType::List anonymousTypes = m_schema->anonymousTypes();
1282  for (int i = 0; i < anonymousTypes.count(); ++i) {
1283  if (!(anonymousTypes.at(i)->isComplexType()) || !anonymousTypes.at(i)->isDefinedBySchema())
1284  continue;
1285 
1286  const XsdComplexType::Ptr complexType = anonymousTypes.at(i);
1287  const XsdAttributeUse::List attributeUses = complexType->attributeUses();
1288 
1289  XsdWildcard::Ptr wildcard = complexType->attributeWildcard();
1290  const XsdAttributeUse::List uses = resolveAttributeTermReferences(attributeUses, wildcard, QSet<QXmlName>());
1291  complexType->setAttributeUses(uses);
1292  complexType->setAttributeWildcard(wildcard);
1293  }
1294 }
1295 
1297 {
1298  XsdAttributeUse::List resolvedAttributeUses;
1299 
1300  for (int i = 0; i < attributeUses.count(); ++i) {
1301  const XsdAttributeUse::Ptr attributeUse = attributeUses.at(i);
1302  if (attributeUse->isAttributeUse()) {
1303  // it is a real attribute use, so no need to resolve it
1304  resolvedAttributeUses.append(attributeUse);
1305  } else if (attributeUse->isReference()) {
1306  // it is just a reference, so resolve it to the real attribute use
1307 
1308  const XsdAttributeReference::Ptr reference = attributeUse;
1309  if (reference->type() == XsdAttributeReference::AttributeUse) {
1310 
1311  // lookup the real attribute
1312  const XsdAttribute::Ptr attribute = m_schema->attribute(reference->referenceName());
1313  if (!attribute) {
1314  m_context->error(QtXmlPatterns::tr("Reference %1 of %2 element cannot be resolved.")
1315  .arg(formatKeyword(m_namePool, reference->referenceName()))
1316  .arg(formatElement("attribute")),
1317  XsdSchemaContext::XSDError, reference->sourceLocation());
1318  return XsdAttributeUse::List();
1319  }
1320 
1321  // if both, reference and definition have a fixed or default value set, then they must be equal
1322  if (attribute->valueConstraint() && attributeUse->valueConstraint()) {
1323  if (attribute->valueConstraint()->value() != attributeUse->valueConstraint()->value()) {
1324  m_context->error(QtXmlPatterns::tr("%1 or %2 attribute of reference %3 does not match with the attribute declaration %4.")
1325  .arg(formatAttribute("fixed"))
1326  .arg(formatAttribute("default"))
1327  .arg(formatKeyword(m_namePool, reference->referenceName()))
1328  .arg(formatKeyword(attribute->displayName(m_namePool))),
1329  XsdSchemaContext::XSDError, reference->sourceLocation());
1330  return XsdAttributeUse::List();
1331  }
1332  }
1333 
1334  attributeUse->setAttribute(attribute);
1335  if (!attributeUse->valueConstraint() && attribute->valueConstraint())
1336  attributeUse->setValueConstraint(XsdAttributeUse::ValueConstraint::fromAttributeValueConstraint(attribute->valueConstraint()));
1337 
1338  resolvedAttributeUses.append(attributeUse);
1339  } else if (reference->type() == XsdAttributeReference::AttributeGroup) {
1340  const XsdAttributeGroup::Ptr attributeGroup = m_schema->attributeGroup(reference->referenceName());
1341  if (!attributeGroup) {
1342  m_context->error(QtXmlPatterns::tr("Reference %1 of %2 element cannot be resolved.")
1343  .arg(formatKeyword(m_namePool, reference->referenceName()))
1344  .arg(formatElement("attributeGroup")),
1345  XsdSchemaContext::XSDError, reference->sourceLocation());
1346  return XsdAttributeUse::List();
1347  }
1348  if (visitedAttributeGroups.contains(attributeGroup->name(m_namePool))) {
1349  m_context->error(QtXmlPatterns::tr("Attribute group %1 has circular reference.").arg(formatKeyword(m_namePool, reference->referenceName())),
1350  XsdSchemaContext::XSDError, reference->sourceLocation());
1351  return XsdAttributeUse::List();
1352  } else {
1353  visitedAttributeGroups.insert(attributeGroup->name(m_namePool));
1354  }
1355 
1356  // resolve attribute wildcards as defined in http://www.w3.org/TR/xmlschema11-1/#declare-attributeGroup-wildcard
1357  XsdWildcard::Ptr childWildcard;
1358  resolvedAttributeUses << resolveAttributeTermReferences(attributeGroup->attributeUses(), childWildcard, visitedAttributeGroups);
1359  if (!childWildcard) {
1360  if (attributeGroup->wildcard()) {
1361  if (wildcard) {
1362  const XsdWildcard::ProcessContents contents = wildcard->processContents();
1363  wildcard = XsdSchemaHelper::wildcardIntersection(wildcard, attributeGroup->wildcard());
1364  wildcard->setProcessContents(contents);
1365  } else {
1366  wildcard = attributeGroup->wildcard();
1367  }
1368  }
1369  } else {
1370  XsdWildcard::Ptr newWildcard;
1371  if (attributeGroup->wildcard()) {
1372  const XsdWildcard::ProcessContents contents = attributeGroup->wildcard()->processContents();
1373  newWildcard = XsdSchemaHelper::wildcardIntersection(attributeGroup->wildcard(), childWildcard);
1374  newWildcard->setProcessContents(contents);
1375  } else {
1376  newWildcard = childWildcard;
1377  }
1378 
1379  if (wildcard) {
1380  const XsdWildcard::ProcessContents contents = wildcard->processContents();
1381  wildcard = XsdSchemaHelper::wildcardIntersection(wildcard, newWildcard);
1382  wildcard->setProcessContents(contents);
1383  } else {
1384  wildcard = newWildcard;
1385  }
1386  }
1387  }
1388  }
1389  }
1390 
1391  return resolvedAttributeUses;
1392 }
1393 
1395 {
1396  // collect the global and anonymous complex types
1398  types << m_schema->anonymousTypes();
1399 
1400  QSet<XsdComplexType::Ptr> visitedTypes;
1401  for (int i = 0; i < types.count(); ++i) {
1402  if (!(types.at(i)->isComplexType()) || !types.at(i)->isDefinedBySchema())
1403  continue;
1404 
1405  const XsdComplexType::Ptr complexType = types.at(i);
1406 
1407  resolveAttributeInheritance(complexType, visitedTypes);
1408  }
1409 }
1410 
1411 bool isValidWildcardRestriction(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &baseWildcard)
1412 {
1413  if (wildcard->namespaceConstraint()->variety() == baseWildcard->namespaceConstraint()->variety()) {
1414  if (!XsdSchemaHelper::checkWildcardProcessContents(baseWildcard, wildcard))
1415  return false;
1416  }
1417 
1418  if (wildcard->namespaceConstraint()->variety() == XsdWildcard::NamespaceConstraint::Any &&
1419  baseWildcard->namespaceConstraint()->variety() != XsdWildcard::NamespaceConstraint::Any ) {
1420  return false;
1421  }
1422  if (baseWildcard->namespaceConstraint()->variety() == XsdWildcard::NamespaceConstraint::Not &&
1424  if (!baseWildcard->namespaceConstraint()->namespaces().intersect(wildcard->namespaceConstraint()->namespaces()).isEmpty())
1425  return false;
1426  }
1427  if (baseWildcard->namespaceConstraint()->variety() == XsdWildcard::NamespaceConstraint::Enumeration &&
1429  if (!wildcard->namespaceConstraint()->namespaces().subtract(baseWildcard->namespaceConstraint()->namespaces()).isEmpty())
1430  return false;
1431  }
1432 
1433  return true;
1434 }
1435 
1436 /*
1437  * Since we inherit the attributes from our base class we have to walk up in the
1438  * inheritance hierarchy first and resolve the attribute inheritance top-down.
1439  */
1441 {
1442  if (visitedTypes.contains(complexType))
1443  return;
1444  else
1445  visitedTypes.insert(complexType);
1446 
1447  const SchemaType::Ptr baseType = complexType->wxsSuperType();
1448  Q_ASSERT(baseType);
1449 
1450  if (!(baseType->isComplexType()) || !baseType->isDefinedBySchema())
1451  return;
1452 
1453  const XsdComplexType::Ptr complexBaseType = baseType;
1454 
1455  resolveAttributeInheritance(complexBaseType, visitedTypes);
1456 
1457  // @see http://www.w3.org/TR/xmlschema11-1/#dcl.ctd.attuses
1458 
1459  // 1 and 2 (the attribute groups have been resolved here already)
1460  const XsdAttributeUse::List uses = complexBaseType->attributeUses();
1461 
1462  if (complexType->derivationMethod() == XsdComplexType::DerivationRestriction) { // 3.2
1463  const XsdAttributeUse::List currentUses = complexType->attributeUses();
1464 
1465  // 3.2.1 and 3.2.2 As we also keep the prohibited attributes as objects, the algorithm below
1466  // handles both the same way
1467 
1468  // add only these attribute uses of the base type that match one of the following criteria:
1469  // 1: there is no attribute use with the same name in type
1470  // 2: there is no attribute with the same name marked as prohibited in type
1471  for (int j = 0; j < uses.count(); ++j) {
1472  const XsdAttributeUse::Ptr use = uses.at(j);
1473  bool found = false;
1474  for (int k = 0; k < currentUses.count(); ++k) {
1475  if (use->attribute()->name(m_namePool) == currentUses.at(k)->attribute()->name(m_namePool)) {
1476  found = true;
1477 
1478  // check if prohibited usage is violated
1479  if ((use->useType() == XsdAttributeUse::ProhibitedUse) && (currentUses.at(k)->useType() != XsdAttributeUse::ProhibitedUse)) {
1480  m_context->error(QtXmlPatterns::tr("%1 attribute in %2 must have %3 use like in base type %4.")
1481  .arg(formatAttribute(use->attribute()->displayName(m_namePool)))
1482  .arg(formatType(m_namePool, complexType))
1483  .arg(formatData("prohibited"))
1484  .arg(formatType(m_namePool, complexBaseType)),
1486  return;
1487  }
1488 
1489  break;
1490  }
1491  }
1492 
1493  if (!found && uses.at(j)->useType() != XsdAttributeUse::ProhibitedUse) {
1494  complexType->addAttributeUse(uses.at(j));
1495  }
1496  }
1497  } else if (complexType->derivationMethod() == XsdComplexType::DerivationExtension) { // 3.1
1499 
1500  // fill hash with attribute uses of current type for faster lookup
1501  {
1502  const XsdAttributeUse::List attributeUses = complexType->attributeUses();
1503 
1504  for (int i = 0; i < attributeUses.count(); ++i) {
1505  availableUses.insert(attributeUses.at(i)->attribute()->name(m_namePool), attributeUses.at(i));
1506  }
1507  }
1508 
1509  // just add the attribute uses of the base type
1510  for (int i = 0; i < uses.count(); ++i) {
1511  const XsdAttributeUse::Ptr currentAttributeUse = uses.at(i);
1512 
1513  // if the base type defines the attribute as prohibited but we override it in current type, then don't copy the prohibited attribute use
1514  if ((currentAttributeUse->useType() == XsdAttributeUse::ProhibitedUse) && availableUses.contains(currentAttributeUse->attribute()->name(m_namePool)))
1515  continue;
1516 
1517  complexType->addAttributeUse(uses.at(i));
1518  }
1519  }
1520 
1521  // handle attribute wildcards: @see http://www.w3.org/TR/xmlschema11-1/#dcl.ctd.anyatt
1522 
1523  // 1
1524  const XsdWildcard::Ptr completeWildcard(complexType->attributeWildcard());
1525 
1527  if (complexType->wxsSuperType()->isComplexType() && complexType->wxsSuperType()->isDefinedBySchema()) {
1528  const XsdComplexType::Ptr complexBaseType(complexType->wxsSuperType());
1529  if (complexType->attributeWildcard()) {
1530  if (complexBaseType->attributeWildcard()) {
1531  if (!isValidWildcardRestriction(complexType->attributeWildcard(), complexBaseType->attributeWildcard())) {
1532  m_context->error(QtXmlPatterns::tr("Attribute wildcard of %1 is not a valid restriction of attribute wildcard of base type %2.")
1533  .arg(formatType(m_namePool, complexType))
1534  .arg(formatType(m_namePool, complexBaseType)),
1536  return;
1537  }
1538  } else {
1539  m_context->error(QtXmlPatterns::tr("%1 has attribute wildcard but its base type %2 has not.")
1540  .arg(formatType(m_namePool, complexType))
1541  .arg(formatType(m_namePool, complexBaseType)),
1543  return;
1544  }
1545  }
1546  }
1547  complexType->setAttributeWildcard(completeWildcard); // 2.1
1548  } else if (complexType->derivationMethod() == XsdComplexType::DerivationExtension) {
1549  XsdWildcard::Ptr baseWildcard; // 2.2.1
1550  if (complexType->wxsSuperType()->isComplexType() && complexType->wxsSuperType()->isDefinedBySchema())
1551  baseWildcard = XsdComplexType::Ptr(complexType->wxsSuperType())->attributeWildcard(); // 2.2.1.1
1552  else
1553  baseWildcard = XsdWildcard::Ptr(); // 2.2.1.2
1554 
1555  if (!baseWildcard) {
1556  complexType->setAttributeWildcard(completeWildcard); // 2.2.2.1
1557  } else if (!completeWildcard) {
1558  complexType->setAttributeWildcard(baseWildcard); // 2.2.2.2
1559  } else {
1560  XsdWildcard::Ptr unionWildcard = XsdSchemaHelper::wildcardUnion(completeWildcard, baseWildcard);
1561  if (unionWildcard) {
1562  unionWildcard->setProcessContents(completeWildcard->processContents());
1563  complexType->setAttributeWildcard(unionWildcard); // 2.2.2.3
1564  } else {
1565  m_context->error(QtXmlPatterns::tr("Union of attribute wildcard of type %1 and attribute wildcard of its base type %2 is not expressible.")
1566  .arg(formatType(m_namePool, complexType))
1567  .arg(formatType(m_namePool, complexBaseType)),
1569  return;
1570  }
1571  }
1572  }
1573 }
1574 
1576 {
1577  XsdSimpleType::List simpleTypes;
1578 
1579  // first collect the global simple types
1580  const SchemaType::List types = m_schema->types();
1581  for (int i = 0; i < types.count(); ++i) {
1582  if (types.at(i)->isSimpleType())
1583  simpleTypes.append(types.at(i));
1584  }
1585 
1586  // then collect all anonymous simple types
1587  const SchemaType::List anonymousTypes = m_schema->anonymousTypes();
1588  for (int i = 0; i < anonymousTypes.count(); ++i) {
1589  if (anonymousTypes.at(i)->isSimpleType())
1590  simpleTypes.append(anonymousTypes.at(i));
1591  }
1592  // process all simple types
1593  for (int i = 0; i < simpleTypes.count(); ++i) {
1594  const XsdSimpleType::Ptr simpleType = simpleTypes.at(i);
1595 
1596  // we resolve the enumeration values only for xs:QName and xs:NOTATION based types
1597  if (BuiltinTypes::xsQName->wxsTypeMatches(simpleType) ||
1599  const XsdFacet::Hash facets = simpleType->facets();
1600  if (facets.contains(XsdFacet::Enumeration)) {
1601  AtomicValue::List newValues;
1602 
1603  const XsdFacet::Ptr facet = facets.value(XsdFacet::Enumeration);
1604  const AtomicValue::List values = facet->multiValue();
1605  for (int j = 0; j < values.count(); ++j) {
1606  const AtomicValue::Ptr value = values.at(j);
1607 
1608  Q_ASSERT(m_enumerationFacetValues.contains(value));
1609  const NamespaceSupport support( m_enumerationFacetValues.value(value) );
1610 
1611  const QString qualifiedName = value->as<DerivedString<TypeString> >()->stringValue();
1612  if (!XPathHelper::isQName(qualifiedName)) {
1613  m_context->error(QtXmlPatterns::tr("Enumeration facet contains invalid content: {%1} is not a value of type %2.")
1614  .arg(formatData(qualifiedName))
1617  return;
1618  }
1619 
1620  QXmlName qNameValue;
1621  bool result = support.processName(qualifiedName, NamespaceSupport::ElementName, qNameValue);
1622  if (!result) {
1623  m_context->error(QtXmlPatterns::tr("Namespace prefix of qualified name %1 is not defined.").arg(formatData(qualifiedName)),
1625  return;
1626  }
1627 
1628  newValues.append(QNameValue::fromValue(m_namePool, qNameValue));
1629  }
1630  facet->setMultiValue(newValues);
1631  }
1632  }
1633  }
1634 }
1635 
1637 {
1638  if (m_componentLocationHash.contains(component)) {
1639  return m_componentLocationHash.value(component);
1640  } else {
1642  location.setLine(1);
1643  location.setColumn(1);
1644  location.setUri(QString::fromLatin1("dummyUri"));
1645 
1646  return location;
1647  }
1648 }
1649 
1651 {
1652  for (int i = 0; i < m_complexBaseTypes.count(); ++i) {
1653  if (m_complexBaseTypes.at(i).complexType == complexType)
1654  return m_complexBaseTypes.at(i).facets;
1655  }
1656 
1657  return XsdFacet::Hash();
1658 }
1659 
1661 {
1662  for (int i = 0; i < m_redefinedGroups.count(); ++i) {
1663  const RedefinedGroups item = m_redefinedGroups.at(i);
1664 
1665  // create dummy particles...
1666  const XsdParticle::Ptr redefinedParticle(new XsdParticle());
1667  redefinedParticle->setTerm(item.redefinedGroup);
1668  const XsdParticle::Ptr particle(new XsdParticle());
1669  particle->setTerm(item.group);
1670 
1671  // so that we can pass them to XsdParticleChecker::subsumes()
1672  QString errorMsg;
1673  if (!XsdParticleChecker::subsumes(particle, redefinedParticle, m_context, errorMsg)) {
1674  m_context->error(QtXmlPatterns::tr("%1 element %2 is not a valid restriction of the %3 element it redefines: %4.")
1675  .arg(formatElement("group"))
1677  .arg(formatElement("group"))
1678  .arg(errorMsg),
1680  return;
1681  }
1682  }
1683 }
1684 
1686 {
1687  for (int i = 0; i < m_redefinedAttributeGroups.count(); ++i) {
1689 
1690  QString errorMsg;
1692  m_context->error(QtXmlPatterns::tr("%1 element %2 is not a valid restriction of the %3 element it redefines: %4.")
1693  .arg(formatElement("attributeGroup"))
1695  .arg(formatElement("attributeGroup"))
1696  .arg(errorMsg),
1698  return;
1699  }
1700  }
1701 }
1702 
1704 {
1705  if (visitedTypes.contains(type)) {
1706  // found invalid circular reference...
1707  return AnySimpleType::Ptr();
1708  } else {
1709  visitedTypes.insert(type);
1710  }
1711 
1712  const QXmlName typeName = type->name(m_namePool);
1713  if (typeName == BuiltinTypes::xsString->name(m_namePool) ||
1714  typeName == BuiltinTypes::xsBoolean->name(m_namePool) ||
1715  typeName == BuiltinTypes::xsFloat->name(m_namePool) ||
1716  typeName == BuiltinTypes::xsDouble->name(m_namePool) ||
1717  typeName == BuiltinTypes::xsDecimal->name(m_namePool) ||
1718  typeName == BuiltinTypes::xsDuration->name(m_namePool) ||
1719  typeName == BuiltinTypes::xsDateTime->name(m_namePool) ||
1720  typeName == BuiltinTypes::xsTime->name(m_namePool) ||
1721  typeName == BuiltinTypes::xsDate->name(m_namePool) ||
1722  typeName == BuiltinTypes::xsGYearMonth->name(m_namePool) ||
1723  typeName == BuiltinTypes::xsGYear->name(m_namePool) ||
1724  typeName == BuiltinTypes::xsGMonthDay->name(m_namePool) ||
1725  typeName == BuiltinTypes::xsGDay->name(m_namePool) ||
1726  typeName == BuiltinTypes::xsGMonth->name(m_namePool) ||
1727  typeName == BuiltinTypes::xsHexBinary->name(m_namePool) ||
1729  typeName == BuiltinTypes::xsAnyURI->name(m_namePool) ||
1730  typeName == BuiltinTypes::xsQName->name(m_namePool) ||
1731  typeName == BuiltinTypes::xsNOTATION->name(m_namePool) ||
1733  return type;
1734  else {
1735  if (type->wxsSuperType())
1736  return findPrimitiveType(type->wxsSuperType(), visitedTypes);
1737  else {
1738  return AnySimpleType::Ptr();
1739  }
1740  }
1741 }
1742 
virtual DerivationMethod derivationMethod() const
Describes the content type of a complex type.
QAtomicInt ref
Definition: qshareddata.h:59
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
The complex type has further elements or attributes and text as content.
void addSubstitutionGroup(const XsdElement::Ptr &elements)
static const AtomicType::Ptr xsBase64Binary
void addComponentLocationHash(const QHash< NamedSchemaComponent::Ptr, QSourceLocation > &hash)
QVector< ElementType > m_elementTypes
QHash< AtomicValue::Ptr, NamespaceSupport > m_enumerationFacetValues
virtual TypeCategory category() const =0
Represents a XSD simpleType object.
void setSubstitutionGroupAffiliations(const XsdElement::List &affiliations)
int type
Definition: qmetatype.cpp:239
virtual TypeCategory category() const
void addSubstitutionGroupAffiliation(const XsdElement::Ptr &element, const QList< QXmlName > &elementName, const QSourceLocation &location)
void resolveTermReference(const XsdParticle::Ptr &particle, QSet< QXmlName > visitedGroups)
virtual SchemaType::Ptr wxsSuperType() const
Represents a XSD model group object.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
XsdElement::Ptr element(const QXmlName &name) const
Definition: qxsdschema.cpp:82
XsdAttributeGroup::Ptr attributeGroup(const QXmlName name) const
Definition: qxsdschema.cpp:195
void setItemType(const AnySimpleType::Ptr &type)
virtual bool isSimpleType() const
Definition: qschematype.cpp:56
static XsdWildcard::Ptr wildcardIntersection(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &otherWildcard)
QString formatKeyword(const QString &keyword)
ProcessContents processContents() const
void addSimpleListType(const XsdSimpleType::Ptr &simpleType, const QXmlName &typeName, const QSourceLocation &location)
static const AtomicType::Ptr xsDuration
QVector< SimpleListType > m_simpleListTypes
void addRedefinedAttributeGroups(const XsdAttributeGroup::Ptr &redefinedGroup, const XsdAttributeGroup::Ptr &group)
QVector< AlternativeType > m_alternativeTypes
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
XsdTerm::Ptr term() const
QVector< SimpleRestrictionBase > m_simpleRestrictionBases
QSet< XsdReference::Ptr > m_allGroups
XsdIdentityConstraint::Ptr identityConstraint(const QXmlName &name) const
Definition: qxsdschema.cpp:258
XsdWildcard::Ptr wildcard() const
QVector< ComplexBaseType > m_complexBaseTypes
ValueConstraint::Ptr valueConstraint() const
static bool subsumes(const XsdParticle::Ptr &particle, const XsdParticle::Ptr &derivedParticle, const XsdSchemaContext::Ptr &context, QString &errorMsg)
static const AtomicType::Ptr xsGYearMonth
void setAttributeUses(const XsdAttributeUse::List &uses)
void setParticles(const XsdParticle::List &particles)
The attribute is not allowed to be there.
void setUri(const QUrl &newUri)
Sets the URI to newUri.
The model group contains elements only.
QVector< SimpleUnionType > m_simpleUnionTypes
XsdComplexType::OpenContent::Ptr m_defaultOpenContent
static const AtomicType::Ptr xsGMonthDay
XsdAttributeUse::List attributeUses() const
void setLine(qint64 newLine)
Sets the line number to newLine.
SchemaType::List anonymousTypes() const
Definition: qxsdschema.cpp:181
XsdElement::List substitutionGroupAffiliations() const
Represents a XSD wildcard object.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void setMinimumOccurs(unsigned int occurrence)
bool hasCircularSubstitutionGroup(const XsdElement::Ptr &current, const XsdElement::Ptr &head, const NamePool::Ptr &namePool)
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
XsdModelGroup::List elementGroups() const
Definition: qxsdschema.cpp:223
The reference points to an attribute group.
static ValueConstraint::Ptr fromAttributeValueConstraint(const XsdAttribute::ValueConstraint::Ptr &constraint)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
void setType(const AnySimpleType::Ptr &type)
void setDerivationMethod(DerivationMethod method)
static QByteArray qualifiedName(const QMetaEnum &e)
QVector< RedefinedAttributeGroups > m_redefinedAttributeGroups
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QExplicitlySharedDataPointer< XsdSchemaContext > m_context
XsdAttributeUse::List attributeUses() const
QHash< XsdFacet::Type, XsdFacet::Ptr > Hash
Definition: qxsdfacet_p.h:118
virtual QXmlName name(const NamePool::Ptr &np) const
Returns the name of the type.
ContentType::Ptr contentType() const
void addKeyReference(const XsdElement::Ptr &element, const XsdIdentityConstraint::Ptr &keyRef, const QXmlName &name, const QSourceLocation &location)
XsdWildcard::Ptr attributeWildcard() const
void setProcessContents(ProcessContents contents)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
void setDefaultOpenContent(const XsdComplexType::OpenContent::Ptr &openContent, bool appliesToEmpty)
SchemaType::Ptr type() const
static const AtomicType::Ptr xsString
void setMaximumOccurs(unsigned int occurrence)
virtual SchemaType::Ptr wxsSuperType() const
Match an enumeration (Enumeration Definition)
Definition: qxsdfacet_p.h:115
static const SchemaType::Ptr xsAnyType
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
unsigned int maximumOccurs() const
virtual bool isElement() const
Definition: qxsdterm.cpp:48
static const AtomicType::Ptr xsGDay
The reference points to a model group.
void addRedefinedGroups(const XsdModelGroup::Ptr &redefinedGroup, const XsdModelGroup::Ptr &group)
virtual SchemaType::Ptr wxsSuperType() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const TCastTarget * as() const
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
SchemaTypeFactory::Ptr schemaTypeFactory() const
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QHash< NamedSchemaComponent::Ptr, QSourceLocation > m_componentLocationHash
static bool checkWildcardProcessContents(const XsdWildcard::Ptr &baseWildcard, const XsdWildcard::Ptr &derivedWildcard)
static bool isEmpty(const char *str)
unsigned int minimumOccurs() const
void setFacets(const XsdFacet::Hash &facets)
XsdParticle::List particles() const
static QNameValue::Ptr fromValue(const NamePool::Ptr &np, const QXmlName name)
Definition: qqnamevalue.cpp:59
static QString formatElement(const QString &element)
Formats element name.
const char * typeName
Definition: qmetatype.cpp:239
static const AtomicType::Ptr xsDateTime
Namespaces in the namespaces set are not allowed.
bool contains(const T &value) const
Definition: qset.h:91
void setColumn(qint64 newColumn)
Sets the column number to newColumn.
XsdXPathExpression::List fields() const
void addAllGroupCheck(const XsdReference::Ptr &reference)
void setWxsSuperType(const SchemaType::Ptr &type)
QList< XsdAttributeUse::Ptr > List
virtual bool isComplexType() const
Definition: qschematype.cpp:70
const char * name
Represents a XSD particle object.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
XsdModelGroup::Ptr elementGroup(const QXmlName &name) const
Definition: qxsdschema.cpp:216
XsdFacet::Hash complexTypeFacets(const XsdComplexType::Ptr &complexType) const
The namespace for the internal API of QtXmlPatterns.
virtual QString displayName(const NamePool::Ptr &namePool) const
const_iterator insert(const T &value)
Definition: qset.h:179
static const AtomicType::Ptr xsDouble
The QSourceLocation class identifies a location in a resource by URI, line, and column.
QSourceLocation sourceLocation(const NamedSchemaComponent::Ptr component) const
static bool isValidAttributeGroupRestriction(const XsdAttributeGroup::Ptr &derivedAttributeGroup, const XsdAttributeGroup::Ptr &attributeGroup, const XsdSchemaContext::Ptr &context, QString &errorMsg)
QExplicitlySharedDataPointer< XsdModelGroup > Ptr
QExplicitlySharedDataPointer< XsdParticle > Ptr
void setTerm(const XsdTerm::Ptr &term)
void addAttributeUse(const XsdAttributeUse::Ptr &use)
QVector< KeyReference > m_keyReferences
void addComplexBaseType(const XsdComplexType::Ptr &complexType, const QXmlName &baseName, const QSourceLocation &location, const XsdFacet::Hash &facets=XsdFacet::Hash())
static qreal component(const QPointF &point, unsigned int i)
static const AtomicType::Ptr xsGYear
quint16 values[128]
static QString formatData(const QString &data)
void addSubstitutionGroupType(const XsdElement::Ptr &element)
A helper class for handling nested namespace declarations.
void setMemberTypes(const AnySimpleType::List &types)
SchemaType::Ptr type(const QXmlName &name) const
Definition: qxsdschema.cpp:124
void setType(const SchemaType::Ptr &type)
QXmlName baseTypeNameOfType(const SchemaType::Ptr &type) const
virtual QXmlName name(const NamePool::Ptr &namePool) const
void copyDataTo(const XsdSchemaResolver::Ptr &other) const
void setWxsSuperType(const SchemaType::Ptr &type)
QXmlName typeNameOfAttribute(const XsdAttribute::Ptr &attribute) const
The constraint is an unique constraint.
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
Represents instances of derived xs:string types, such as xs:normalizedString.
The complex type has only simple type content (e.g. text, number etc.)
void setPrimitiveType(const AnySimpleType::Ptr &type)
void addEnumerationFacetValue(const AtomicValue::Ptr &facetValue, const NamespaceSupport &namespaceSupport)
void setReferencedKey(const XsdIdentityConstraint::Ptr &key)
void addComponentLocationHash(const QHash< NamedSchemaComponent::Ptr, QSourceLocation > &hash)
virtual DerivationMethod derivationMethod() const
bool maximumOccursUnbounded() const
NamespaceConstraint::Ptr namespaceConstraint() const
void setCategory(TypeCategory category)
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
XsdSchemaResolver(const QExplicitlySharedDataPointer< XsdSchemaContext > &context, const XsdSchemaParserContext *parserContext)
QExplicitlySharedDataPointer< XsdWildcard > Ptr
static const AtomicType::Ptr xsQName
virtual bool isReference() const
Definition: qxsdterm.cpp:63
The reference points to an attribute use.
static const struct @32 types[]
static bool wxsTypeMatches(const SchemaType::Ptr &type, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > &visitedTypes, SchemaType::Ptr &conflictingType)
XsdFacet::Hash facets() const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void setCompositor(ModelCompositor compositor)
void removeSimpleRestrictionBase(const XsdSimpleType::Ptr &type)
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
Definition: qhash.h:693
void addAnonymousType(const SchemaType::Ptr &type)
Definition: qxsdschema.cpp:168
static const SchemaType::Ptr xsAnySimpleType
static const AtomicType::Ptr xsFloat
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
void setAttributeWildcard(const XsdWildcard::Ptr &wildcard)
AnySimpleType::Ptr findPrimitiveType(const AnySimpleType::Ptr &type, QSet< AnySimpleType::Ptr > &visitedTypes)
static XsdWildcard::Ptr wildcardUnion(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &otherWildcard)
void setContentType(const ContentType::Ptr &type)
virtual DerivationMethod derivationMethod() const =0
QExplicitlySharedDataPointer< AnySimpleType > Ptr
virtual SchemaType::Hash types() const =0
virtual bool isModelGroup() const
Definition: qxsdterm.cpp:53
XsdAttribute::Ptr attribute(const QXmlName &name) const
Definition: qxsdschema.cpp:103
static const AtomicType::Ptr xsTime
AnySimpleType::List memberTypes() const
static const QTextHtmlElement elements[Html_NumElements]
QExplicitlySharedDataPointer< XsdSchemaChecker > m_checker
virtual SchemaType::Ptr createSchemaType(const QXmlName name) const =0
static const AtomicType::Ptr xsDecimal
XsdAttributeGroup::List attributeGroups() const
Definition: qxsdschema.cpp:202
static const AtomicType::Ptr xsBoolean
void addAttributeType(const XsdAttribute::Ptr &attribute, const QXmlName &typeName, const QSourceLocation &location)
void addElementType(const XsdElement::Ptr &element, const QXmlName &typeName, const QSourceLocation &location)
QExplicitlySharedDataPointer< XsdComplexType > Ptr
static bool isParticleEmptiable(const XsdParticle::Ptr &particle)
ModelCompositor compositor() const
Namespaces in the namespaces set are allowed.
static const AtomicType::Ptr xsDate
If the item has a uniquely determined declaration available, it must be valid with respect to that de...
QVector< ComplexContentType > m_complexContentTypes
QVector< AlternativeTypeElement > m_alternativeTypeElements
static QString formatAttribute(const QString &attribute)
Formats attribute name.
void addSimpleUnionTypes(const XsdSimpleType::Ptr &simpleType, const QList< QXmlName > &typeNames, const QSourceLocation &location)
static bool isQName(const QString &qName)
QVector< XsdElement::Ptr > m_substitutionGroupTypes
void removeComplexBaseType(const XsdComplexType::Ptr &type)
void setType(const SchemaType::Ptr &type)
virtual bool isDefinedBySchema() const
Definition: qschematype.cpp:75
SchemaType::List types() const
Definition: qxsdschema.cpp:131
The complex type has further elements or attributes but no text as content.
static const AtomicType::Ptr xsNOTATION
static const AtomicType::Ptr xsGMonth
void addAlternativeType(const XsdAlternative::Ptr &alternative, const QXmlName &typeName, const QSourceLocation &location)
bool isValidWildcardRestriction(const XsdWildcard::Ptr &wildcard, const XsdWildcard::Ptr &baseWildcard)
bool isSubstGroupHeadOf(const XsdElement::Ptr &head, const XsdElement::Ptr &element, const NamePool::Ptr &namePool)
The complex type has no further content.
QVector< AttributeType > m_attributeTypes
static const AtomicType::Ptr xsHexBinary
void addComplexContentType(const XsdComplexType::Ptr &complexType, const XsdParticle::Ptr &content, bool mixed)
The reference points to an element.
static const AtomicType::Ptr xsAnyURI
XsdElement::List elements() const
Definition: qxsdschema.cpp:89
QHash< Key, T > & unite(const QHash< Key, T > &other)
Inserts all the items in the other hash into this hash.
Definition: qhash.h:556
Describes the open content object of a complex type.
void setMaximumOccursUnbounded(bool unbounded)
The constraint is a key constraint.
QVector< RedefinedGroups > m_redefinedGroups
void addSimpleRestrictionBase(const XsdSimpleType::Ptr &simpleType, const QXmlName &baseName, const QSourceLocation &location)
QVector< SubstitutionGroupAffiliation > m_substitutionGroupAffiliations
AnySimpleType::Ptr itemType() const