QXmlDeclHandler Class
QXmlDeclHandler 类提供了一个用于报告 XML 数据声明内容的接口。更多内容...
| 头文件: | #include <QXmlDeclHandler> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
| qmake: | QT += core5compat |
| 由以下接口继承: |
注意:该类中的所有函数均为可重入函数。
公共函数
| virtual | ~QXmlDeclHandler() |
| virtual bool | attributeDecl(const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value) = 0 |
| virtual QString | errorString() const = 0 |
| virtual bool | externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) = 0 |
| virtual bool | internalEntityDecl(const QString &name, const QString &value) = 0 |
详细说明
您可以使用 `QXmlReader::setDeclHandler()` 设置声明处理程序。
该接口基于 SAX2 扩展 DeclHandler。
该接口提供了attributeDecl()、internalEntityDecl() 和externalEntityDecl() 函数。
另请参阅 QXmlDTDHandler 、QXmlContentHandler 、QXmlEntityResolver 、QXmlErrorHandler 和QXmlLexicalHandler 。
成员函数文档
[virtual noexcept] QXmlDeclHandler::~QXmlDeclHandler()
销毁声明处理程序。
[pure virtual] bool QXmlDeclHandler::attributeDecl(const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value)
读取器调用此函数来报告属性类型的声明。仅报告该属性的有效(首个)声明。
解析器将关联元素的名称传递到eName ,将属性的名称传递到aName 。它将表示属性类型的字符串传递到type ,并将表示属性默认值的字符串传递到valueDefault 。 该字符串可以是“#IMPLIED”、“#REQUIRED”、“#FIXED”之一,或者是一个空字符串(如果其他情况均不适用)。解析器会在value 中传递该属性的默认值。如果 XML 文件中未指定默认值,则value 是一个空字符串。
如果该函数返回false ,解析器将停止解析并报告错误。解析器使用函数errorString()来获取错误消息。
[pure virtual] QString QXmlDeclHandler::errorString() const
如果任何处理程序函数返回false ,读取器将调用此函数以获取错误字符串。
[pure virtual] bool QXmlDeclHandler::externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)
解析器调用此函数来报告已解析的外部实体声明。对于每个实体,仅报告有效的(第一个)声明。
解析器将实体的名称传递至 `name`,将公共标识符传递至 `publicId `,并将系统标识符传递至 `systemId`。如果未指定公共标识符,则将空字符串传递至 `publicId`。
如果该函数返回false ,解析器将停止解析并报告错误。解析器使用函数errorString() 获取错误消息。
[pure virtual] bool QXmlDeclHandler::internalEntityDecl(const QString &name, const QString &value)
读取器调用此函数来报告一个内部实体的声明。仅报告有效的(第一个)声明。
解析器将实体的名称传递至name ,并将实体的值传递至value 。
如果该函数返回false ,解析器将停止解析并报告错误。解析器使用函数errorString()来获取错误消息。
© 2026 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.