Hi,
Am trying to find out if the issue in the thread below
got resolved?
<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.
</backgrond>
Apologies if this has been cleared up already, I
trawled the archives but came up with nothing.
rgds
Andrew Fuller
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]
> >
> >
>
>
--
Gareth Reakes, Head of Product Development
DecisionSoft Ltd.
http://www.decisionsoft.com
Office: +44 (0) 1865 203192
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]