Details
Description
I am currently working on a XML file parse problem when doing migration our system from jdk1.3.1 to jdk1.4.2.
The scenario is
1. Turn off the namespace aware feature of the DOM parser
2. Try to parse a XML file with name space.
I use two environments to do the testing. One is jdk1.3.1+xalan.jar+xerces.jar, the other one is jdk1.4.2+xerces.jar. The xalan version is 1.0, the xerces version is 1.0. The expected result is the parser just ignores the name space and parses the XML file properly.
I created a program to demonstrate the defect, basically the program does the following:
· Read a sample xml file in (with Namespace information).
· Create a DOM parser
· Set the namespace feature as false, parse the file
· Get the ("Header") node using XPath
· Write the value of the Header note out to the console.
A) Test using jdk131_08 and our current xalan.jar and xerces.jar.
The results were the following
1) Compile the file successfully using the following command:
C:\ jdk131_08\bin\javac -classpath .;C:\temp\lib\xalan.jar;C:\temp\lib\xerces.jar DomParsing.java
2) Run the program using the following script:
setlocal
set cp=%cp%;/temp/lib/xerces.jar
set cp=%cp%;/temp/lib/xalan.jar
C:\ jdk131_08\bin\java -cp %cp% xml.DomParsing
endlocal
3) Output result is (using this system out statement: System.out.println("header [" + header + "]"):
header [[test:Header: null]]
The test is successful as the Header node in this case is not null (The null shown here is the node value, Header does not have a value)
B) Test using jdk142_05 and our current xerces.jar.
1) Compile the file successfully using the following command:
C:\ jdk142_05 \bin\javac -classpath .;C:\temp\lib\xerces.jar DomParsing.java
2) Run the program using the following script:
setlocal
set cp=%cp%;/temp/lib/xerces.jar
C:\jdk142_05\bin\java -cp %cp% xml.DomParsing
endlocal
3) Output result is (using this system out statement: System.out.println("header [" + header + "]"):
header [null]
The test is a failure as the Header node in this case is null.
The actual result seems the DOM parser just doesn't recognize the name space feature has been set to false.