stanfordnlp/CoreNLP · warning

Warning

Error message

Warning: ${SAXParseException details}

What it means

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.

Solutions

  1. Read the full logged message (makeBetterErrorString includes line/column) and fix the XML at the reported location
  2. Validate the document against its schema/DTD with xmllint before feeding it to Stanford NLP code
  3. If the warning is benign and expected, adjust the SAX ErrorHandler or logging filter to suppress it
  4. Regenerate/export the XML from the producing tool with schema-valid output

Example fix

// before
Tree t = XMLUtils.readTreesFromFile("annotations.xml"); // warns: Warning: ... line 12
// after
// fix line 12 of annotations.xml (e.g., undeclared entity) or pre-validate:
// xmllint --noout --dtdvalid annotations.dtd annotations.xml
Tree t = XMLUtils.readTreesFromFile("annotations_fixed.xml");
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate XML with a strict parser before handing to NLP code
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
dbf.parse(new InputSource(new FileInputStream(xmlFile))); // throws on real problems

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/d4cd1992614a41a0. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/util/XMLUtils.java:1264

      String str = ex.getMessage();
      if (str.lastIndexOf('.') == str.length() - 1) {
        str = str.substring(0, str.length() - 1);
      }
      sb.append(str);
      sb.append(" at document line ").append(ex.getLineNumber());
      sb.append(", column ").append(ex.getColumnNumber());
      if (ex.getSystemId() != null) {
        sb.append(" in entity from systemID ").append(ex.getSystemId());
      } else if (ex.getPublicId() != null) {
        sb.append(" in entity from publicID ").append(ex.getPublicId());
      }
      sb.append('.');
      return sb.toString();
    }

    @Override
    public void warning(SAXParseException exception) {
      log.warn(makeBetterErrorString("Warning", exception));
    }

    @Override
    public void error(SAXParseException exception) {
      log.error(makeBetterErrorString("Error", exception));
    }

    @Override
    public void fatalError(SAXParseException ex) throws SAXParseException {
      throw new SAXParseException(makeBetterErrorString("Fatal Error", ex),
              ex.getPublicId(), ex.getSystemId(), ex.getLineNumber(), ex.getColumnNumber());
      // throw new RuntimeException(makeBetterErrorString("Fatal Error", ex));
    }

  } // end class SAXErrorHandler

  public static Document readDocumentFromString(String s) throws ParserConfigurationException, SAXException {
    InputSource in = new InputSource(new StringReader(s));

View on GitHub (pinned to 1b7edd19c4)