QDomImplementation class provides information about the features of the DOM implementation. 更多...
头: | #include <QDomImplementation> |
qmake: | QT += xml |
注意: 此类的所有函数 可重入 除以下外:
enum | InvalidDataPolicy { AcceptInvalidChars, DropInvalidChars, ReturnNullNode } |
QDomImplementation () | |
QDomImplementation (const QDomImplementation & x ) | |
~QDomImplementation () | |
QDomDocument | createDocument (const QString & nsURI , const QString & qName , const QDomDocumentType & doctype ) |
QDomDocumentType | createDocumentType (const QString & qName , const QString & publicId , const QString & systemId ) |
bool | hasFeature (const QString & feature , const QString & version ) const |
bool | isNull () |
bool | operator!= (const QDomImplementation & x ) const |
QDomImplementation & | operator= (const QDomImplementation & x ) |
bool | operator== (const QDomImplementation & x ) const |
InvalidDataPolicy | invalidDataPolicy () |
void | setInvalidDataPolicy (InvalidDataPolicy policy ) |
QDomImplementation class provides information about the features of the DOM implementation.
此类描述由 DOM 实现所支持的特征。目前支持 DOM 级别 1 和 DOM 级别 2 核心 XML 子集。
通常,使用函数 QDomDocument::implementation () 能获取实现对象。
可以创建新的文档类型采用 createDocumentType () 和新的文档采用 createDocument ().
有关文档对象模型的进一步信息,见 级别 1 and 级别 2 核心 。有关 DOM 实现的更一般介绍,见 QDomDocument 文档编制。
QDom 类有一些不符合 XML 规范的问题,Qt 4 无法在不破坏向后兼容性的情况下修复这些问题。Qt XML 模式模块和 QXmlStreamReader and QXmlStreamWriter 类拥有更高一致性。
另请参阅 hasFeature ().
此枚举指定应做什么,当工厂函数在 QDomDocument 被调用采用无效数据。
常量 | 值 | 描述 |
---|---|---|
QDomImplementation::AcceptInvalidChars
|
0
|
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
|
1
|
应从数据中移除无效字符。 |
QDomImplementation::ReturnNullNode
|
2
|
工厂函数应返回 null 节点。 |
另请参阅 setInvalidDataPolicy () 和 invalidDataPolicy ().
构造 QDomImplementation 对象。
构造副本为 x .
销毁对象并释放其资源。
创建的 DOM (文档对象模型) 文档具有文档类型 doctype . This function also adds a root element node with the qualified name qName 和名称空间 URI nsURI .
创建文档类型节点为名称 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.
另请参阅 createDocument ().
函数返回
true
if QDom implements the requested
version
of a
feature
;否则返回
false
.
目前支持的特征及其版本:
特征 | 版本 |
---|---|
XML | 1.0 |
[static]
InvalidDataPolicy
QDomImplementation::
invalidDataPolicy
()
Returns the invalid data policy, which specifies what should be done when a factory function in QDomDocument is passed invalid data.
警告: 此函数不 可重入 .
该函数在 Qt 4.1 引入。
另请参阅 setInvalidDataPolicy () 和 InvalidDataPolicy .
返回
false
如果对象被创建由
QDomDocument::implementation
();否则返回
true
.
[static]
void
QDomImplementation::
setInvalidDataPolicy
(
InvalidDataPolicy
policy
)
Sets the invalid data policy, which specifies what should be done when a factory function in QDomDocument is passed invalid data.
policy is set for all instances of QDomDocument which already exist and which will be created in the future.
QDomDocument doc; QDomImplementation impl; // 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. impl.setInvalidDataPolicy(QDomImplementation::ReturnNullNode); QDomElement elt3 = doc.createElement("foo~bar");
警告: 此函数不 可重入 .
该函数在 Qt 4.1 引入。
另请参阅 invalidDataPolicy () 和 InvalidDataPolicy .
返回
true
if
x
and this DOM implementation object were created from different QDomDocuments; otherwise returns
false
.
赋值 x 到此 DOM (文档对象模型) 实现。
返回
true
if
x
and this DOM implementation object were created from the same
QDomDocument
;否则返回
false
.