DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22660>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22660

Attribute default values in DTD not available after DOMElement::cloneNode()

           Summary: Attribute default values in DTD not available after
                    DOMElement::cloneNode()
           Product: Xerces-C++
           Version: 2.3.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Seem to be losing default attrubues after DOMElement::cloneNode(true).  Here's 
the background:

I create a XercesDOMParser and parse a document.
If I get a DOMElement* from the parser using
getDocument()->getDocumentElement() it will contain
all the specified and the default attributes.
However, if I call
getDocument()->getDocumentElement()->cloneNode(true)
the resulting DOMElement* will only contain the
specified attributes, not the defaults.
Am using xerces 2.3.0, win32.

This was an issue raised a while back in xerces-c-dev, but it seems to have 
been dropped as far as i can tell (?)... see below


List:     xerces-c-dev
Subject:  RE: Attribute default values in DTD is not
available in the DOMDocument.
From:     Gareth Reakes <gareth () decisionsoft ! com>
Date:     2002-09-23 17:11:11
[Download message RAW]

OK,
        well this is the code thats the problem (in 
DOMDocumentImpl::importNode):

            if (smap != 0) {
                for(XMLSize_t i = 0; i <
smap->getLength(); i++) {
                   
tmap->setNamedItem(importNode(smap->item(i), true, 
false));
                }
            }
            // NOTE: At this time, the DOM definition
of DocumentType
            // doesn't cover Elements and their
Attributes. domimpl's
            // extentions in that area will not be
preserved, even if
            // copying from domimpl to domimpl. We
could special-case
            // that here. Arguably we should.
Consider. ?????
            newnode = newdoctype;

It seems that this has not yet been discussed. What do
people think? When 
you clone a document should you have access the the
element info from the 
DTD? I would say yes. I will provide a patch if it is
agreed that this 
should be the behaviour.


Gareth




On Mon, 23 Sep 2002, Gareth Reakes wrote:

> Hi,
>       well this has been fun. Ive looked into this a bit
now and think I 
> know whats going on. cloneNode is implemented by
using importNode. 
> Unfortunately there is a difference in behaviour. 
> 
> >From the level 2 spec for importNode:
> 
> "Specified attribute nodes of the source element are
imported, and the 
> generated Attr nodes are attached to the generated
Element. Default 
> attributes are not copied, though if the document
being imported into 
> defines default attributes for this element name,
those are assigned."
> 
> >From the Level 2 spec for cloneNode:
> 
> "Cloning an Element copies all attributes and their
values, including
> those generated by the XML processor to represent
defaulted attributes"
> 
> 
> The code for importNode seems to be correct. 
> 
> for(XMLSize_t i=0;i<srcattr->getLength();++i)
>    {
>        DOMAttr *attr = (DOMAttr *) srcattr->item(i);
>        if (attr -> getSpecified()) { // not a
default attribute
> 
> so this is a bug. Its not our fault though because
this code was ported 
> from the java ;)
> 
> 
> Gareth
> 
> 
> On Mon, 23 Sep 2002, Erik Rydgren wrote:
> 
> > Well now it is time to set things streight.
> > The default values in DOM are in fact working
*blush*.
> > Found it out during the test that Gareth did
suggest. The extra code that I
> > suggested is not needed.
> > Somewhere deep down in the parser the default
values are transferred into
> > the standard attribute list.
> > (There I got fooled by not reading all the hundred
thousand lines of code
> > but just a subset. Silly me.)
> > 
> > BUT! After a document clone then the default
values ARE in fact removed. So
> > if there is something that needs fixing it is the
document clone process.
> > 
> > Sorry for taking up your time.
> > / Erik Rydgren

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to