Qt 4.8
Public Types | Public Functions | Static Public Functions | Private Functions | Properties | Friends | List of all members
QDomImplementation Class Reference

The QDomImplementation class provides information about the features of the DOM implementation. More...

#include <qdom.h>

Public Types

enum  InvalidDataPolicy { AcceptInvalidChars = 0, DropInvalidChars, ReturnNullNode }
 This enum specifies what should be done when a factory function in QDomDocument is called with invalid data. More...
 

Public Functions

QDomDocument createDocument (const QString &nsURI, const QString &qName, const QDomDocumentType &doctype)
 Creates a DOM document with the document type doctype. More...
 
QDomDocumentType createDocumentType (const QString &qName, const QString &publicId, const QString &systemId)
 Creates a document type node for the name qName. More...
 
bool hasFeature (const QString &feature, const QString &version) const
 The function returns true if QDom implements the requested version of a feature; otherwise returns false. More...
 
bool isNull ()
 Returns false if the object was created by QDomDocument::implementation(); otherwise returns true. More...
 
bool operator!= (const QDomImplementation &) const
 Returns true if x and this DOM implementation object were created from different QDomDocuments; otherwise returns false. More...
 
QDomImplementationoperator= (const QDomImplementation &)
 Assigns x to this DOM implementation. More...
 
bool operator== (const QDomImplementation &) const
 Returns true if x and this DOM implementation object were created from the same QDomDocument; otherwise returns false. More...
 
 QDomImplementation ()
 Constructs a QDomImplementation object. More...
 
 QDomImplementation (const QDomImplementation &)
 Constructs a copy of x. More...
 
 ~QDomImplementation ()
 Destroys the object and frees its resources. More...
 

Static Public Functions

static InvalidDataPolicy invalidDataPolicy ()
 Returns the invalid data policy, which specifies what should be done when a factory function in QDomDocument is passed invalid data. More...
 
static void setInvalidDataPolicy (InvalidDataPolicy policy)
 Sets the invalid data policy, which specifies what should be done when a factory function in QDomDocument is passed invalid data. More...
 

Private Functions

 QDomImplementation (QDomImplementationPrivate *)
 

Properties

QDomImplementationPrivateimpl
 

Friends

class QDomDocument
 

Detailed Description

The QDomImplementation class provides information about the features of the DOM implementation.

Note
This class or function is reentrant.
Attention
Module: QtXml

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 QDomDocument::implementation() to get the implementation object.

You can create a new document type with createDocumentType() and a new document with createDocument().

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 QtXmlPatterns module and the QXmlStreamReader and QXmlStreamWriter classes have a higher degree of a conformance.

See also
hasFeature()

Definition at line 99 of file qdom.h.

Enumerations

◆ InvalidDataPolicy

This enum specifies what should be done when a factory function in QDomDocument is called with invalid data.

  • 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.
  • DropInvalidChars The invalid characters should be removed from the data.
  • ReturnNullNode The factory function should return a null node.
See also
setInvalidDataPolicy() invalidDataPolicy()
Enumerator
AcceptInvalidChars 
DropInvalidChars 
ReturnNullNode 

Definition at line 114 of file qdom.h.

Constructors and Destructors

◆ QDomImplementation() [1/3]

QDomImplementation::QDomImplementation ( )

Constructs a QDomImplementation object.

Definition at line 922 of file qdom.cpp.

923 {
924  impl = 0;
925 }
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ QDomImplementation() [2/3]

QDomImplementation::QDomImplementation ( const QDomImplementation x)

Constructs a copy of x.

Definition at line 930 of file qdom.cpp.

931 {
932  impl = x.impl;
933  if (impl)
934  impl->ref.ref();
935 }
bool ref()
Atomically increments the value of this QAtomicInt.
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ ~QDomImplementation()

QDomImplementation::~QDomImplementation ( )

Destroys the object and frees its resources.

Definition at line 979 of file qdom.cpp.

980 {
981  if (impl && !impl->ref.deref())
982  delete impl;
983 }
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ QDomImplementation() [3/3]

QDomImplementation::QDomImplementation ( QDomImplementationPrivate p)
private

Definition at line 937 of file qdom.cpp.

938 {
939  // We want to be co-owners, so increase the reference count
940  impl = p;
941  if (impl)
942  impl->ref.ref();
943 }
bool ref()
Atomically increments the value of this QAtomicInt.
QDomImplementationPrivate * impl
Definition: qdom.h:122

Functions

◆ createDocument()

QDomDocument QDomImplementation::createDocument ( const QString nsURI,
const QString qName,
const QDomDocumentType doctype 
)

Creates a DOM document with the document type doctype.

This function also adds a root element node with the qualified name qName and the namespace URI nsURI.

Definition at line 1071 of file qdom.cpp.

1072 {
1073  QDomDocument doc(doctype);
1074  QDomElement root = doc.createElementNS(nsURI, qName);
1075  if (root.isNull())
1076  return QDomDocument();
1077  doc.appendChild(root);
1078  return doc;
1079 }
The QDomDocument class represents an XML document.
Definition: qdom.h:308
bool isNull() const
Returns true if this node is null (i.e.
Definition: qdom.cpp:2679
The QDomElement class represents one element in the DOM tree.
Definition: qdom.h:476
friend class QDomDocument
Definition: qdom.h:125

◆ createDocumentType()

QDomDocumentType QDomImplementation::createDocumentType ( const QString qName,
const QString publicId,
const QString systemId 
)

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 the publicId, 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 the systemId, 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 a QDomDocument 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 QDomDocument::createElement(), is called. The document also becomes non-null when setContent() is called.

See also
createDocument()

Definition at line 1038 of file qdom.cpp.

1039 {
1040  bool ok;
1041  QString fixedName = fixedXmlName(qName, &ok, true);
1042  if (!ok)
1043  return QDomDocumentType();
1044 
1045  QString fixedPublicId = fixedPubidLiteral(publicId, &ok);
1046  if (!ok)
1047  return QDomDocumentType();
1048 
1049  QString fixedSystemId = fixedSystemLiteral(systemId, &ok);
1050  if (!ok)
1051  return QDomDocumentType();
1052 
1054  dt->name = fixedName;
1055  if (systemId.isNull()) {
1056  dt->publicId.clear();
1057  dt->systemId.clear();
1058  } else {
1059  dt->publicId = fixedPublicId;
1060  dt->systemId = fixedSystemId;
1061  }
1062  dt->ref.deref();
1063  return QDomDocumentType(dt);
1064 }
QString name
Definition: qdom.cpp:198
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QDomDocumentType class is the representation of the DTD in the document tree. ...
Definition: qdom.h:282
QAtomicInt ref
Definition: qdom.cpp:191
static QString fixedSystemLiteral(const QString &data, bool *ok)
Definition: qdom.cpp:843
bool deref()
Atomically decrements the value of this QAtomicInt.
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
static QString fixedXmlName(const QString &_name, bool *ok, bool namespaces=false)
Definition: qdom.cpp:645
static QString fixedPubidLiteral(const QString &data, bool *ok)
Definition: qdom.cpp:810

◆ hasFeature()

bool QDomImplementation::hasFeature ( const QString feature,
const QString version 
) const

The function returns true if QDom implements the requested version of a feature; otherwise returns false.

The currently supported features and their versions:

Feature Version
XML 1.0

Definition at line 995 of file qdom.cpp.

Referenced by QDomNode::isSupported().

996 {
997  if (feature == QLatin1String("XML")) {
998  if (version.isEmpty() || version == QLatin1String("1.0")) {
999  return true;
1000  }
1001  }
1002  // ### add DOM level 2 features
1003  return false;
1004 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704

◆ invalidDataPolicy()

QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy ( )
static

Returns the invalid data policy, which specifies what should be done when a factory function in QDomDocument is passed invalid data.

Since
4.1
Note
This class or function is not reentrant.
See also
setInvalidDataPolicy() InvalidDataPolicy

Definition at line 1137 of file qdom.cpp.

1138 {
1140 }
static QDomImplementation::InvalidDataPolicy invalidDataPolicy
Definition: qdom.cpp:132

◆ isNull()

bool QDomImplementation::isNull ( )

Returns false if the object was created by QDomDocument::implementation(); otherwise returns true.

Definition at line 1085 of file qdom.cpp.

1086 {
1087  return (impl == 0);
1088 }
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ operator!=()

bool QDomImplementation::operator!= ( const QDomImplementation x) const

Returns true if x and this DOM implementation object were created from different QDomDocuments; otherwise returns false.

Definition at line 971 of file qdom.cpp.

972 {
973  return (impl != x.impl);
974 }
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ operator=()

QDomImplementation & QDomImplementation::operator= ( const QDomImplementation x)

Assigns x to this DOM implementation.

Definition at line 948 of file qdom.cpp.

949 {
950  if (x.impl)
951  x.impl->ref.ref();
952  if (impl && !impl->ref.deref())
953  delete impl;
954  impl = x.impl;
955  return *this;
956 }
bool ref()
Atomically increments the value of this QAtomicInt.
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ operator==()

bool QDomImplementation::operator== ( const QDomImplementation x) const

Returns true if x and this DOM implementation object were created from the same QDomDocument; otherwise returns false.

Definition at line 962 of file qdom.cpp.

963 {
964  return (impl == x.impl);
965 }
QDomImplementationPrivate * impl
Definition: qdom.h:122

◆ setInvalidDataPolicy()

void QDomImplementation::setInvalidDataPolicy ( InvalidDataPolicy  policy)
static

Sets the invalid data policy, which specifies what should be done when a factory function in QDomDocument is passed invalid data.

Since
4.1
Note
This class or function is not reentrant.

The policy is set for all instances of QDomDocument which already exist and which will be created in the future.

// 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::AcceptInvalidData);
QDomElement elt1 = doc.createElement("foo~bar");
// This will create an element with the tag name "foobar".
impl.setInvalidDataPolicy(QDomImplementation::DropInvalidData);
QDomElement elt2 = doc.createElement("foo~bar");
// This will create a null element.
QDomElement elt3 = doc.createElement("foo~bar");
See also
invalidDataPolicy() InvalidDataPolicy

Definition at line 1160 of file qdom.cpp.

1161 {
1163 }
static QDomImplementation::InvalidDataPolicy invalidDataPolicy
Definition: qdom.cpp:132

Friends and Related Functions

◆ QDomDocument

friend class QDomDocument
friend

Definition at line 125 of file qdom.h.

Properties

◆ impl

QDomImplementationPrivate* QDomImplementation::impl
private

Definition at line 122 of file qdom.h.

Referenced by operator!=(), operator=(), operator==(), and QDomImplementation().


The documentation for this class was generated from the following files: