QXmlDeclHandler Class
QXmlDeclHandler 类为报告 XML 数据的声明内容提供了一个接口。更多
Header: | #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() 获取错误信息。
© 2025 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.