You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Mike Oliver <mo...@unt.edu> on 2006/11/15 05:46:13 UTC
Distinguishing default attribute value from absent attribute
Suppose you're using the DOM setup and you have an attribute
for an element, defined in the .dtd file with a default value.
When parsing, how can you distinguish the situation where the .xml file
did not have that attribute specified for that attribute, from
the situation where the default value was specified explicitly?
The docs claim that DOMElement::getAttrNode returns
The DOMAttr node with the specified name (nodeName) or null if there is no such attribute.
However this does not seem to be true, unless by "there is no such attribute"
they mean that there is no such attribute even in the .dtd file.
Re: Distinguishing default attribute value from absent attribute
Posted by Mike Oliver <mo...@unt.edu>.
Alberto Massari wrote:
> At 20.46 14/11/2006 -0800, Mike Oliver wrote:
>
>> Suppose you're using the DOM setup and you have an attribute
>> for an element, defined in the .dtd file with a default value.
>> When parsing, how can you distinguish the situation where the .xml file
>> did not have that attribute specified for that attribute, from
>> the situation where the default value was specified explicitly?
>
> See DOMAttr::getSpecified
Thanks much!
Re: Distinguishing default attribute value from absent
attribute
Posted by Alberto Massari <am...@datadirect.com>.
At 20.46 14/11/2006 -0800, Mike Oliver wrote:
>Suppose you're using the DOM setup and you have an attribute
>for an element, defined in the .dtd file with a default value.
>When parsing, how can you distinguish the situation where the .xml file
>did not have that attribute specified for that attribute, from
>the situation where the default value was specified explicitly?
>
>The docs claim that DOMElement::getAttrNode returns
> The DOMAttr node with the specified name (nodeName) or null if
> there is no such attribute.
>However this does not seem to be true, unless by "there is no such attribute"
>they mean that there is no such attribute even in the .dtd file.
See DOMAttr::getSpecified
/**
*
* Returns true if the attribute received its value explicitly in the
* XML document, or if a value was assigned programatically with
* the setValue function. Returns false if the attribute value
* came from the default value declared in the document's DTD.
* @since DOM Level 1
*/
virtual bool getSpecified() const = 0;
Alberto