The XML parser is getting attribute values that are wrong (not what is in the document) under certain circumstances. I've attached an XML file and a simple program that reproduce the problem.
The problem only occurs on Java 1.6 using the SAX parser shipped with it.
The XML file provided must be used without any editing. Removing some "unnecessary" and unrelated tags will result in different (and sometime correct) behavior. Also, switching the XML version number from 1.1 to 1.0 results in correct behavior. Even removing the commented out XML results in the correct behavior. I tried to make the XML file as small as possible, but found if I removed any more content, then the parser behaves correctly.
I was not able to step through the DOM Parser with the debugger to determine where the problem is occurring or why.
I submitted this first to Oracle, but seem to have been ignored (perhaps because they do not support the SAX parser).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample code provided with sample XML file.
You'll see that in the last line, the fill, gridHeight, gridWidth, gridX, gridY, ipadX, and ipadY attributes are wrong.
Note: You may need to change the package name and path to the XML file to match your setup.
EXPECTED VERSUS ACTUAL BEHAVIOR :
(The output will show twice, as I run through the DOM parser (which uses the SAX parser, I believe) and then the SAX parser directly.
EXPECTED -
Node: GridBagConstraints : anchor = 10; fill = 2; gridHeight = 1; gridWidth = 0; gridX = 0; gridY = 8; insetsBottom = 0; insetsLeft = 0; insetsRight = 0; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 18; fill = 2; gridHeight = 1; gridWidth = 0; gridX = 0; gridY = 0; insetsBottom = 0; insetsLeft = 0; insetsRight = 0; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 1.0; weightY = 1.0;
Node: GridBagConstraints : anchor = 13; fill = 0; gridHeight = 1; gridWidth = 1; gridX = 1; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 5; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 17; fill = 0; gridHeight = 1; gridWidth = 1; gridX = 2; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 40; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 13; fill = 0; gridHeight = 1; gridWidth = 1; gridX = 5; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 5; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 17; fill = 0; gridHeight = 1; gridWidth = 0; gridX = 6; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 5; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
ACTUAL -
Node: GridBagConstraints : anchor = 10; fill = 2; gridHeight = 1; gridWidth = 0; gridX = 0; gridY = 8; insetsBottom = 0; insetsLeft = 0; insetsRight = 0; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 18; fill = 2; gridHeight = 1; gridWidth = 0; gridX = 0; gridY = 0; insetsBottom = 0; insetsLeft = 0; insetsRight = 0; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 1.0; weightY = 1.0;
Node: GridBagConstraints : anchor = 13; fill = 0; gridHeight = 1; gridWidth = 1; gridX = 1; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 5; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 17; fill = 0; gridHeight = 1; gridWidth = 1; gridX = 2; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 40; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 13; fill = 0; gridHeight = 1; gridWidth = 1; gridX = 5; gridY = 25; insetsBottom = 0; insetsLeft = 0; insetsRight = 5; insetsTop = 0; ipadX = 0; ipadY = 0; weightX = 0.0; weightY = 0.0;
Node: GridBagConstraints : anchor = 17; fill = B; gridHeight = e; gridWidth = m; gridX = .; gridY = mo; insetsBottom = 0; insetsLeft = 0; insetsRight = 5; insetsTop = 0; ipadX = G; ipadY = s; weightX = 0.0; weightY = 0.0;
REPRODUCIBILITY :
This bug can be reproduced always.
Test code