Hi,
        what version of xerces are you using? I still cant get any 
attributes if I use the following xml:

<!DOCTYPE greeting SYSTEM "foo.dtd"><greeting xmlns="foo" ls="ping" />

<!ELEMENT greeting EMPTY>
<!ATTLIST greeting
   ls CDATA #IMPLIED
   xmlns CDATA #IMPLIED >


let alone if I have default attrs!! I have now tried this with the CVS 
tree as well as 2.0. I have difficulty in believing that this has not been 
noticed by users as it seems fairly fundamental. Does anyone else see this 
behaviour? If I remove the DOCTYPE then I can access the attributes via 
any of the get methods.

I believe that you are correct in thinking that the default attrs should
be available through the getAttrs methods. Spec says

"The Attr value as a string, or the empty string if that attribute does 
not have a specified or default value."

All the removing stuff is dealt with properly inside of DOMAttrMap but the 
get stuff is not overridden. If it is agreed that this is the correct 
behaviour then perhaps we should put the code in there. 


Gareth


On Fri, 20 Sep 2002, Erik Rydgren wrote:

> I did some serious debugging and have tracked my problem down to the
> document cloning process. Everything looks dandy until then except that I
> can not access the default attributes but at least they are there in
> DOMElementImpl::fDefaultAttributes.
> So I modified some fuctions to be able to access the default values.
> 
> *************************************************************************
> const XMLCh * DOMElementImpl::getAttribute(const XMLCh *nam) const
> {
>     static const XMLCh emptyString[]  = {0};
>     DOMNode * attr=0;
> 
>     attr=fAttributes->getNamedItem(nam);
> 
>     if (!attr && fAttributes->hasDefaults())
>       attr=fDefaultAttributes->getNamedItem(nam);
> 
>     const XMLCh *retString = emptyString;
>     if (attr != 0)
>         retString = attr->getNodeValue();
> 
>     return retString;
> };
> *************************************************************************
> DOMAttr *DOMElementImpl::getAttributeNode(const XMLCh *nam) const
> {
>     DOMNode * attr=0;
>     attr=fAttributes->getNamedItem(nam);
>     if (!attr && fAttributes->hasDefaults())
>       attr=fDefaultAttributes->getNamedItem(nam);
>     return  (DOMAttr*) attr;
> };
> *************************************************************************
> 
> I'm not sure how the DOM API is supposed to work with default values.
> Should getAttributes also return default value attributes?
> If it should, then the solution needs to be modified a bit.
> 
> I came to realize that a document clone totally removes all default values.
> How it is supposed to work?
> Personally I found the new handy function adoptDocument() in the parser so I
> do not sweat about the cloning problem anymore ( plus that I saved tons of
> CPU cykles. YES! :o) )
> 
> Regards
> 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]

Reply via email to