XML Parser Recovery Behavior After Well-Formedness Errors Lacks Standardization
0 reputation · 26 Jul 2024, 20:03 UTC
0 reputation · 26 Jul 2024, 20:03 UTC
The XML 1.0 specification (Fifth Edition, Section 2.1) mandates that a well-formedness error is fatal and the processor must not continue normal processing. Despite this requirement, widely used parsers including Xerces, libxml2, and MSXML provide non-standard recovery modes that attempt to continue parsing after such errors.
Applications that need to process potentially malformed XML from external sources often enable these recovery flags (for example, Xerces continueAfterFatalError or libxml2 XML_PARSE_RECOVER) to avoid complete parse failure. However, the resulting document trees, error reporting, and heuristic decisions differ significantly between implementations, and no standard API or configuration exists to control recovery behavior.
This implementation-defined variance creates portability risk when switching parsers or upgrading parser versions, and recovery modes may produce trees that do not correspond to any well-formed XML document, potentially violating downstream validation or business logic.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.