W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Re: Attribute is a kind of Node?

From: Ray Whitmer <ray@imall.com>
Date: Tue, 03 Nov 1998 05:07:21 -0700
Message-ID: <363EF1F9.AE1D6D9D@imall.com>
To: DOM List <www-dom@w3.org>


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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT