{"record":{"id":"8d5abe0a0939d096","repo":"pentaho/pentaho-kettle","slug":"error-writing-xml-row","errorCode":null,"errorMessage":"Error writing XML row :","messagePattern":"Error writing XML row :","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmloutput/XMLOutput.java","lineNumber":213,"sourceCode":"            ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta( data.fieldnrs[i] );\n            Object valueData = getNullIfValue( r[data.fieldnrs[i]], outputField.getNullString() );\n\n            String elementName = outputField.getElementName();\n            if ( Utils.isEmpty( elementName ) ) {\n              elementName = outputField.getFieldName();\n            }\n\n            if ( !( valueMeta.isNull( valueData ) && meta.isOmitNullValues() ) ) {\n              writeField( valueMeta, valueData, elementName );\n            }\n          }\n        }\n      }\n\n      data.writer.writeEndElement();\n      data.writer.writeCharacters( EOL );\n    } catch ( Exception e ) {\n      throw new KettleException( \"Error writing XML row :\" + e.toString() + Const.CR + \"Row: \"\n          + getInputRowMeta().getString( r ), e );\n    }\n\n    incrementLinesOutput();\n  }\n\n  void writeRowAttributes( Object[] r ) throws KettleValueException, XMLStreamException {\n    for ( int i = 0; i < meta.getOutputFields().length; i++ ) {\n      XMLField xmlField = meta.getOutputFields()[i];\n      if ( xmlField.getContentType() == ContentType.Attribute ) {\n        ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta( data.fieldnrs[i] );\n        Object valueData = r[data.fieldnrs[i]];\n\n        String elementName = xmlField.getElementName();\n        if ( Utils.isEmpty( elementName ) ) {\n          elementName = xmlField.getFieldName();\n        }\n","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmloutput/XMLOutput.java#L195-L231","documentation":"XMLOutput.writeRowToFile wraps any exception raised while writing one XML row (start/end element, characters, encoding) into this KettleException, including the offending row content via getInputRowMeta().getString(r). It indicates an I/O or serialization failure mid-row, typically from the underlying StAX writer or the output stream.","triggerScenarios":"processRow -> writeRowToFile when the writer throws: disk full, file closed/removed, illegal XML characters in field values, encoding conversion errors, or stream closed by a concurrent error.","commonSituations":"Target filesystem full or quota exceeded; field data contains characters invalid in the target encoding; network drive disconnected mid-run.","solutions":["Check disk space and file permissions on the output file","Enable 'Fast dump' vs formatted mode or sanitize field values to valid XML characters","Verify the file encoding setting matches the data (e.g. UTF-8)","Read the wrapped cause e and the printed Row to identify the offending value"],"exampleFix":"// before\nString value = data.valueMeta.getString( valueData );\n// after\nString value = data.valueMeta.getString( valueData ).replaceAll(\"[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]\", \"\");","handlingStrategy":"try-catch","validationCode":"// before run\njava.io.File out = new java.io.File(filename);\nif (out.getParentFile() != null && !out.getParentFile().canWrite()) throw new IllegalStateException(\"Output dir not writable\");\nif (out.getParentFile().getUsableSpace() < minBytes) throw new IllegalStateException(\"Low disk space\");","typeGuard":"boolean writableTarget = new java.io.File(directory).canWrite();","tryCatchPattern":"try { writeRowToFile(row); } catch (KettleStepException|KettleException e) { log.error(\"XML row write failed: \" + e.getCause(), e); }","preventionTips":["Monitor disk space on output directories","Use UTF-8 encoding unless data dictates otherwise","Sanitize control characters from string fields before XML output","Route the offending row to an error handling stream"],"tags":["kettle","xml","io"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}