You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Ju...@daimlerchrysler.com on 2003/02/27 17:28:59 UTC

A serious bug in org.w3c.dom or Xerces

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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: A serious bug in org.w3c.dom or Xerces

Posted by Joseph Kesselman <ke...@us.ibm.com>.
The DOM spec explicitly says "Default attributes are not copied, though if 
the document being imported into defines default attributes for this 
element name, those are assigned. "

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies:
XML, XSL and more.  "may'ron DaroQbe'chugh vaj bIrIQbej" 
("Put down the squeezebox and nobody gets hurt.")


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org