{"record":{"id":"81bb2a2e8fd26d73","repo":"pentaho/pentaho-kettle","slug":"xpath-statement-returned-no-result","errorCode":null,"errorMessage":"XPath statement returned no result [","messagePattern":"XPath statement returned no result \\[","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmljoin/XMLJoin.java","lineNumber":124,"sourceCode":"      data.outputRowMeta = data.TargetRowSet.getRowMeta().clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(),\n          new RowMetaInterface[] { data.TargetRowSet.getRowMeta() }, null, getTransMeta(), repository, metaStore );\n      data.outputRowData = rTarget.clone();\n\n      // get the target xml structure and create a DOM\n      String strTarget = (String) rTarget[target_field_id];\n      // parse the XML as a W3C Document\n\n      InputSource inputSource = new InputSource( new StringReader( strTarget ) );\n\n      data.XPathStatement = meta.getTargetXPath();\n      try {\n        DocumentBuilder builder = XMLParserFactoryProducer.createSecureDocBuilderFactory().newDocumentBuilder();\n        data.targetDOM = builder.parse( inputSource );\n        if ( !meta.isComplexJoin() ) {\n          data.targetNode = (Node) xpath.evaluate( data.XPathStatement, data.targetDOM, XPathConstants.NODE );\n          if ( data.targetNode == null ) {\n            throw new KettleXMLException( \"XPath statement returned no result [\" + data.XPathStatement + \"]\" );\n          }\n        }\n      } catch ( Exception e ) {\n        throw new KettleXMLException( e );\n      }\n\n    }\n\n    Object[] rJoinSource = getRowFrom( data.SourceRowSet ); // This also waits for a row to be finished.\n    if ( rJoinSource == null ) {\n      // no more input to be expected... create the output row\n      try {\n        if ( meta.isOmitNullValues() ) {\n          removeEmptyNodes( data.targetDOM.getChildNodes() );\n        }\n        // create string from xml tree\n        StringWriter sw = new StringWriter();\n        StreamResult resultXML = new StreamResult( sw );","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmljoin/XMLJoin.java#L106-L142","documentation":"In XMLJoin.processRow(), when not using a complex join, the configured XPath statement is evaluated against the parsed target document with XPathConstants.NODE. If evaluation returns null (no node matches), a KettleXMLException 'XPath statement returned no result [<xpath>]' is thrown. The message includes the XPath statement that failed.","triggerScenarios":"Simple join mode where the XPath statement stored in the step settings matches no node in the target XML document for a given row — wrong path, wrong namespace context, or the target XML lacks the expected element.","commonSituations":"Typo in the XPath expression; XML uses namespaces so element names need a namespace-aware expression; target XML structure changed upstream; XPath references an element that only sometimes exists.","solutions":["Print/inspect the XPath statement in the error message and verify it against the actual target XML structure.","Test the XPath in an evaluator (xmllint --xpath or a browser console) against a sample target document.","Handle namespaces: use local-name() predicates or configure namespace-aware evaluation if the XML is namespaced.","Make the XPath tolerant (e.g. match optional elements) or validate/branch rows where the element is missing before the join.","If the missing node is legitimate for some rows, restructure the transformation to filter or default those rows."],"exampleFix":"// before: XPath assuming an unnamespaced document\n/xsl:stylesheet\n// after: namespace-agnostic XPath\n/*[local-name()='stylesheet']","handlingStrategy":"validation","validationCode":"// Pre-validate the XPath against a sample target document\nNode n = (Node) xpath.evaluate(xpathStmt, sampleTargetDom, XPathConstants.NODE);\nif (n == null) throw new IllegalArgumentException(\"XPath matches nothing: \" + xpathStmt);","typeGuard":null,"tryCatchPattern":"try {\n  xmlJoinStep.processRow();\n} catch (KettleXMLException e) {\n  if (e.getMessage().startsWith(\"XPath statement returned no result\")) {\n    log.error(\"XPath '{}' matched no node; verify structure/namespaces\", e);\n  }\n}","preventionTips":["Test XPaths against real sample XML before configuring the step.","Use local-name() predicates for namespaced XML.","Keep target XML structure stable or update the XPath when upstream changes.","Handle optional elements with a default/fallback branch upstream."],"tags":["kettle","xmljoin","xpath"],"backgroundTag":"empty-result-set","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"}