-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
5.0
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
Also fails with 1.5.0_06 and 1.5.0
ADDITIONAL OS VERSION INFORMATION :
Linux unununium 2.4.21-32.EL #1 Fri Apr 15 21:29:19 EDT 2005 i686 i686 i386 GNU/Linux
Tough this problem is not OS specific.
A DESCRIPTION OF THE PROBLEM :
I get an org.xml.sax.SAXParseException with the message "Character reference "" is an invalid XML character." when calling javax.xml.parsers.DocumentBuilder.parse() on a document with an attribute containing the string "". This message is obviously incorrect as this is perfectly valid XML. This problem does not exist in java 1.4.2. Docments created from DocumentBuilder.parse() in java 1.4.2 behave correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the program provided below with 1.5.0* and run it. You will see the error message displayed. Interestingly the xml parser prints a message to the screen in addition to throwing an exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If no errors there is no output. This is verified by compiling and running this program with java 1.4.2_04.
ACTUAL -
The following:
[Fatal Error] :1:17: Character reference "" is an invalid XML character.
Caught exception: org.xml.sax.SAXParseException: Character reference "" is an invalid XML character.
The first of the two lines is printed from the xml parser itself. It would also be good to eliminate screen output in the case of parse errors. Throwing an exception is adequate.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
[Fatal Error] :1:17: Character reference "" is an invalid XML character.
Caught exception: org.xml.sax.SAXParseException: Character reference "" is an invalid XML character.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import org.w3c.dom.*;
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class XMLParse
{
private static String xml = "<foo bar=\"\"/>";
public static final void main( String[] args )
{
try
{
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
Document doc = dfactory.newDocumentBuilder().parse(
new InputSource( new StringReader( xml ) ) );
}
catch( Exception e )
{
System.out.println( "Caught exception: " + e.getClass().getName() + ": " + e.getMessage() );
}
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.2_12
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
In XML 1.0, you cannot include control characters in your document, even if they are escaped. In XML 1.1, you can, if you escape them.
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
Also fails with 1.5.0_06 and 1.5.0
ADDITIONAL OS VERSION INFORMATION :
Linux unununium 2.4.21-32.EL #1 Fri Apr 15 21:29:19 EDT 2005 i686 i686 i386 GNU/Linux
Tough this problem is not OS specific.
A DESCRIPTION OF THE PROBLEM :
I get an org.xml.sax.SAXParseException with the message "Character reference "" is an invalid XML character." when calling javax.xml.parsers.DocumentBuilder.parse() on a document with an attribute containing the string "". This message is obviously incorrect as this is perfectly valid XML. This problem does not exist in java 1.4.2. Docments created from DocumentBuilder.parse() in java 1.4.2 behave correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the program provided below with 1.5.0* and run it. You will see the error message displayed. Interestingly the xml parser prints a message to the screen in addition to throwing an exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If no errors there is no output. This is verified by compiling and running this program with java 1.4.2_04.
ACTUAL -
The following:
[Fatal Error] :1:17: Character reference "" is an invalid XML character.
Caught exception: org.xml.sax.SAXParseException: Character reference "" is an invalid XML character.
The first of the two lines is printed from the xml parser itself. It would also be good to eliminate screen output in the case of parse errors. Throwing an exception is adequate.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
[Fatal Error] :1:17: Character reference "" is an invalid XML character.
Caught exception: org.xml.sax.SAXParseException: Character reference "" is an invalid XML character.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import org.w3c.dom.*;
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class XMLParse
{
private static String xml = "<foo bar=\"\"/>";
public static final void main( String[] args )
{
try
{
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
Document doc = dfactory.newDocumentBuilder().parse(
new InputSource( new StringReader( xml ) ) );
}
catch( Exception e )
{
System.out.println( "Caught exception: " + e.getClass().getName() + ": " + e.getMessage() );
}
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.2_12
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
In XML 1.0, you cannot include control characters in your document, even if they are escaped. In XML 1.1, you can, if you escape them.