Hi!
I've installed the new Java 1.5 and found a problem with one of my programs. I tested it and found out, that the problem is the Default Java XML Parser. Here is an example:
import java.io.File;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class Test {
public static void main(String[] args) {
String countryPath = "countries.xml";
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(countryPath));
System.out.println(document.getDocumentElement());
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
If I compile (simple javac Test.java) and run the program with Java 1.5 under Windows XP/SP2 or Linux (SuSE 9.0) I always get null in System.out. If I do the same with Java 1.4 I get the content of the XML file. There is no exception. I tried also an validating enabled Parser with my own ErrorHandler . Its the same.
Has someone an idea, why this happens? I had months ago a similar problem with Java 1.4 and did not find a solution for this strange behavior.... It's very bad to find the error, if there is no message.
The XML file contains the following:
<?xml version="1.0"?>
<countries>
<country>
<de>Deutschland</de>
<en>Germany</en>
</country>
</countries>