{"record":{"id":"d4cd1992614a41a0","repo":"stanfordnlp/CoreNLP","slug":"warning-saxparseexception-details","errorCode":null,"errorMessage":"Warning: ${SAXParseException details}","messagePattern":"Warning: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/util/XMLUtils.java","lineNumber":1264,"sourceCode":"      String str = ex.getMessage();\n      if (str.lastIndexOf('.') == str.length() - 1) {\n        str = str.substring(0, str.length() - 1);\n      }\n      sb.append(str);\n      sb.append(\" at document line \").append(ex.getLineNumber());\n      sb.append(\", column \").append(ex.getColumnNumber());\n      if (ex.getSystemId() != null) {\n        sb.append(\" in entity from systemID \").append(ex.getSystemId());\n      } else if (ex.getPublicId() != null) {\n        sb.append(\" in entity from publicID \").append(ex.getPublicId());\n      }\n      sb.append('.');\n      return sb.toString();\n    }\n\n    @Override\n    public void warning(SAXParseException exception) {\n      log.warn(makeBetterErrorString(\"Warning\", exception));\n    }\n\n    @Override\n    public void error(SAXParseException exception) {\n      log.error(makeBetterErrorString(\"Error\", exception));\n    }\n\n    @Override\n    public void fatalError(SAXParseException ex) throws SAXParseException {\n      throw new SAXParseException(makeBetterErrorString(\"Fatal Error\", ex),\n              ex.getPublicId(), ex.getSystemId(), ex.getLineNumber(), ex.getColumnNumber());\n      // throw new RuntimeException(makeBetterErrorString(\"Fatal Error\", ex));\n    }\n\n  } // end class SAXErrorHandler\n\n  public static Document readDocumentFromString(String s) throws ParserConfigurationException, SAXException {\n    InputSource in = new InputSource(new StringReader(s));","sourceCodeStart":1246,"sourceCodeEnd":1282,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/XMLUtils.java#L1246-L1282","documentation":"This is the SAX ErrorHandler warning callback used by XMLUtils when parsing XML. A non-fatal SAXParseException (e.g., recoverable validation issue) is reported via log.warn with a formatted \"Warning: <detail> at line X, column Y\" string. Parsing continues; the message is diagnostic, not thrown.","triggerScenarios":"Parsing an XML document (e.g., via XMLUtils's builder/reader helpers) where the SAX parser emits a recoverable warning: minor DTD/schema discrepancies, missing optional declarations, entity issues, or non-fatal document-order problems.","commonSituations":"XML files written by other tools with slightly non-standard constructs; documents referencing DTDs that resolve imperfectly; mixed versions of parser (Xerces) emitting new warnings.","solutions":["Read the full logged message (makeBetterErrorString includes line/column) and fix the XML at the reported location","Validate the document against its schema/DTD with xmllint before feeding it to Stanford NLP code","If the warning is benign and expected, adjust the SAX ErrorHandler or logging filter to suppress it","Regenerate/export the XML from the producing tool with schema-valid output"],"exampleFix":"// before\nTree t = XMLUtils.readTreesFromFile(\"annotations.xml\"); // warns: Warning: ... line 12\n// after\n// fix line 12 of annotations.xml (e.g., undeclared entity) or pre-validate:\n// xmllint --noout --dtdvalid annotations.dtd annotations.xml\nTree t = XMLUtils.readTreesFromFile(\"annotations_fixed.xml\");","handlingStrategy":"validation","validationCode":"// Pre-validate XML with a strict parser before handing to NLP code\nDocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\ndbf.setValidating(true);\ndbf.parse(new InputSource(new FileInputStream(xmlFile))); // throws on real problems","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run xmllint or a strict parser over XML files before NLP processing","Fix warnings at the reported line/column rather than ignoring them","Keep the SAX parser (e.g., Xerces) version consistent with the document features used","Set a custom ErrorHandler in your own code if you want warnings escalated or silenced deliberately"],"tags":["xml","sax","parser-warning"],"backgroundTag":"schema-validation-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}