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

Public Functions

void finalize () const
 
 TagValidationHandler (XsdTagScope::Type tag, XsdSchemaParser *parser, const NamePool::Ptr &namePool)
 
void validate (XsdSchemaToken::NodeName token)
 

Properties

XsdStateMachine< XsdSchemaToken::NodeNamem_machine
 
XsdSchemaParserm_parser
 

Detailed Description

A helper class that checks for the right occurrence of xml tags with the help of a DFA.

Definition at line 149 of file qxsdschemaparser.cpp.

Constructors and Destructors

◆ TagValidationHandler()

QPatternist::TagValidationHandler::TagValidationHandler ( XsdTagScope::Type  tag,
XsdSchemaParser parser,
const NamePool::Ptr namePool 
)
inline

Definition at line 152 of file qxsdschemaparser.cpp.

153  : m_parser(parser), m_machine(namePool)
154  {
155  Q_ASSERT(m_parser->m_stateMachines.contains(tag));
156 
157  m_machine = m_parser->m_stateMachines.value(tag);
158  m_machine.reset();
159  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QHash< XsdTagScope::Type, XsdStateMachine< XsdSchemaToken::NodeName > > m_stateMachines
XsdStateMachine< XsdSchemaToken::NodeName > m_machine

Functions

◆ finalize()

void QPatternist::TagValidationHandler::finalize ( ) const
inline

Definition at line 190 of file qxsdschemaparser.cpp.

Referenced by QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), and QPatternist::XsdSchemaParser::parseWhiteSpaceFacet().

191  {
192  if (!m_machine.inEndState()) {
194 
195  QStringList elementNames;
196  for (int i = 0; i < tokens.count(); ++i)
197  elementNames.append(formatElement(XsdSchemaToken::toString(tokens.at(i))));
198 
199  m_parser->error(QtXmlPatterns::tr("Child element is missing in that scope, possible child elements are: %1.")
200  .arg(elementNames.join(QLatin1String(", "))));
201  }
202  }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QString toString(NodeName token)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static QString formatElement(const QString &element)
Formats element name.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
virtual void error(const QString &msg)
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
XsdStateMachine< XsdSchemaToken::NodeName > m_machine
QList< TransitionType > possibleTransitions() const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ validate()

void QPatternist::TagValidationHandler::validate ( XsdSchemaToken::NodeName  token)
inline

Definition at line 161 of file qxsdschemaparser.cpp.

Referenced by QPatternist::XsdSchemaParser::parseAll(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAnnotation(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAssertion(), QPatternist::XsdSchemaParser::parseChoice(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), QPatternist::XsdSchemaParser::parseGlobalSimpleType(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKey(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAll(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalChoice(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseLocalSequence(), QPatternist::XsdSchemaParser::parseLocalSimpleType(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseNamedAttributeGroup(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSequence(), QPatternist::XsdSchemaParser::parseSimpleContent(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseUnique(), and QPatternist::XsdSchemaParser::parseWhiteSpaceFacet().

162  {
163  if (token == XsdSchemaToken::NoKeyword) {
165 
166  QStringList elementNames;
167  for (int i = 0; i < tokens.count(); ++i)
168  elementNames.append(formatElement(XsdSchemaToken::toString(tokens.at(i))));
169 
170  m_parser->error(QtXmlPatterns::tr("Can not process unknown element %1, expected elements are: %2.")
171  .arg(formatElement(m_parser->name().toString()))
172  .arg(elementNames.join(QLatin1String(", "))));
173  return;
174  }
175 
176  if (!m_machine.proceed(token)) {
178 
179  QStringList elementNames;
180  for (int i = 0; i < tokens.count(); ++i)
181  elementNames.append(formatElement(XsdSchemaToken::toString(tokens.at(i))));
182 
183  m_parser->error(QtXmlPatterns::tr("Element %1 is not allowed in this scope, possible elements are: %2.")
185  .arg(elementNames.join(QLatin1String(", "))));
186  return;
187  }
188  }
QString toString() const
Returns a copy of the string reference as a QString object.
Definition: qstring.cpp:8653
QStringRef name() const
Returns the local name of a StartElement, EndElement, or an EntityReference.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QString toString(NodeName token)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static QString formatElement(const QString &element)
Formats element name.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
virtual void error(const QString &msg)
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
XsdStateMachine< XsdSchemaToken::NodeName > m_machine
bool proceed(TransitionType transition)
QList< TransitionType > possibleTransitions() const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Properties

◆ m_machine

XsdStateMachine<XsdSchemaToken::NodeName> QPatternist::TagValidationHandler::m_machine
private

Definition at line 206 of file qxsdschemaparser.cpp.

◆ m_parser

XsdSchemaParser* QPatternist::TagValidationHandler::m_parser
private

Definition at line 205 of file qxsdschemaparser.cpp.


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