Hi,
I found a serious bug in either org.w3c.dom.Document or Apache (all
versions)/Crimson. As this
bug affects both Apache and Crimson, it is most likely that something is wrong
with the Java DOM implementation - but I am not sure.
The problem:
Code Fragment:
[...]
//imports the 'global_layout' node
System.err.println("old test1:"+currentContextElement.getAttribute("test1"));
System.err.println("old test2:"+currentContextElement.getAttribute("test2"));
Node importedNode=domResult.importNode(currentContextElement,true);
System.err.println("new test1:"+((Element)importedNode).getAttribute("test1"));
System.err.println("new test2:"+((Element)importedNode).getAttribute("test2"));
currentResultElement.appendChild(importedNode);
DTD:
<!ELEMENT global_layout (...)>
<!ATTLIST global_layout
test1 CDATA "TestTest" <----this is IMPORTANT
test2 CDATA #REQUIRED
>
Using this xml file...
<global_layout test1="t1" test2="t2">
...
</global_layout>
...gives me the right anwser:
old test1:t1
old test2:t2
new test1:t1
new test2:t2
While this xml file...
<global_layout test2="t2">
...
</global_layout>
...gives me a wrong answer:
old test1:TestTest
old test2:t2
new test1: <--should be "TestTest"
new test2:t2
The bug is, that importNode does not copy default attribute values specified in
the DTD. As one can see above,
in <global_layout> of the source DOM, the attribute test1 is existing and has
the correct value. After importing
<global_layout> via importNode(), the attribute test1 is simply missing (not =
"")
If this is not a Xerces bug, could you guys please forward this bug to your SUN
contacts?
Thanks and best regards
Julian
p.s I am using java 1.4.1 with SUN's newest JAXP implementation, with
xercesImpl.jar replaces by Xerxes 2.3. Using 1.4.1 without external
JAXP and Crimson shows the same behaviour...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]