Qt 4.8
Public Types | Public Functions | Private Functions | Properties | List of all members
QPatternist::XsdSchemaMerger Class Reference

A helper class that merges two schemas into one. More...

#include <qxsdschemamerger_p.h>

Inheritance diagram for QPatternist::XsdSchemaMerger:
QSharedData

Public Types

typedef QExplicitlySharedDataPointer< XsdSchemaMergerPtr
 

Public Functions

XsdSchema::Ptr mergedSchema () const
 
 XsdSchemaMerger (const XsdSchema::Ptr &schema, const XsdSchema::Ptr &otherSchema)
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Private Functions

void merge (const XsdSchema::Ptr &schema, const XsdSchema::Ptr &otherSchema)
 

Properties

XsdSchema::Ptr m_mergedSchema
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

A helper class that merges two schemas into one.

This class is used in XsdValidatingInstanceReader to merge the schema given in the constructor with a schema defined in the instance document via xsi:schemaLocation or xsi:noNamespaceSchema location.

Author
Tobias Koenig tobia.nosp@m.s.ko.nosp@m.enig@.nosp@m.noki.nosp@m.a.com

Definition at line 73 of file qxsdschemamerger_p.h.

Typedefs

◆ Ptr

Definition at line 76 of file qxsdschemamerger_p.h.

Constructors and Destructors

◆ XsdSchemaMerger()

XsdSchemaMerger::XsdSchemaMerger ( const XsdSchema::Ptr schema,
const XsdSchema::Ptr otherSchema 
)

Creates a new schema merger object that merges schema with otherSchema.

Definition at line 48 of file qxsdschemamerger.cpp.

49 {
50  merge(schema, otherSchema);
51 }
void merge(const XsdSchema::Ptr &schema, const XsdSchema::Ptr &otherSchema)

Functions

◆ merge()

void XsdSchemaMerger::merge ( const XsdSchema::Ptr schema,
const XsdSchema::Ptr otherSchema 
)
private

Definition at line 58 of file qxsdschemamerger.cpp.

Referenced by XsdSchemaMerger().

59 {
60  m_mergedSchema = XsdSchema::Ptr(new XsdSchema(otherSchema->namePool()));
61 
62  // first fill the merged schema with the values from schema
63  if (schema) {
64  const XsdElement::List elements = schema->elements();
65  for (int i = 0; i < elements.count(); ++i) {
66  m_mergedSchema->addElement(elements.at(i));
67  }
68 
69  const XsdAttribute::List attributes = schema->attributes();
70  for (int i = 0; i < attributes.count(); ++i) {
71  m_mergedSchema->addAttribute(attributes.at(i));
72  }
73 
74  const SchemaType::List types = schema->types();
75  for (int i = 0; i < types.count(); ++i) {
76  m_mergedSchema->addType(types.at(i));
77  }
78 
79  const SchemaType::List anonymousTypes = schema->anonymousTypes();
80  for (int i = 0; i < anonymousTypes.count(); ++i) {
81  m_mergedSchema->addAnonymousType(anonymousTypes.at(i));
82  }
83 
84  const XsdModelGroup::List elementGroups = schema->elementGroups();
85  for (int i = 0; i < elementGroups.count(); ++i) {
86  m_mergedSchema->addElementGroup(elementGroups.at(i));
87  }
88 
89  const XsdAttributeGroup::List attributeGroups = schema->attributeGroups();
90  for (int i = 0; i < attributeGroups.count(); ++i) {
91  m_mergedSchema->addAttributeGroup(attributeGroups.at(i));
92  }
93 
94  const XsdNotation::List notations = schema->notations();
95  for (int i = 0; i < notations.count(); ++i) {
96  m_mergedSchema->addNotation(notations.at(i));
97  }
98 
99  const XsdIdentityConstraint::List identityConstraints = schema->identityConstraints();
100  for (int i = 0; i < identityConstraints.count(); ++i) {
101  m_mergedSchema->addIdentityConstraint(identityConstraints.at(i));
102  }
103  }
104 
105  // then merge in the values from the otherSchema
106  {
107  const XsdElement::List elements = otherSchema->elements();
108  for (int i = 0; i < elements.count(); ++i) {
109  if (!m_mergedSchema->element(elements.at(i)->name(otherSchema->namePool())))
110  m_mergedSchema->addElement(elements.at(i));
111  }
112 
113  const XsdAttribute::List attributes = otherSchema->attributes();
114  for (int i = 0; i < attributes.count(); ++i) {
115  if (!m_mergedSchema->attribute(attributes.at(i)->name(otherSchema->namePool())))
116  m_mergedSchema->addAttribute(attributes.at(i));
117  }
118 
119  const SchemaType::List types = otherSchema->types();
120  for (int i = 0; i < types.count(); ++i) {
121  if (!m_mergedSchema->type(types.at(i)->name(otherSchema->namePool())))
122  m_mergedSchema->addType(types.at(i));
123  }
124 
125  const SchemaType::List anonymousTypes = otherSchema->anonymousTypes();
126  for (int i = 0; i < anonymousTypes.count(); ++i) {
127  // add anonymous type as they are
128  m_mergedSchema->addAnonymousType(anonymousTypes.at(i));
129  }
130 
131  const XsdModelGroup::List elementGroups = otherSchema->elementGroups();
132  for (int i = 0; i < elementGroups.count(); ++i) {
133  if (!m_mergedSchema->elementGroup(elementGroups.at(i)->name(otherSchema->namePool())))
134  m_mergedSchema->addElementGroup(elementGroups.at(i));
135  }
136 
137  const XsdAttributeGroup::List attributeGroups = otherSchema->attributeGroups();
138  for (int i = 0; i < attributeGroups.count(); ++i) {
139  if (!m_mergedSchema->attributeGroup(attributeGroups.at(i)->name(otherSchema->namePool())))
140  m_mergedSchema->addAttributeGroup(attributeGroups.at(i));
141  }
142 
143  const XsdNotation::List notations = otherSchema->notations();
144  for (int i = 0; i < notations.count(); ++i) {
145  if (!m_mergedSchema->notation(notations.at(i)->name(otherSchema->namePool())))
146  m_mergedSchema->addNotation(notations.at(i));
147  }
148 
149  const XsdIdentityConstraint::List identityConstraints = otherSchema->identityConstraints();
150  for (int i = 0; i < identityConstraints.count(); ++i) {
151  if (!m_mergedSchema->identityConstraint(identityConstraints.at(i)->name(otherSchema->namePool())))
152  m_mergedSchema->addIdentityConstraint(identityConstraints.at(i));
153  }
154  }
155 }
void addElement(const XsdElement::Ptr &element)
Definition: qxsdschema.cpp:75
XsdElement::Ptr element(const QXmlName &name) const
Definition: qxsdschema.cpp:82
XsdAttributeGroup::Ptr attributeGroup(const QXmlName name) const
Definition: qxsdschema.cpp:195
XsdIdentityConstraint::Ptr identityConstraint(const QXmlName &name) const
Definition: qxsdschema.cpp:258
void addAttributeGroup(const XsdAttributeGroup::Ptr &group)
Definition: qxsdschema.cpp:188
Represents a XSD schema object.
Definition: qxsdschema_p.h:91
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
XsdModelGroup::List elementGroups() const
Definition: qxsdschema.cpp:223
void addIdentityConstraint(const XsdIdentityConstraint::Ptr &constraint)
Definition: qxsdschema.cpp:251
void addNotation(const XsdNotation::Ptr &notation)
Definition: qxsdschema.cpp:230
XsdIdentityConstraint::List identityConstraints() const
Definition: qxsdschema.cpp:265
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
XsdNotation::Ptr notation(const QXmlName &name) const
Definition: qxsdschema.cpp:237
XsdNotation::List notations() const
Definition: qxsdschema.cpp:244
QExplicitlySharedDataPointer< XsdSchema > Ptr
Definition: qxsdschema_p.h:94
SchemaType::Ptr type(const QXmlName &name) const
Definition: qxsdschema.cpp:124
virtual QXmlName name(const NamePool::Ptr &namePool) const
static const struct @32 types[]
void addAnonymousType(const SchemaType::Ptr &type)
Definition: qxsdschema.cpp:168
XsdAttribute::List attributes() const
Definition: qxsdschema.cpp:110
XsdAttribute::Ptr attribute(const QXmlName &name) const
Definition: qxsdschema.cpp:103
static const QTextHtmlElement elements[Html_NumElements]
void addElementGroup(const XsdModelGroup::Ptr &group)
Definition: qxsdschema.cpp:209
XsdAttributeGroup::List attributeGroups() const
Definition: qxsdschema.cpp:202
void addType(const SchemaType::Ptr &type)
Definition: qxsdschema.cpp:117
SchemaType::List types() const
Definition: qxsdschema.cpp:131
virtual QXmlName name(const NamePool::Ptr &np) const =0
Returns the name of the type.
XsdElement::List elements() const
Definition: qxsdschema.cpp:89
void addAttribute(const XsdAttribute::Ptr &attribute)
Definition: qxsdschema.cpp:96
NamePool::Ptr namePool() const
Definition: qxsdschema.cpp:60

◆ mergedSchema()

XsdSchema::Ptr XsdSchemaMerger::mergedSchema ( ) const

Returns the merged schema.

Definition at line 53 of file qxsdschemamerger.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::addSchema().

54 {
55  return m_mergedSchema;
56 }

Properties

◆ m_mergedSchema

XsdSchema::Ptr QPatternist::XsdSchemaMerger::m_mergedSchema
private

Definition at line 91 of file qxsdschemamerger_p.h.

Referenced by merge(), and mergedSchema().


The documentation for this class was generated from the following files: