FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.21-27.0.4.EL #1 Sat Apr 16 18:43:06 EDT 2005 i686 athlon i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The DTD for the XML files generated by the Properties class is incorrect. As a result, the XML files generated by the Properties.storeToXML() command do not validate.
The DTD, which is stored at http://java.sun.com/dtd/properties.dtd as listed in the XML files generated by the Properties class, contains an invalid line. The line in question reads "<?xml version="1.0" encoding="UTF-8"?>". This line should not be in the DTD. If this line were removed from the DTD, and no other changes made, then the Properties XML files would validate correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To reproduce this bug, generate an XML file using the Properties class. For example, compile and run the following program.
//------------------- proptest.java ---------------------------
import java.util.Properties;
import java.io.*;
public class proptest {
public static void main (String args[]) throws Exception {
Properties p = new Properties();
p.setProperty("prop1", "val1");
p.setProperty("prop2", "val2");
p.setProperty("prop3", "val3");
BufferedOutputStream b = new BufferedOutputStream( new FileOutputStream("properties.xml"));
p.storeToXML(b, "Properties Test");
b.close();
}
} // End proptest.java
//-------------------------------------------------------
This will create a file called properties.xml. Now, go to http://www.stg.brown.edu/service/xmlvalid/ . There is an option to validate a local file, put in the correct path and filename for the properties.xml file you created. It will report that the file http://java.sun.com/dtd/properties.dtd contains an error. You can also download the Sun XML validator from http://www.sun.com/software/xml/developers/multischema/ and use it to validate the XML file. It will also report an error in the properties.dtd
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting the properties.xml document to validate
ACTUAL -
The properties.xml document does not validate because of an error in http://java.sun.com/dtd/properties.dtd.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//------------------- proptest.java ---------------------------
import java.util.Properties;
import java.io.*;
public class proptest {
public static void main (String args[]) throws Exception {
Properties p = new Properties();
p.setProperty("prop1", "val1");
p.setProperty("prop2", "val2");
p.setProperty("prop3", "val3");
BufferedOutputStream b = new BufferedOutputStream( new FileOutputStream("properties.xml"));
p.storeToXML(b, "Properties Test");
b.close();
}
} // End proptest.java
//-------------------------------------------------------
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround.
###@###.### 2005-05-30 11:33:09 GMT
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.21-27.0.4.EL #1 Sat Apr 16 18:43:06 EDT 2005 i686 athlon i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The DTD for the XML files generated by the Properties class is incorrect. As a result, the XML files generated by the Properties.storeToXML() command do not validate.
The DTD, which is stored at http://java.sun.com/dtd/properties.dtd as listed in the XML files generated by the Properties class, contains an invalid line. The line in question reads "<?xml version="1.0" encoding="UTF-8"?>". This line should not be in the DTD. If this line were removed from the DTD, and no other changes made, then the Properties XML files would validate correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To reproduce this bug, generate an XML file using the Properties class. For example, compile and run the following program.
//------------------- proptest.java ---------------------------
import java.util.Properties;
import java.io.*;
public class proptest {
public static void main (String args[]) throws Exception {
Properties p = new Properties();
p.setProperty("prop1", "val1");
p.setProperty("prop2", "val2");
p.setProperty("prop3", "val3");
BufferedOutputStream b = new BufferedOutputStream( new FileOutputStream("properties.xml"));
p.storeToXML(b, "Properties Test");
b.close();
}
} // End proptest.java
//-------------------------------------------------------
This will create a file called properties.xml. Now, go to http://www.stg.brown.edu/service/xmlvalid/ . There is an option to validate a local file, put in the correct path and filename for the properties.xml file you created. It will report that the file http://java.sun.com/dtd/properties.dtd contains an error. You can also download the Sun XML validator from http://www.sun.com/software/xml/developers/multischema/ and use it to validate the XML file. It will also report an error in the properties.dtd
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting the properties.xml document to validate
ACTUAL -
The properties.xml document does not validate because of an error in http://java.sun.com/dtd/properties.dtd.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//------------------- proptest.java ---------------------------
import java.util.Properties;
import java.io.*;
public class proptest {
public static void main (String args[]) throws Exception {
Properties p = new Properties();
p.setProperty("prop1", "val1");
p.setProperty("prop2", "val2");
p.setProperty("prop3", "val3");
BufferedOutputStream b = new BufferedOutputStream( new FileOutputStream("properties.xml"));
p.storeToXML(b, "Properties Test");
b.close();
}
} // End proptest.java
//-------------------------------------------------------
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround.
###@###.### 2005-05-30 11:33:09 GMT