Qt 4.8
Public Functions | Properties | List of all members
QPatternist::XsdSchemaDebugger Class Reference

#include <qxsdschemadebugger_p.h>

Public Functions

void dumpAttribute (const XsdAttribute::Ptr &attribute)
 
void dumpElement (const XsdElement::Ptr &element)
 
void dumpInheritance (const SchemaType::Ptr &type, int level=0)
 
void dumpParticle (const XsdParticle::Ptr &particle, int level=0)
 
void dumpSchema (const XsdSchema::Ptr &schema)
 
void dumpType (const SchemaType::Ptr &type)
 
void dumpWildcard (const XsdWildcard::Ptr &wildcard)
 
 XsdSchemaDebugger (const NamePool::Ptr &namePool)
 

Properties

const NamePool::Ptr m_namePool
 

Detailed Description

A helper class to print out the structure of a compiled schema.

Definition at line 66 of file qxsdschemadebugger_p.h.

Constructors and Destructors

◆ XsdSchemaDebugger()

XsdSchemaDebugger::XsdSchemaDebugger ( const NamePool::Ptr namePool)

Creates a new schema debugger.

Parameters
namePoolThe name pool that the schema uses.

Definition at line 48 of file qxsdschemadebugger.cpp.

49  : m_namePool(namePool)
50 {
51 }

Functions

◆ dumpAttribute()

void XsdSchemaDebugger::dumpAttribute ( const XsdAttribute::Ptr attribute)

Dumps the structure of the given attribute.

Definition at line 177 of file qxsdschemadebugger.cpp.

Referenced by dumpSchema().

178 {
179  qDebug() << "Name:" << attribute->displayName(m_namePool);
180  qDebug() << "Type:" << attribute->type()->displayName(m_namePool);
181 }
Q_CORE_EXPORT void qDebug(const char *,...)
AnySimpleType::Ptr type() const
virtual QString displayName(const NamePool::Ptr &namePool) const
virtual QString displayName(const NamePool::Ptr &np) const

◆ dumpElement()

void XsdSchemaDebugger::dumpElement ( const XsdElement::Ptr element)

Dumps the structure of the given element.

Definition at line 160 of file qxsdschemadebugger.cpp.

Referenced by dumpSchema().

161 {
162  QStringList disallowedSubstGroup;
164  disallowedSubstGroup << QLatin1String("restriction");
166  disallowedSubstGroup << QLatin1String("extension");
168  disallowedSubstGroup << QLatin1String("substitution");
169 
170 
171  qDebug() << "Name:" << element->displayName(m_namePool);
172  qDebug() << "IsAbstract:" << (element->isAbstract() ? "yes" : "no");
173  qDebug() << "Type:" << element->type()->displayName(m_namePool);
174  qDebug() << "DisallowedSubstitutionGroups:" << disallowedSubstGroup.join(QLatin1String("' "));
175 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
SchemaType::Ptr type() const
Q_CORE_EXPORT void qDebug(const char *,...)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
virtual QString displayName(const NamePool::Ptr &namePool) const
QString join(const QString &sep) const
Joins all the string list&#39;s strings into a single string with each element separated by the given sep...
Definition: qstringlist.h:162
BlockingConstraints disallowedSubstitutions() const
virtual QString displayName(const NamePool::Ptr &np) const =0
Returns a suitable display name for this type.

◆ dumpInheritance()

void XsdSchemaDebugger::dumpInheritance ( const SchemaType::Ptr type,
int  level = 0 
)

Dumps the inheritance path of the given type.

Parameters
typeThe type to dump.
levelThe level of indention.

Definition at line 80 of file qxsdschemadebugger.cpp.

Referenced by dumpType().

81 {
82  QString prefix; prefix.fill(QLatin1Char(' '), level);
83  qDebug("%s-->%s", qPrintable(prefix), qPrintable(type->displayName(m_namePool)));
84  if (type->wxsSuperType())
85  dumpInheritance(type->wxsSuperType(), ++level);
86 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qDebug(const char *,...)
void dumpInheritance(const SchemaType::Ptr &type, int level=0)
QString & fill(QChar c, int size=-1)
Sets every character in the string to character ch.
Definition: qstring.cpp:4641
#define qPrintable(string)
Definition: qglobal.h:1750
virtual SchemaType::Ptr wxsSuperType() const =0
virtual QString displayName(const NamePool::Ptr &np) const =0
Returns a suitable display name for this type.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ dumpParticle()

void XsdSchemaDebugger::dumpParticle ( const XsdParticle::Ptr particle,
int  level = 0 
)

Dumps the structure of the given particle.

Parameters
particleThe particle to dump.
levelThe level of indention.

Definition at line 53 of file qxsdschemadebugger.cpp.

Referenced by dumpType().

54 {
55  QString prefix; prefix.fill(QLatin1Char(' '), level);
56 
57  qDebug("%s min=%s max=%s", qPrintable(prefix), qPrintable(QString::number(particle->minimumOccurs())),
58  qPrintable(particle->maximumOccursUnbounded() ? QLatin1String("unbounded") : QString::number(particle->maximumOccurs())));
59 
60  if (particle->term()->isElement()) {
61  qDebug("%selement (%s)", qPrintable(prefix), qPrintable(XsdElement::Ptr(particle->term())->displayName(m_namePool)));
62  } else if (particle->term()->isModelGroup()) {
63  const XsdModelGroup::Ptr group(particle->term());
64  if (group->compositor() == XsdModelGroup::SequenceCompositor) {
65  qDebug("%ssequence", qPrintable(prefix));
66  } else if (group->compositor() == XsdModelGroup::AllCompositor) {
67  qDebug("%sall", qPrintable(prefix));
68  } else if (group->compositor() == XsdModelGroup::ChoiceCompositor) {
69  qDebug("%schoice", qPrintable(prefix));
70  }
71 
72  for (int i = 0; i < group->particles().count(); ++i)
73  dumpParticle(group->particles().at(i), level + 5);
74  } else if (particle->term()->isWildcard()) {
75  XsdWildcard::Ptr wildcard(particle->term());
76  qDebug("%swildcard (process=%d)", qPrintable(prefix), wildcard->processContents());
77  }
78 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
XsdTerm::Ptr term() const
The model group contains elements only.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool isWildcard() const
Definition: qxsdterm.cpp:58
Q_CORE_EXPORT void qDebug(const char *,...)
virtual bool isElement() const
Definition: qxsdterm.cpp:48
void dumpParticle(const XsdParticle::Ptr &particle, int level=0)
unsigned int minimumOccurs() const
bool maximumOccursUnbounded() const
QString & fill(QChar c, int size=-1)
Sets every character in the string to character ch.
Definition: qstring.cpp:4641
virtual bool isModelGroup() const
Definition: qxsdterm.cpp:53
#define qPrintable(string)
Definition: qglobal.h:1750
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ dumpSchema()

void XsdSchemaDebugger::dumpSchema ( const XsdSchema::Ptr schema)

Dumps the structure of the complete schema.

Definition at line 183 of file qxsdschemadebugger.cpp.

184 {
185  qDebug() << "------------------------------ Schema -------------------------------";
186 
187  // elements
188  {
189  qDebug() << "Global Elements:";
190  const XsdElement::List elements = schema->elements();
191  for (int i = 0; i < elements.count(); ++i) {
192  dumpElement(elements.at(i));
193  }
194  }
195 
196  // attributes
197  {
198  qDebug() << "Global Attributes:";
199  const XsdAttribute::List attributes = schema->attributes();
200  for (int i = 0; i < attributes.count(); ++i) {
201  dumpAttribute(attributes.at(i));
202  }
203  }
204 
205  // types
206  {
207  qDebug() << "Global Types:";
208  const SchemaType::List types = schema->types();
209  for (int i = 0; i < types.count(); ++i) {
210  dumpType(types.at(i));
211  }
212  }
213 
214  // anonymous types
215  {
216  qDebug() << "Anonymous Types:";
217  const SchemaType::List types = schema->anonymousTypes();
218  for (int i = 0; i < types.count(); ++i) {
219  dumpType(types.at(i));
220  }
221  }
222 
223  qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
224 }
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
void dumpType(const SchemaType::Ptr &type)
Q_CORE_EXPORT void qDebug(const char *,...)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static const struct @32 types[]
void dumpAttribute(const XsdAttribute::Ptr &attribute)
XsdAttribute::List attributes() const
Definition: qxsdschema.cpp:110
static const QTextHtmlElement elements[Html_NumElements]
void dumpElement(const XsdElement::Ptr &element)
SchemaType::List types() const
Definition: qxsdschema.cpp:131
XsdElement::List elements() const
Definition: qxsdschema.cpp:89

◆ dumpType()

void XsdSchemaDebugger::dumpType ( const SchemaType::Ptr type)

Dumps the structure of the given type.

Definition at line 107 of file qxsdschemadebugger.cpp.

Referenced by dumpSchema().

108 {
109  if (type->isComplexType()) {
110  const XsdComplexType::Ptr complexType(type);
111  qDebug("\n+++ Complex Type +++");
112  qDebug("Name: %s (abstract: %s)", qPrintable(complexType->displayName(m_namePool)), complexType->isAbstract() ? "yes" : "no");
113  if (complexType->wxsSuperType())
114  qDebug(" base type: %s", qPrintable(complexType->wxsSuperType()->displayName(m_namePool)));
115  else
116  qDebug(" base type: (none)");
117  if (complexType->contentType()->variety() == XsdComplexType::ContentType::Empty)
118  qDebug(" content type: empty");
119  if (complexType->contentType()->variety() == XsdComplexType::ContentType::Simple)
120  qDebug(" content type: simple");
121  if (complexType->contentType()->variety() == XsdComplexType::ContentType::ElementOnly)
122  qDebug(" content type: element-only");
123  if (complexType->contentType()->variety() == XsdComplexType::ContentType::Mixed)
124  qDebug(" content type: mixed");
125  if (complexType->contentType()->variety() == XsdComplexType::ContentType::Simple) {
126  if (complexType->contentType()->simpleType())
127  qDebug(" simple type: %s", qPrintable(complexType->contentType()->simpleType()->displayName(m_namePool)));
128  else
129  qDebug(" simple type: (none)");
130  }
131 
132  const XsdAttributeUse::List uses = complexType->attributeUses();
133  qDebug(" %d attributes", uses.count());
134  for (int i = 0; i < uses.count(); ++i) {
135  qDebug(" attr: %s", qPrintable(uses.at(i)->attribute()->displayName(m_namePool)));
136  }
137  qDebug(" has attribute wildcard: %s", complexType->attributeWildcard() ? "yes" : "no");
138  if (complexType->attributeWildcard()) {
139  dumpWildcard(complexType->attributeWildcard());
140  }
141 
142  if (complexType->contentType()->particle()) {
143  dumpParticle(complexType->contentType()->particle(), 5);
144  }
145  } else {
146  qDebug("\n+++ Simple Type +++");
147  qDebug("Name: %s", qPrintable(type->displayName(m_namePool)));
148  if (type->isDefinedBySchema()) {
149  const XsdSimpleType::Ptr simpleType(type);
150  if (simpleType->primitiveType())
151  qDebug(" primitive type: %s", qPrintable(simpleType->primitiveType()->displayName(m_namePool)));
152  else
153  qDebug(" primitive type: (none)");
154  }
155  dumpInheritance(type, 0);
156  }
157 }
The complex type has further elements or attributes and text as content.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_CORE_EXPORT void qDebug(const char *,...)
void dumpParticle(const XsdParticle::Ptr &particle, int level=0)
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
The complex type has only simple type content (e.g. text, number etc.)
void dumpWildcard(const XsdWildcard::Ptr &wildcard)
void dumpInheritance(const SchemaType::Ptr &type, int level=0)
virtual bool isDefinedBySchema() const
Definition: qschematype.cpp:75
The complex type has further elements or attributes but no text as content.
#define qPrintable(string)
Definition: qglobal.h:1750
virtual QString displayName(const NamePool::Ptr &np) const =0
Returns a suitable display name for this type.
The complex type has no further content.

◆ dumpWildcard()

void XsdSchemaDebugger::dumpWildcard ( const XsdWildcard::Ptr wildcard)

Dumps the structure of the given wildcard.

Definition at line 88 of file qxsdschemadebugger.cpp.

Referenced by dumpType().

89 {
90  QVector<QString> varietyNames;
91  varietyNames.append(QLatin1String("Any"));
92  varietyNames.append(QLatin1String("Enumeration"));
93  varietyNames.append(QLatin1String("Not"));
94 
95  QVector<QString> processContentsNames;
96  processContentsNames.append(QLatin1String("Strict"));
97  processContentsNames.append(QLatin1String("Lax"));
98  processContentsNames.append(QLatin1String("Skip"));
99 
100  qDebug(" processContents: %s", qPrintable(processContentsNames.at((int)wildcard->processContents())));
101  const XsdWildcard::NamespaceConstraint::Ptr constraint = wildcard->namespaceConstraint();
102  qDebug(" variety: %s", qPrintable(varietyNames.at((int)constraint->variety())));
103  if (constraint->variety() != XsdWildcard::NamespaceConstraint::Any)
104  qDebug() << " namespaces:" << constraint->namespaces();
105 }
ProcessContents processContents() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
NamespaceConstraint::Ptr namespaceConstraint() const
#define qPrintable(string)
Definition: qglobal.h:1750

Properties

◆ m_namePool

const NamePool::Ptr QPatternist::XsdSchemaDebugger::m_namePool
private

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