- class QDomImplementation¶
The
QDomImplementation
class provides information about the features of the DOM implementation. More…Synopsis¶
Methods¶
def
__init__()
def
createDocument()
def
hasFeature()
def
isNull()
def
__ne__()
def
__eq__()
Static functions¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
This class describes the features that are supported by the DOM implementation. Currently the XML subset of DOM Level 1 and DOM Level 2 Core are supported.
Normally you will use the function
implementation()
to get the implementation object.You can create a new document type with
createDocumentType()
and a new document withcreateDocument()
.For further information about the Document Object Model see Level 1 and Level 2 Core . For a more general introduction of the DOM implementation see the
QDomDocument
documentation.The QDom classes have a few issues of nonconformance with the XML specifications that cannot be fixed in Qt 4 without breaking backward compatibility. The Qt XML Patterns module and the QXmlStreamReader and QXmlStreamWriter classes have a higher degree of a conformance.
See also
- class InvalidDataPolicy¶
This enum specifies what should be done when a factory function in
QDomDocument
is called with invalid data.Constant
Description
QDomImplementation.AcceptInvalidChars
The data should be stored in the DOM object anyway. In this case the resulting XML document might not be well-formed. This is the default value and QDom’s behavior in Qt < 4.1.
QDomImplementation.DropInvalidChars
The invalid characters should be removed from the data.
QDomImplementation.ReturnNullNode
The factory function should return a null node.
- __init__()¶
Constructs a
QDomImplementation
object.- __init__(implementation)
- Parameters:
implementation –
QDomImplementation
Constructs a copy of
implementation
.- createDocument(nsURI, qName, doctype)¶
- Parameters:
nsURI – str
qName – str
doctype –
QDomDocumentType
- Return type:
Creates a DOM document with the document type
doctype
. This function also adds a root element node with the qualified nameqName
and the namespace URInsURI
.- createDocumentType(qName, publicId, systemId)¶
- Parameters:
qName – str
publicId – str
systemId – str
- Return type:
Creates a document type node for the name
qName
.publicId
specifies the public identifier of the external subset. If you specify an empty string (QString()) as thepublicId
, this means that the document type has no public identifier.systemId
specifies the system identifier of the external subset. If you specify an empty string as thesystemId
, this means that the document type has no system identifier.Since you cannot have a public identifier without a system identifier, the public identifier is set to an empty string if there is no system identifier.
DOM level 2 does not support any other document type declaration features.
The only way you can use a document type that was created this way, is in combination with the
createDocument()
function to create aQDomDocument
with this document type.In the DOM specification, this is the only way to create a non-null document. For historical reasons, Qt also allows to create the document using the default empty constructor. The resulting document is null, but becomes non-null when a factory function, for example
createElement()
, is called. The document also becomes non-null when setContent() is called.See also
- hasFeature(feature, version)¶
- Parameters:
feature – str
version – str
- Return type:
bool
The function returns
true
if QDom implements the requestedversion
of afeature
; otherwise returnsfalse
.The currently supported features and their versions:
Feature
Version
XML
1.0
- static invalidDataPolicy()¶
- Return type:
Returns the invalid data policy, which specifies what should be done when a factory function in
QDomDocument
is passed invalid data.See also
- isNull()¶
- Return type:
bool
Returns
false
if the object was created byimplementation()
; otherwise returnstrue
.- __ne__(other)¶
- Parameters:
other –
QDomImplementation
- Return type:
bool
Returns
true
ifother
and this DOM implementation object were created from different QDomDocuments; otherwise returnsfalse
.- __eq__(other)¶
- Parameters:
other –
QDomImplementation
- Return type:
bool
Returns
true
ifother
and this DOM implementation object were created from the sameQDomDocument
; otherwise returnsfalse
.- static setInvalidDataPolicy(policy)¶
- Parameters:
policy –
InvalidDataPolicy
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
Sets the invalid data policy, which specifies what should be done when a factory function in
QDomDocument
is passed invalid data.The
policy
is set for all instances ofQDomDocument
which already exist and which will be created in the future.def XML_snippet_main(): doc = QDomDocument() impl = QDomImplementation() # This will create the element, but the resulting XML document will # be invalid, because '~' is not a valid character in a tag name. impl.setInvalidDataPolicy(QDomImplementation.AcceptInvalidChars) elt1 = doc.createElement("foo~bar") # This will create an element with the tag name "foobar". impl.setInvalidDataPolicy(QDomImplementation.DropInvalidChars) elt2 = doc.createElement("foo~bar") # This will create a null element. impl.setInvalidDataPolicy(QDomImplementation.ReturnNullNode) elt3 = doc.createElement("foo~bar")
See also