pentaho/pentaho-kettle · error · RuntimeException
Unknown XML event: [event]
Error message
Unknown XML event: [event]
What it means
Identical RuntimeException from XMLFormatter.format()'s default switch case; the recorded message contains the event value already substituted ('[event]'), meaning the formatter hit an XML stream event type it does not know how to render.
Solutions
- Identify the event constant from the message value and handle it explicitly in the switch
- Skip benign events (comment, DTD, processing instruction) instead of throwing
- Pre-process the XML to remove non-content nodes
- Configure the XMLInputFactory to coalesce text and expand entity references
- Catch RuntimeException around format() and fall back to returning the input unformatted
Example fix
// before
String out = XMLFormatter.format( xml );
// after
String out;
try {
out = XMLFormatter.format( xml );
} catch ( RuntimeException e ) {
log.logMinimal( "XML formatting failed, using original: " + e.getMessage() );
out = xml;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Same pre-check as 576 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:" ) ) {
log.logMinimal( "Skipping formatting: " + e.getMessage() );
result = xml;
} else {
throw e;
}
} Prevention
- Remove comments/PIs/DOCTYPE from generated XML before formatting
- Test formatting against documents produced by all upstream emitters
- Handle additional event constants in the switch defensively
- Log the event number to map it to XMLStreamConstants when it occurs
When it happens
Trigger: Same as 576: the StaX cursor returns an event constant not covered by the implemented cases (e.g. COMMENT=5, DTD=11, PROCESSING_INSTRUCTION=3) while formatting.
Common situations: Same as 576: documents with DOCTYPE, comments, processing instructions, or entity references; differences between StaX implementations (Woodstox vs JDK default).
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:
- 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/c705fb5e986ad822.
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)