pentaho/pentaho-kettle · error · RuntimeException
Unknown XML event:
Error message
Unknown XML event:
What it means
XMLFormatter.format() walks an XML stream (StaX) and throws this RuntimeException in its default case when it encounters an XML stream event type it does not explicitly handle (only start/end element, characters, etc. are supported).
Solutions
- Inspect the numeric event value in the message and map it to an XMLStreamConstants constant
- Add a case for the missing event type (e.g. XMLStreamConstants.COMMENT) in the switch to ignore or copy it
- Strip comments/processing instructions/doctype from the XML before formatting
- Set the input factory to coalesce/replacement-safe properties (e.g. P_LAZY? coalescing true, replacing entity references) so exotic events are not emitted
- Wrap format() in a try-catch if formatting is best-effort
Example fix
// before default: throw new RuntimeException( "Unknown XML event: " + event ); // after case XMLStreamConstants.PROCESSING_INSTRUCTION: case XMLStreamConstants.COMMENT: case XMLStreamConstants.DTD: break; // skip unhandled events default: throw new RuntimeException( "Unknown XML event: " + event );
Defensive patterns
Strategy: try-catch
Validate before calling
// Detect constructs that map to unhandled events before formatting: boolean risky = xml.contains( "<!DOCTYPE" ) || xml.contains( "<?" ) || xml.contains( "<!--" );
Try / catch
try {
result = XMLFormatter.format( xml );
} catch ( RuntimeException e ) {
if ( e.getMessage().startsWith( "Unknown XML event:" ) ) {
// handle/strip the offending construct and retry, or skip formatting
} else {
throw e;
}
} Prevention
- Strip DOCTYPE/comments/processing instructions before formatting
- Keep the input XML plain (elements + text) when possible
- Pin a known StaX implementation to keep event streams predictable
- Add cases for extra XMLStreamConstants values when extending format()
When it happens
Trigger: Formatting XML whose stream emits unhandled event types, e.g. PROCESSING_INSTRUCTION, DTD, ENTITY_REFERENCE, CDATA variants or COMMENT depending on handled cases.
Common situations: Formatting documents with DOCTYPE declarations, processing instructions (<?xml-stylesheet?>), comments or entity references; different StaX implementations surfacing more event types.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unknown XML event: [event]
- AnalyticQueryMeta.Exception.UnableToLoadStepInfoFromXML
- Error_0001
- ERROR_0001
- Error loading transformation executor details from XML
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/8739ab080c330de4.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/xml/XMLFormatter.java:143
cdata.append( rd.getText() );
wasSomething = true;
break;
case XMLStreamConstants.COMMENT:
if ( !whitespacesOnly( str ) ) {
wr.writeCharacters( str.toString() );
} else if ( wasSomething ) {
wr.writeCharacters( "\n" + prefix );
}
str.setLength( 0 );
wr.writeComment( rd.getText() );
wasSomething = true;
break;
case XMLStreamConstants.END_DOCUMENT:
wr.writeCharacters( "\n" );
wr.writeEndDocument();
break;
default:
throw new RuntimeException( "Unknown XML event: " + event );
}
}
wr.flush();
return result.toString();
} catch ( XMLStreamException ex ) {
throw new RuntimeException( ex );
} finally {
try {
if ( wr != null ) {
wr.close();
}
} catch ( Exception ex ) {
}
try {
if ( rd != null ) {
rd.close();View on GitHub (pinned to f3058517a1)