PySide6.QtCore.QXmlStreamEntityResolver¶
- class QXmlStreamEntityResolver¶
The
QXmlStreamEntityResolverclass provides an entity resolver for aQXmlStreamReader. More…Synopsis¶
Methods¶
def
__init__()
Virtual methods¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Use to inform
QXmlStreamReaderhow to expand entities notdeclared in the internal-set of the DTD.You must take care to avoid resolving entities in cycles, because
QXmlStreamReaderonly detects and rejects cycles inentities defined in the DTD, not in entities expanded from an implementation of theQXmlStreamEntityResolverinterface.This is by design:
QXmlStreamReaderputs the work on the implementation of a concreteQXmlStreamEntityResolver. For static mappings, like XML Entity Definitions for Characters , this is trivially guaranteed, so running some tracking in the background would just slow things down for everyone.Things get interesting when you read entity definitions from external input, including untrusted sources. In this case, your implementation must ensure the expansions it uses as input are cycle-free. This is a simple graph operation that can be implemented in linear time and space and can be performed up front at load time, so it doesn’t affect
resolveUndeclaredEntity()performance.At the moment, entities resolved by this class do not count against
entityExpansionLimit(). This may change in future versions of Qt.For the time being, you need to enforce some upper expansion limit yourself, if you read entity definitions from external input. After cycle detection, longest-path calculation is a simple graph operation that can be implemented in linear time and space and can be performed up front at load time, so it, too, doesn’t affect
resolveUndeclaredEntity()performance.See also
- __init__()¶
- resolveEntity(publicId, systemId)¶
- Parameters:
publicId – str
systemId – str
- Return type:
str
- resolveUndeclaredEntity(name)¶
- Parameters:
name – str
- Return type:
str
Reimplement this function to resolve the undeclared entity
nameand return its replacement text. If the entity is unknown to the entity resolver, return anull string:QString(). This will raise an error in QXmlStreamreader. An empty, but non-null string is considered a valid expansion of the entity, and will not cause an error.The default implementation always returns
QString().