{"record":{"id":"df3fa41ebdc2244b","repo":"stanfordnlp/CoreNLP","slug":"could-not-find-match-name-for-elt","errorCode":null,"errorMessage":"Could not find match name for \" + elt","messagePattern":"Could not find match name for \" \\+ elt","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java","lineNumber":946,"sourceCode":"          return andPred;\n        }\n        break;\n      case SsurgeonPattern.PREDICATE_OR_TAG:\n        SsurgOrPred orPred = new SsurgOrPred();\n        for (Element childElt : getChildElements(elt)) {\n          SsurgPred childPred = assemblePredFromXML(childElt);\n          orPred.add(childPred);\n          return orPred;\n        }\n        break;\n      case SsurgeonPattern.PRED_WORDLIST_TEST_TAG:\n        String id = elt.getAttribute(SsurgeonPattern.PRED_ID_ATTR);\n        String resourceID = elt.getAttribute(\"resourceID\");\n        String typeStr = elt.getAttribute(\"type\");\n        String matchName = getEltText(elt).trim(); // node name to match on\n\n        if (matchName == null) {\n          throw new SsurgeonParseException(\"Could not find match name for \" + elt);\n        }\n        if (id == null) {\n          throw new SsurgeonParseException(\"No ID attribute for element = \" + elt);\n        }\n        return new WordlistTest(id, resourceID, typeStr, matchName);\n    }\n\n    // Not a valid node, error out!\n    throw new SsurgeonParseException(\"Invalid node encountered during Ssurgeon predicate processing, node name=\"+eltName);\n  }\n\n\n\n  /**\n   * Reads in the test file and prints readable to string (for debugging).\n   * Input file consists of semantic graphs, in compact form.\n   */\n  public void testRead(File tgtDirPath) throws Exception {","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java#L928-L964","documentation":"While parsing the <wordlist> test element in ssurgeon XML, the parser reads the match name from the element's text content. Because getEltText returns empty string rather than null for empty elements, the null check is a defensive guard; a truly missing/empty match name produces this SsurgeonParseException indicating the WordlistTest has no node name to match.","triggerScenarios":"An ssurgeon XML <wordlist> element with no text content (empty body) so no node name is available for the WordlistTest.","commonSituations":"Hand-edited or generated ssurgeon XML where the inner text (the semgrex node name) was deleted or the element was written self-closing.","solutions":["Add the match name as the text content of the wordlist element","Ensure the name matches a node captured by the pattern's semgrex query","Read the chained cause to identify the offending element in the XML"],"exampleFix":"// before (empty wordlist element)\n<wordlist id=\"wl1\" type=\"...\" resourceID=\"...\" />\n// after\n<wordlist id=\"wl1\" type=\"...\" resourceID=\"...\">verb</wordlist>","handlingStrategy":"validation","validationCode":"// ensure every wordlist element has text content before parsing\norg.w3c.dom.NodeList wls = doc.getElementsByTagName(\"wordlist\");\nfor (int i = 0; i < wls.getLength(); i++) {\n  String text = wls.item(i).getTextContent();\n  if (text == null || text.trim().isEmpty())\n    throw new IllegalStateException(\"wordlist missing match name\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  List<SsurgeonPattern> pats = ssurgeon.readFromDocument(doc);\n} catch (SsurgeonParseException e) {\n  log.severe(\"WordlistTest parse failed: \" + e.getCause());\n}","preventionTips":["Always give wordlist elements a text body naming a matched node","Self-check generated XML for empty text nodes before loading","Keep node names in wordlist tests aligned with the semgrex pattern captures"],"tags":["java","xml","ssurgeon","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}