You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by John Nunneley <jk...@synchronnetworks.com> on 2000/12/08 04:37:35 UTC

Getting Default Attibute Values ?

I don't seem to be getting the default attributes when I look at the
attribute list for an element.  If an attribute is declared to have a
default value, but  it is not defined in the body of the element,
shouldn't it get "filled in" to the attribute list?

i.e.
..

<!ELEMENT myelement EMPTY>
<!ATTLIST myelement
    myid  IDREF #REQUIRED
    myattr CDATA "default value"
>
..
<myelement myid="MyID"/>
..
does not yield an attribute myattr="default value" in the attribute list

as I expected it would.

Thanks for any insight into this.
Regards,
John Nunneley



Re: Getting Default Attibute Values ?

Posted by Thomas Norton <to...@ndtechnologies.com>.
Is it possible that you first importing the node before
attempting to view it's attributes?

Eric Wasserman reported:
>> Is anyone else having trouble with Document::importNode()?
>> I find that importNode sometimes neglects to import attributes of
elements.

Joseph Kesselman  responded:
>>I forgot to mention: Note that this handling of default attributes is
>>different from what happens when you explicitly import an Attr node.
>>Importing a default Attr yields a specified (non-default) Attr.

I had a similar problem and solved it by cloning the node then importing it.
DOM_Element::cloneNode(bool deep) copies default attributes.

It's a shot in the dark...Hope it helps.
- Tom


----- Original Message -----
From: "John Nunneley" <jk...@synchronnetworks.com>
To: "xerces C-Dev" <xe...@xml.apache.org>
Sent: Thursday, December 07, 2000 10:37 PM
Subject: Getting Default Attibute Values ?


> I don't seem to be getting the default attributes when I look at the
> attribute list for an element.  If an attribute is declared to have a
> default value, but  it is not defined in the body of the element,
> shouldn't it get "filled in" to the attribute list?
>
> i.e.
> ..
>
> <!ELEMENT myelement EMPTY>
> <!ATTLIST myelement
>     myid  IDREF #REQUIRED
>     myattr CDATA "default value"
> >
> ..
> <myelement myid="MyID"/>
> ..
> does not yield an attribute myattr="default value" in the attribute list
>
> as I expected it would.
>
> Thanks for any insight into this.
> Regards,
> John Nunneley
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>