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


Reply via email to