The QXmlNamespaceSupport class is a helper class for XML readers which want to include namespace support. More...
#include <qxml.h>
Public Member Functions | |
QXmlNamespaceSupport () | |
~QXmlNamespaceSupport () | |
void | setPrefix (const QString &, const QString &) |
QString | prefix (const QString &) const |
QString | uri (const QString &) const |
void | splitName (const QString &, QString &, QString &) const |
void | processName (const QString &, bool, QString &, QString &) const |
QStringList | prefixes () const |
QStringList | prefixes (const QString &) const |
void | pushContext () |
void | popContext () |
void | reset () |
Private Attributes | |
QValueStack< QMap< QString, QString > > | nsStack |
QMap< QString, QString > | ns |
The QXmlNamespaceSupport class is a helper class for XML readers which want to include namespace support.
XML
It provides some functions that makes it easy to handle namespaces. Its main use is for subclasses of QXmlReader which want to provide namespace support.
See also the namespace description.
QXmlNamespaceSupport::QXmlNamespaceSupport | ( | ) |
Constructs a QXmlNamespaceSupport.
QXmlNamespaceSupport::~QXmlNamespaceSupport | ( | ) |
void QXmlNamespaceSupport::popContext | ( | ) |
Returns one of the prefixes mapped to a namespace URI.
If more than one prefix is currently mapped to the same URI, this function will make an arbitrary selection; if you want all of the prefixes, use the prefixes() function instead.
Note: this will never return the empty (default) prefix; to check for a default prefix, use the uri() function with an argument of "".
Definition at line 363 of file qxml.cpp.
QStringList QXmlNamespaceSupport::prefixes | ( | ) | const |
Returns an enumeration of all prefixes currently declared.
Note: if there is a default prefix, it will not be returned in this enumeration; check for the default prefix using uri() with an argument of "".
Definition at line 453 of file qxml.cpp.
QStringList QXmlNamespaceSupport::prefixes | ( | const QString & | uri | ) | const |
Returns a list of all prefixes currently declared for a URI.
The xml: prefix will be included. If you want only one prefix that's mapped to the namespace URI, and you don't care which one you get, use the prefix() function instead.
Note: the empty (default) prefix is never included in this enumeration; to check for the presence of a default namespace, use uri() with an argument of "".
Definition at line 477 of file qxml.cpp.
void QXmlNamespaceSupport::processName | ( | const QString & | qname, |
bool | isAttribute, | ||
QString & | nsuri, | ||
QString & | localname | ||
) | const |
Processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among the prefixes currently declared.
First parameter is the raw XML 1.0 name to be processed. The second parameter is a flag wheter the name is the name of an attribute (TRUE) or not (FALSE).
The return values will be stored in the last two parameters as follows:
If the raw name has a prefix that has not been declared, then the return value will be empty.
Note that attribute names are processed differently than element names: an unprefixed element name will received the default namespace (if any), while an unprefixed element name will not
Definition at line 421 of file qxml.cpp.
void QXmlNamespaceSupport::pushContext | ( | ) |
Starts a new namespace context.
Normally, you should push a new context at the beginning of each XML element: the new context will automatically inherit the declarations of its parent context, but it will also keep track of which declarations were made within this context.
Definition at line 498 of file qxml.cpp.
void QXmlNamespaceSupport::reset | ( | ) |
This function declares a prefix in the current namespace context; the prefix will remain in force until this context is popped, unless it is shadowed in a descendant context.
Note that there is an asymmetry in this library: while prefix() will not return the default "" prefix, even if you have declared one; to check for a default prefix, you have to look it up explicitly using uri(). This asymmetry exists to make it easier to look up prefixes for attribute names, where the default prefix is not allowed.
Definition at line 344 of file qxml.cpp.
void QXmlNamespaceSupport::splitName | ( | const QString & | qname, |
QString & | prefix, | ||
QString & | localname | ||
) | const |
Looks up a prefix in the current context and returns the currently-mapped namespace URI. Use the empty string ("") for the default namespace.
Definition at line 378 of file qxml.cpp.
|
private |