QXmlNamespaceSupport¶
The
QXmlNamespaceSupport
class is a helper class for XML readers which want to include namespace support. More…
Synopsis¶
Functions¶
def
popContext
()def
prefix
(arg__1)def
prefixes
()def
prefixes
(arg__1)def
processName
(arg__1, arg__2, arg__3, arg__4)def
pushContext
()def
reset
()def
setPrefix
(arg__1, arg__2)def
splitName
(arg__1, arg__2, arg__3)def
uri
(arg__1)
Detailed Description¶
You can set the prefix for the current namespace with
setPrefix()
, and get the list of current prefixes (or those for a given URI) withprefixes()
. The namespace URI is available fromuri()
. UsepushContext()
to start a new namespace context, andpopContext()
to return to the previous namespace context. UsesplitName()
orprocessName()
to split a name into its prefix and local name.
- class PySide2.QtXml.QXmlNamespaceSupport¶
Constructs a
QXmlNamespaceSupport
.
- PySide2.QtXml.QXmlNamespaceSupport.popContext()¶
Reverts to the previous namespace context.
Normally, you should pop the context at the end of each XML element. After popping the context, all namespace prefix mappings that were previously in force are restored.
See also
- PySide2.QtXml.QXmlNamespaceSupport.prefix(arg__1)¶
- Parameters:
arg__1 – str
- Return type:
str
Returns one of the prefixes mapped to the namespace URI
uri
.If more than one prefix is currently mapped to the same URI, this function makes an arbitrary selection; if you want all of the prefixes, use
prefixes()
instead.Note: to check for a default prefix, use the
uri()
function with an argument of “”.See also
- PySide2.QtXml.QXmlNamespaceSupport.prefixes()¶
- Return type:
list of strings
Returns a list of all the prefixes currently declared.
If there is a default prefix, this function does not return it in the list; check for the default prefix using
uri()
with an argument of “”.
- PySide2.QtXml.QXmlNamespaceSupport.prefixes(arg__1)
- Parameters:
arg__1 – str
- Return type:
list of strings
This is an overloaded function.
Returns a list of all prefixes currently declared for the namespace URI
uri
.The “xml:” prefix is included. If you only want one prefix that is 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 list; to check for the presence of a default namespace, call
uri()
with “” as the argument.
- PySide2.QtXml.QXmlNamespaceSupport.processName(arg__1, arg__2, arg__3, arg__4)¶
- Parameters:
arg__1 – str
arg__2 – bool
arg__3 – str
arg__4 – str
Processes a raw XML 1.0 name in the current context by removing the prefix and looking it up among the prefixes currently declared.
qname
is the raw XML 1.0 name to be processed.isAttribute
is true if the name is an attribute name.This function stores the namespace URI in
nsuri
(which will be set to an empty string if the raw name has an undeclared prefix), and stores the local name (without prefix) inlocalname
(which will be set to an empty string if no namespace is in use).Note that attribute names are processed differently than element names: an unprefixed element name gets the default namespace (if any), while an unprefixed attribute name does not.
- PySide2.QtXml.QXmlNamespaceSupport.pushContext()¶
Starts a new namespace context.
Normally, you should push a new context at the beginning of each XML element: the new context automatically inherits the declarations of its parent context, and it also keeps track of which declarations were made within this context.
See also
- PySide2.QtXml.QXmlNamespaceSupport.reset()¶
Resets this namespace support object ready for reuse.
- PySide2.QtXml.QXmlNamespaceSupport.setPrefix(arg__1, arg__2)¶
- Parameters:
arg__1 – str
arg__2 – str
This function declares a prefix
pre
in the current namespace context to be the namespace URIuri
. The prefix remains in force until this context is popped, unless it is shadowed in a descendant context.Note that there is an asymmetry in this library.
prefix()
does not return the default “” prefix, even if you have declared one; to check for a default prefix, you must look it up explicitly usinguri()
. This asymmetry exists to make it easier to look up prefixes for attribute names, where the default prefix is not allowed.See also
- PySide2.QtXml.QXmlNamespaceSupport.splitName(arg__1, arg__2, arg__3)¶
- Parameters:
arg__1 – str
arg__2 – str
arg__3 – str
Splits the name
qname
at the ‘:’ and returns the prefix inprefix
and the local name inlocalname
.See also
- PySide2.QtXml.QXmlNamespaceSupport.uri(arg__1)¶
- Parameters:
arg__1 – str
- Return type:
str
Looks up the prefix
prefix
in the current context and returns the currently-mapped namespace URI. Use the empty string (“”) for the default namespace.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.