Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6573786

No formatting for an parser error messages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 6
    • xml
    • 1.4
    • x86
    • windows_xp
    • Verified

        FULL PRODUCT VERSION :
        java version "1.6.0_01"
        Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
        Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        I'm making localized properties files for XML parser errors.
        There is an error in file :
        com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties

        The property "SDDeclInvalid" is not formatted, so if this error occurs while parsing a document, the exception message is :
        The standalone document declaration value must be \"yes\" or \"no\", not \"{0}\".

        The {0} is not replaced.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

        Just run the following commands :
        javac TestCase.java
        java TestCase

        or
        Just edit an XML document :
        <?xml version="1.0" encoding="UTF-8" standalone="a_value" ?>
        <root />
        Try to parse this file and display the exception message.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expected result should be (for the example) :
        The standalone document declaration value must be "yes" or "no", not
        "bad_value".
        ACTUAL -
        The standalone document declaration value must be "yes" or "no", not "{0}".


        ---------- BEGIN SOURCE ----------

        Here is a test case that show the bug :
        --
        import org.xml.sax.*;
        import org.xml.sax.helpers.*;
        import javax.xml.parsers.SAXParser;
        import javax.xml.parsers.SAXParserFactory;
        import java.io.*;

        public class TestCase extends DefaultHandler {

            public void fatalError (SAXParseException e) throws SAXException {
                System.out.println (e.getMessage ());
            } // fatalError ()

            public void error (SAXParseException e) throws SAXException {
                System.out.println (e.getMessage ());
            } // error ()

            public void warning (SAXParseException e) throws SAXException {
                System.out.println (e.getMessage ());
            } // warning ()

            public static void main (String[] args) {
                try {
                    SAXParser parser = SAXParserFactory.newInstance ().newSAXParser
        ();
                    parser.parse (new InputSource (new FileInputStream
        ("invalid_case.xml")), new TestCase ());
                } catch (Exception e) {}
            } // main ()
        } // TestCase ()
        --

        And the XML file associated :
        --
        <?xml version="1.0" encoding="UTF-8" standalone="bad_value" ?>

        <root />
        --
        ---------- END SOURCE ----------

        REPRODUCIBILITY :
        This bug can be reproduced always.

              joehw Joe Wang
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: