org.openxml
Class XMLCollection

java.lang.Object
  |
  +--org.openxml.dom.CollectionImpl
        |
        +--org.openxml.XMLCollection

public class XMLCollection
extends org.openxml.dom.CollectionImpl

Implements a live collection of elements. This collection is based on the HTMLCollection defined for HTML documents but works with XML documents.

The collection is defined in terms of a root element and the elements to look for under this root. Only elements of the specified type are contained in the collection. Elements are returned by index or by identifier (the id attribute). The collection is live, meaning that changes to the document tree are immediately reflected in the collection. The collection is not optimized for traversing large document trees.

Application specific collections can be defined by overriding the methods CollectionImpl.recurse() and CollectionImpl.collectionMatch(org.w3c.dom.Element, java.lang.String). The first indicates whether the collection is recursive or flat. The second returns true for each element that matches the collection. The default implementation looks for elements based on their tag name.

Note that synchronization on the traversed document cannot be achieved. The document itself cannot be locked, and locking each traversed node is likely to lead to a dead lock condition. Therefore, there is a chance of the document being changed as results are fetched; in all likelihood, the results might be out dated, but not erroneous.

Version:
$Revision: 1.3 $ $Date: 1999/03/30 06:49:03 $
Author:
Assaf Arkin
See Also:
XMLDocument, HTMLCollection

Constructor Summary
XMLCollection(Document document, java.lang.String lookFor)
          Construct a collection to look for named elements (lookFor matches the tag name) inside the document.
XMLCollection(XMLElement topLevel, java.lang.String lookFor)
          Construct a collection to look for named elements (lookFor matches the tag name) under the top-level element.
 
Methods inherited from class org.openxml.dom.CollectionImpl
collectionMatch, getLength, item, namedItem, recurse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLCollection

public XMLCollection(XMLElement topLevel,
                     java.lang.String lookFor)
Construct a collection to look for named elements (lookFor matches the tag name) under the top-level element.
Parameters:
topLevel - The top level element underneath which to look
lookFor - The element to look for

XMLCollection

public XMLCollection(Document document,
                     java.lang.String lookFor)
Construct a collection to look for named elements (lookFor matches the tag name) inside the document.
Parameters:
document - The document in which to look
lookFor - The element to look for