001 /*
002 * Copyright (c) 2003 World Wide Web Consortium,
003 * (Massachusetts Institute of Technology, Institut National de
004 * Recherche en Informatique et en Automatique, Keio University). All
005 * Rights Reserved. This program is distributed under the W3C's Software
006 * Intellectual Property License. This program is distributed in the
007 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
008 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
009 * PURPOSE.
010 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
011 */
012
013 package org.w3c.dom.html2;
014
015 import org.w3c.dom.Node;
016
017 /**
018 * An <code>HTMLCollection</code> is a list of nodes. An individual node may
019 * be accessed by either ordinal index or the node's <code>name</code> or
020 * <code>id</code> attributes. Collections in the HTML DOM are assumed to be
021 * live meaning that they are automatically updated when the underlying
022 * document is changed.
023 * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.
024 */
025 public interface HTMLCollection {
026 /**
027 * This attribute specifies the length or size of the list.
028 */
029 public int getLength();
030
031 /**
032 * This method retrieves a node specified by ordinal index. Nodes are
033 * numbered in tree order (depth-first traversal order).
034 * @param index The index of the node to be fetched. The index origin is
035 * <code>0</code>.
036 * @return The <code>Node</code> at the corresponding position upon
037 * success. A value of <code>null</code> is returned if the index is
038 * out of range.
039 */
040 public Node item(int index);
041
042 /**
043 * This method retrieves a <code>Node</code> using a name. With [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>]
044 * documents, it first searches for a <code>Node</code> with a matching
045 * <code>id</code> attribute. If it doesn't find one, it then searches
046 * for a <code>Node</code> with a matching <code>name</code> attribute,
047 * but only on those elements that are allowed a name attribute. With [<a href='http://www.w3.org/TR/2002/REC-xhtml1-20020801'>XHTML 1.0</a>]
048 * documents, this method only searches for <code>Nodes</code> with a
049 * matching <code>id</code> attribute. This method is case insensitive
050 * in HTML documents and case sensitive in XHTML documents.
051 * @param name The name of the <code>Node</code> to be fetched.
052 * @return The <code>Node</code> with a <code>name</code> or
053 * <code>id</code> attribute whose value corresponds to the specified
054 * string. Upon failure (e.g., no node with this name exists), returns
055 * <code>null</code>.
056 */
057 public Node namedItem(String name);
058
059 }