Re: Attribute is a kind of Node?

DaeHoon Zee wrote:

> Please somebody explain to me, why Attribute shoulld be a Node.
> Is it possible Attibute have some child Nodes?
> What will be happen if insertBefore() is called like below?
>         myNode.insertNode(myAttribute, prevNode);
>
> If the answers are 'No' and 'Error', again, why Attribute shoulld be a Node?

After asking whether Attr can have children (which it can), your example tries
to use an Attr as a child node, which it can not be.  This is not unique to
Attr.  Also Document and DocumentFragment are never child nodes.  But each of
these three can be the root of a hierarchy of values.

Section 1.1.1 in the recommendation gives a list of which nodes are parents and
children of which other nodes.  Attr has to be a node so that it can have entity
references in addition to text as children.  But it is never a child node, which
would make as little sense as making a Document or DocumentFragment a child
node.

There are getAttribute and setAttribute functions on Element so that users who
do not need to manipulate entity references inside attributes can ignore
attributes as nodes.  Some implementations may never actually construct nodes
for the attribute values if the nodes are never explicitly requested.

Ray Whitmer
ray@imall.com

Received on Tuesday, 3 November 1998 07:08:06 UTC