Qt 4.8
|
Base class for tokenizers that reads XML formats. This is XSLTTokenizer, and the W3C XML Schema parser. More...
#include <qmaintainingreader_p.h>
Protected Functions | |
TokenLookupClass::NodeName | currentElementName () const |
virtual QUrl | documentURI () const =0 |
Returns the location of the document that MaintainingReader is parsing. Used for error reporting. More... | |
void | error (const QString &message, const ReportContext::ErrorCode code) const |
Convenience function for calling ReportContext::error(). More... | |
bool | hasAttribute (const QString &namespaceURI, const QString &localName) const |
Returns true if the current element has an attribute whose name is namespaceURI and local name is localName . More... | |
bool | hasAttribute (const QString &localName) const |
Returns true if the current element has an attribute whose local name is localName and namespace URI is null. More... | |
virtual bool | isAnyAttributeAllowed () const =0 |
Returns true , if any attribute is allowed on the element currently being validated. More... | |
bool | isWhitespace () const |
MaintainingReader (const typename ElementDescription< TokenLookupClass, LookupKey >::Hash &elementDescriptions, const QSet< typename TokenLookupClass::NodeName > &standardAttributes, const ReportContext::Ptr &context, QIODevice *const queryDevice) | |
QString | readAttribute (const QString &localName, const QString &namespaceURI=QString()) const |
Returns the value for attribute by name name. More... | |
TokenType | readNext () |
void | validateElement (const LookupKey name) const |
void | warning (const QString &message) const |
Convenience function for calling ReportContext::warning(). More... | |
virtual | ~MaintainingReader () |
Protected Variables | |
QXmlStreamAttributes | m_currentAttributes |
bool | m_hasHandledStandardAttributes |
QStack< bool > | m_stripWhitespace |
Private Functions | |
QSourceLocation | currentLocation () const |
Properties | |
const ReportContext::Ptr | m_context |
TokenLookupClass::NodeName | m_currentElementName |
const ElementDescription< TokenLookupClass, LookupKey >::Hash | m_elementDescriptions |
const QSet< typename TokenLookupClass::NodeName > | m_standardAttributes |
Additional Inherited Members | |
Public Types inherited from QXmlStreamReader | |
enum | Error { NoError, UnexpectedElementError, CustomError, NotWellFormedError, PrematureEndOfDocumentError } |
This enum specifies different error cases. More... | |
enum | ReadElementTextBehaviour { ErrorOnUnexpectedElement, IncludeChildElements, SkipChildElements } |
This enum specifies the different behaviours of readElementText(). More... | |
enum | TokenType { NoToken = 0, Invalid, StartDocument, EndDocument, StartElement, EndElement, Characters, Comment, DTD, EntityReference, ProcessingInstruction } |
This enum specifies the type of token the reader just read. More... | |
Public Functions inherited from QXmlStreamReader | |
void | addData (const QByteArray &data) |
Adds more data for the reader to read. More... | |
void | addData (const QString &data) |
Adds more data for the reader to read. More... | |
void | addData (const char *data) |
Adds more data for the reader to read. More... | |
void | addExtraNamespaceDeclaration (const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaraction) |
Adds an extraNamespaceDeclaration. More... | |
void | addExtraNamespaceDeclarations (const QXmlStreamNamespaceDeclarations &extraNamespaceDeclaractions) |
Adds a vector of declarations specified by extraNamespaceDeclarations. More... | |
bool | atEnd () const |
Returns true if the reader has read until the end of the XML document, or if an error() has occurred and reading has been aborted. More... | |
QXmlStreamAttributes | attributes () const |
Returns the attributes of a StartElement. More... | |
qint64 | characterOffset () const |
Returns the current character offset, starting with 0. More... | |
void | clear () |
Removes any device() or data from the reader and resets its internal state to the initial state. More... | |
qint64 | columnNumber () const |
Returns the current column number, starting with 0. More... | |
QIODevice * | device () const |
Returns the current device associated with the QXmlStreamReader, or 0 if no device has been assigned. More... | |
QStringRef | documentEncoding () const |
If the state() is StartDocument , this function returns the encoding string as specified in the XML declaration. More... | |
QStringRef | documentVersion () const |
If the state() is StartDocument , this function returns the version string as specified in the XML declaration. More... | |
QStringRef | dtdName () const |
If the state() is DTD , this function returns the DTD's name. More... | |
QStringRef | dtdPublicId () const |
If the state() is DTD , this function returns the DTD's public identifier. More... | |
QStringRef | dtdSystemId () const |
If the state() is DTD , this function returns the DTD's system identifier. More... | |
QXmlStreamEntityDeclarations | entityDeclarations () const |
If the state() is DTD , this function returns the DTD's unparsed (external) entity declarations. More... | |
QXmlStreamEntityResolver * | entityResolver () const |
Returns the entity resolver, or 0 if there is no entity resolver. More... | |
Error | error () const |
Returns the type of the current error, or NoError if no error occurred. More... | |
QString | errorString () const |
Returns the error message that was set with raiseError(). More... | |
bool | hasError () const |
Returns true if an error has occurred, otherwise false . More... | |
bool | isCDATA () const |
Returns true if the reader reports characters that stem from a CDATA section; otherwise returns false. More... | |
bool | isCharacters () const |
Returns true if tokenType() equals Characters ; otherwise returns false. More... | |
bool | isComment () const |
Returns true if tokenType() equals Comment ; otherwise returns false. More... | |
bool | isDTD () const |
Returns true if tokenType() equals DTD ; otherwise returns false. More... | |
bool | isEndDocument () const |
Returns true if tokenType() equals EndDocument ; otherwise returns false. More... | |
bool | isEndElement () const |
Returns true if tokenType() equals EndElement ; otherwise returns false. More... | |
bool | isEntityReference () const |
Returns true if tokenType() equals EntityReference ; otherwise returns false. More... | |
bool | isProcessingInstruction () const |
Returns true if tokenType() equals ProcessingInstruction ; otherwise returns false. More... | |
bool | isStandaloneDocument () const |
Returns true if this document has been declared standalone in the XML declaration; otherwise returns false. More... | |
bool | isStartDocument () const |
Returns true if tokenType() equals StartDocument ; otherwise returns false. More... | |
bool | isStartElement () const |
Returns true if tokenType() equals StartElement ; otherwise returns false. More... | |
bool | isWhitespace () const |
Returns true if the reader reports characters that only consist of white-space; otherwise returns false. More... | |
qint64 | lineNumber () const |
Returns the current line number, starting with 1. More... | |
QStringRef | name () const |
Returns the local name of a StartElement, EndElement, or an EntityReference. More... | |
QXmlStreamNamespaceDeclarations | namespaceDeclarations () const |
If the state() is StartElement , this function returns the element's namespace declarations. More... | |
bool | namespaceProcessing () const |
This property controls whether or not the stream reader processes namespaces. More... | |
QStringRef | namespaceUri () const |
Returns the namespaceUri of a StartElement or EndElement. More... | |
QXmlStreamNotationDeclarations | notationDeclarations () const |
If the state() is DTD , this function returns the DTD's notation declarations. More... | |
QStringRef | prefix () const |
Returns the prefix of a StartElement or EndElement. More... | |
QStringRef | processingInstructionData () const |
Returns the data of a ProcessingInstruction. More... | |
QStringRef | processingInstructionTarget () const |
Returns the target of a ProcessingInstruction. More... | |
QStringRef | qualifiedName () const |
Returns the qualified name of a StartElement or EndElement;. More... | |
QXmlStreamReader () | |
Constructs a stream reader. More... | |
QXmlStreamReader (QIODevice *device) | |
Creates a new stream reader that reads from device. More... | |
QXmlStreamReader (const QByteArray &data) | |
Creates a new stream reader that reads from data. More... | |
QXmlStreamReader (const QString &data) | |
Creates a new stream reader that reads from data. More... | |
QXmlStreamReader (const char *data) | |
Creates a new stream reader that reads from data. More... | |
void | raiseError (const QString &message=QString()) |
Raises a custom error with an optional error message. More... | |
QString | readElementText (ReadElementTextBehaviour behaviour) |
Convenience function to be called in case a StartElement was read. More... | |
QString | readElementText () |
TokenType | readNext () |
Reads the next token and returns its type. More... | |
bool | readNextStartElement () |
Reads until the next start element within the current element. More... | |
void | setDevice (QIODevice *device) |
Sets the current device to device. More... | |
void | setEntityResolver (QXmlStreamEntityResolver *resolver) |
Makes resolver the new entityResolver(). More... | |
void | setNamespaceProcessing (bool) |
void | skipCurrentElement () |
Reads until the end of the current element, skipping any child nodes. More... | |
QStringRef | text () const |
Returns the text of Characters , Comment , DTD , or EntityReference. More... | |
QString | tokenString () const |
Returns the reader's current token as string. More... | |
TokenType | tokenType () const |
Returns the type of the current token. More... | |
~QXmlStreamReader () | |
Destructs the reader. More... | |
Base class for tokenizers that reads XML formats. This is XSLTTokenizer, and the W3C XML Schema parser.
MaintainingReader is intended for sub-classing.
TokenLookupClass | The name of the class that is generated by QTokenAutomaton and which supplies tokenizing tokens. For XSLTTokenizer, this is XSLTTokenLookup, for instance. |
LookupKey | The type that is passed to validateElement() and is the key in ElementDescription. For the schema code, where elements have different interpretations depending on context, the lookup key is hence not equal element name. |
Definition at line 112 of file qmaintainingreader_p.h.
|
protected |
Definition at line 51 of file qmaintainingreader.cpp.
|
protectedvirtual |
Definition at line 69 of file qmaintainingreader.cpp.
|
inlineprotected |
Returns the name of the current element.
Definition at line 137 of file qmaintainingreader.cpp.
|
inlineprivate |
Returns the current location that QXmlStreamReader has.
Definition at line 75 of file qmaintainingreader.cpp.
|
protectedpure virtual |
Returns the location of the document that MaintainingReader is parsing. Used for error reporting.
Implemented in QPatternist::XsdSchemaParser, and QPatternist::XSLTTokenizer.
|
protected |
Convenience function for calling ReportContext::error().
Definition at line 122 of file qmaintainingreader.cpp.
|
protected |
Returns true
if the current element has an attribute whose name is namespaceURI
and local name is localName
.
Definition at line 247 of file qmaintainingreader.cpp.
|
inlineprotected |
Returns true
if the current element has an attribute whose local name is localName
and namespace URI is null.
Definition at line 256 of file qmaintainingreader.cpp.
|
protectedpure virtual |
Returns true
, if any attribute is allowed on the element currently being validated.
Implemented in QPatternist::XsdSchemaParser, and QPatternist::XSLTTokenizer.
|
protected |
QXmlStreamReader::isWhitespace() returns true for whitespace that is not expressed as character references, while XSL-T operatates ontop of the XDM, which means we needs to return true for those too.
Definition at line 113 of file qmaintainingreader.cpp.
|
protected |
Returns the value for attribute by name name.
If it doesn't exist, an error is raised.
It is assumed that m_reader's current state is QXmlStreamReader::StartElement.
Definition at line 263 of file qmaintainingreader.cpp.
|
protected |
Definition at line 84 of file qmaintainingreader.cpp.
|
protected |
This function is not merged with handleStandardAttributes() because handleStandardAttributes() needs to be called for all elements, while validateElement() only applies to XSL-T elements.
Definition at line 144 of file qmaintainingreader.cpp.
Referenced by QPatternist::XSLTTokenizer::validateElement().
|
protected |
Convenience function for calling ReportContext::warning().
Definition at line 130 of file qmaintainingreader.cpp.
Referenced by QPatternist::MaintainingReader< XSLTTokenLookup >::warning().
|
private |
This member is private, see the error() and warning() functions in this class.
Definition at line 214 of file qmaintainingreader_p.h.
|
protected |
Definition at line 172 of file qmaintainingreader_p.h.
|
private |
Definition at line 208 of file qmaintainingreader_p.h.
|
private |
Definition at line 221 of file qmaintainingreader_p.h.
|
protected |
Definition at line 174 of file qmaintainingreader_p.h.
|
private |
Definition at line 222 of file qmaintainingreader_p.h.
|
protected |
This stack mirrors the depth of elements in the parsed document. If no xml:space
is present on the current element, MaintainingReader simply pushes the current top(). However, it never sets the value depending on xml:space's
value.
Definition at line 182 of file qmaintainingreader_p.h.