{"record":{"id":"effa0df77f8acfa4","repo":"stanfordnlp/CoreNLP","slug":"unexpected-element-child","errorCode":null,"errorMessage":"unexpected element ${child}","messagePattern":"unexpected element (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/GUTimeAnnotator.java","lineNumber":320,"sourceCode":"              }\n              searchStep += 1;\n            }\n            searchStep = 1;\n            Integer tokEnd = endMap.get(charEnd);\n            while(tokEnd == null){\n              tokEnd = endMap.get(charEnd - searchStep);\n              if(tokEnd == null){\n                tokEnd = endMap.get(charEnd + searchStep);\n              }\n              searchStep += 1;\n            }\n            timexMap.set(CoreAnnotations.TokenBeginAnnotation.class, tokBegin);\n            timexMap.set(CoreAnnotations.TokenEndAnnotation.class, tokEnd);\n          }\n          //(add)\n          timexMaps.add(timexMap);\n        } else {\n          throw new RuntimeException(\"unexpected element \" + child);\n        }\n      } else {\n        throw new RuntimeException(\"unexpected content \" + content);\n      }\n    }\n    return timexMaps;\n  }\n\n\n  @Override\n  public Set<Class<? extends CoreAnnotation>> requires() {\n    return Collections.unmodifiableSet(new ArraySet<>(Arrays.asList(\n        CoreAnnotations.TextAnnotation.class,\n        CoreAnnotations.TokensAnnotation.class,\n        CoreAnnotations.CharacterOffsetBeginAnnotation.class,\n        CoreAnnotations.CharacterOffsetEndAnnotation.class,\n        CoreAnnotations.SentencesAnnotation.class\n    )));","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/GUTimeAnnotator.java#L302-L338","documentation":"toTimexCoreMaps walks the children of GUTime's output XML root; Text nodes and TIMEX3 Elements are the only accepted content types. If a child is an Element whose node name is not TIMEX3 (e.g. some other tag GUTime emitted), a RuntimeException naming that element is thrown, since the parser has no rule for it.","triggerScenarios":"GUTime output contains non-TIMEX3 element children inside the document body — caused by a GUTime version emitting a different tag set, or by markup in the input that GUTime passes through wrapped in another element.","commonSituations":"Version drift between the external GUTime tool and CoreNLP's GUTimeAnnotator expectations; annotated HTML input producing wrapper elements in output XML.","solutions":["Inspect the element named in the exception message to learn which tag GUTime emitted","Use the GUTime version matching CoreNLP's expected output schema","Pre-filter the GUTime XML: remove or unwrap unknown elements before parsing","Sanitize input markup so only plain text reaches GUTime","Patch toTimexCoreMaps to handle the extra tag type if it carries timex information"],"exampleFix":"// before\nString text = htmlWithMarkup; // markup flows into GUTime output XML\nnew GUTimeAnnotator().annotate(annotation);\n// after\nString text = Jsoup.parse(htmlWithMarkup).text(); // strip markup first\nnew GUTimeAnnotator().annotate(new Annotation(text));","handlingStrategy":"validation","validationCode":"// Check GUTime output contains only Text/TIMEX3 nodes before conversion\nNodeList children = outputXML.getDocumentElement().getChildNodes();\nfor (int i = 0; i < children.getLength(); i++) {\n  org.w3c.dom.Node n = children.item(i);\n  boolean ok = n.getNodeType() == org.w3c.dom.Node.TEXT_NODE\n      || (n.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE && n.getNodeName().equals(\"TIMEX3\"));\n  if (!ok) throw new IllegalStateException(\"Unsupported GUTime output node: \" + n.getNodeName());\n}","typeGuard":null,"tryCatchPattern":"try {\n  guTimeAnnotator.annotate(annotation);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"unexpected element\")) {\n    logger.warning(\"GUTime emitted unknown element: \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Strip HTML/XML markup from documents before time annotation","Keep GUTime and CoreNLP versions matched to the expected output schema","Preprocess or filter unknown elements out of the GUTime XML"],"tags":["java","nlp","xml","parsing"],"backgroundTag":"unexpected-response-shape","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"}