QXmlEntityResolver Class
QXmlEntityResolver 类提供了一个用于解析 XML 数据中包含的外部实体的接口。更多内容...
| 头文件: | #include <QXmlEntityResolver> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
| qmake: | QT += core5compat |
| 由以下项目继承: |
注意:该类中的所有函数均为可重入函数。
公共函数
| virtual | ~QXmlEntityResolver() |
| virtual QString | errorString() const = 0 |
| virtual bool | resolveEntity(const QString &publicId, const QString &systemId, QXmlInputSource *&ret) = 0 |
详细说明
如果应用程序需要为外部实体实现自定义处理,则必须实现此接口,即resolveEntity(),并使用QXmlReader::setEntityResolver() 将其注册。
另请参阅 QXmlDTDHandler 、QXmlDeclHandler 、QXmlContentHandler 、QXmlErrorHandler 和QXmlLexicalHandler 。
成员函数文档
[virtual noexcept] QXmlEntityResolver::~QXmlEntityResolver()
销毁实体解析器。
[pure virtual] QString QXmlEntityResolver::errorString() const
如果任一处理函数返回false ,读取器将调用此函数以获取错误字符串。
[pure virtual] bool QXmlEntityResolver::resolveEntity(const QString &publicId, const QString &systemId, QXmlInputSource *&ret)
阅读器在打开任何外部实体(顶级文档实体除外)之前会调用此函数。应用程序可以要求阅读器解析该实体本身(ret 为 0),或者使用一个完全不同的输入源(ret 指向该输入源)。
当阅读器不再需要输入源ret 时,会将其删除,因此您应使用new 将其在堆上分配。
参数publicId 是外部实体的公共标识符,systemId 是外部实体的系统标识符,ret 是该函数的返回值。如果ret 为 0,解析器应自行解析该实体;如果不为零,则它必须指向一个输入源,解析器将改用该输入源。
如果该函数返回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.