Skip to content

PythonQt.Qt.QXmlName

QXmlName

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

The name of an XML node has three components: The namespace URI, the local name, and the prefix. To see what these refer to in XML, consider the following snippet.

<book xmlns:dc='http://purl.org/dc/elements/1.1'
      xmlns='http://example.com/MyDefault'>
    <dc:title>Mobey Dick</dc:title> ...
</book>

For the element named book, localName() returns book, namespaceUri() returns http://example.com/MyDefault, and prefix() returns an empty string. For the element named title, localName() returns title, namespaceUri() returns http://purl.org/dc/elements/1.1, and prefix() returns dc.

To ensure that operations with QXmlName are efficient, e.g., copying names and comparing them, each instance of QXmlName is associated with a name pool, which must be specified at QXmlName construction time. The three components of the QXmlName, i.e., the namespace URI, the local name, and the prefix, are stored in the name pool mapped to identifiers so they can be shared. For this reason, the only way to create a valid instance of QXmlName is to use the class constructor, where the name pool, local name, namespace URI, and prefix must all be specified.

Note that QXmlName's default constructor constructs a null instance. It is typically used for allocating unused entries in collections of QXmlName.

A side effect of associating each instance of QXmlName with a name pool is that each instance of QXmlName is tied to the QXmlNamePool with which it was created. However, the QXmlName class does not keep track of the name pool, so all the accessor functions, e.g., namespaceUri(), prefix(), localName(), and toClarkName() require that the correct name pool be passed to them. Failure to provide the correct name pool to these accessor functions results in undefined behavior.

Note that a name pool is not an XML namespace. One name pool can represent instances of QXmlName from different XML namespaces, and the instances of QXmlName from one XML namespace can be distributed over multiple name pools.

Comparing QXmlNames

To determine what a QXmlName refers to, the namespace URI and the local name are used. The prefix is not used because the prefix is simply a shorthand name for use in place of the normally much longer namespace URI. Nor is the prefix used in name comparisons. For example, the following two element nodes represent the same element and compare equal.

<svg xmlns="http://www.w3.org/2000/svg"/>
<x:svg xmlns:x="http://www.w3.org/2000/svg"/>

Although the second name has the prefix x, the two names compare equal as instances of QXmlName, because the prefix is not used in the comparison.

A local name can never be an empty string, although the prefix and namespace URI can. If the prefix is not empty, the namespace URI cannot be empty. Local names and prefixes must be valid NCNames, e.g., abc.def or abc123.

QXmlName represents what is sometimes called an expanded QName, or simply a QName.

Source: https://doc.qt.io/archives/qt-5.15/qxmlname.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
fromClarkName function (self, clarkName: str, namePool: Any) -> Any X.fromClarkName(clarkName, namePool) -> PythonQt.QtXmlPatterns.QXmlName (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isNCName function (self, candidate: str) -> bool X.isNCName(candidate) -> bool (shared captured text)
isNull function (self) -> bool X.isNull() -> bool (shared captured text)
localName function (self, query: Any) -> str X.localName(query) -> str (shared captured text)
namespaceUri function (self, query: Any) -> str X.namespaceUri(query) -> str (shared captured text)
prefix function (self, query: Any) -> str X.prefix(query) -> str (shared captured text)
toClarkName function (self, query: Any) -> str X.toClarkName(query) -> str (shared captured text)