jaxp
  1. jaxp
  2. JAXP-22

Poor error message during a parsing error

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      22

      Description

      When the JAXP RI tries to read a malformed XML like <foo a="1"b="2"/> (note no
      whitespace between two attributes), it dies with an error message like this:

      --------------------------
      [java] 11:25:05,380 ERROR MetaData:117 - Parser error with file
      "/Users/clr/jpaperf/projects/persistence_benchmark/build/classes/ package.jdo"
      has cause
      [java] Error parsing file
      /Users/clr/jpaperf/projects/persistence_benchmark/build/classes/package.jdo :
      Error reading the Meta-Data input "Element type "field" must be followed by
      either attribute specifications, ">" or "/>".
      [java] org.xml.sax.SAXParseException: Element type "field" must be
      followed by either attribute specifications, ">" or "/>".
      [java] at
      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
      [java] at
      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
      [java] at
      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
      [java] at
      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
      [java] at
      com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError
      (XMLScanner.java:1438)
      [java] at
      com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:218)
      [java] at
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
      [java] at
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
      [java] at
      com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
      [java] at
      com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      [java] at
      com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
      [java] at
      com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
      [java] at javax.xml.parsers.SAXParser.parse(SAXParser.java: 375)
      [java] at javax.xml.parsers.SAXParser.parse(SAXParser.java: 176)
      [java] at
      org.jpox.metadata.MetaDataParser.parseMetaDataStream(MetaDataParser.java:236)
      [java] at org.jpox.metadata.MetaDataParser.parseMetaDataFile
      MetaDataParser.java:162)
      --------------------------

      The only legal characters after an element name or an attribute are whitespaces,
      '/', or '>'. So the error diagnosis should be:

      if(the next character is valid char to start a name)

      { error "whitespace required"; }

      else

      { error "invalid character"; }

      I don't think most people are familiar with what "element type" or "attribute
      specifications" mean — I'm not even sure what they really mean; are they
      technical terms defined in XML REC?

      Besides, those terms could make the user think that the error is validation
      related, which is not.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            jaxp-issues
            Reporter:
            kohsuke
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: