## com.icl.saxon.tree
Class DocumentImpl

    java.lang.Object
      |
      +--com.icl.saxon.om.AbstractNode
            |
            +--com.icl.saxon.tree.NodeImpl
                  |
                  +--com.icl.saxon.tree.ParentNodeImpl
                        |
                        +--com.icl.saxon.tree.DocumentImpl

All Implemented Interfaces:
  org.w3c.dom.Document, DocumentInfo, javax.xml.transform.dom.DOMLocator, org.w3c.dom.Node, NodeInfo, javax.xml.transform.Source, javax.xml.transform.SourceLocator

public final class DocumentImpl
extends com.icl.saxon.tree.ParentNodeImpl
implements DocumentInfo, org.w3c.dom.Document

A node in the XML parse tree representing the Document itself (or equivalently, the root node of the Document).

Field Summary
`protected int` `sequence`

Fields inherited from class com.icl.saxon.tree.NodeImpl
`emptyArray, index, parent`

Fields inherited from class com.icl.saxon.om.AbstractNode
`NODE_LETTER`

Fields inherited from interface com.icl.saxon.om.NodeInfo
`ATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NONE, NUMBER_OF_TYPES, PI, ROOT, TEXT`

Fields inherited from interface org.w3c.dom.Node
`ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE`

Constructor Summary
`DocumentImpl()`

Method Summary
`void` `addChild(NodeImpl node, int index)` Add a child node to this node.
`void` `compact(int size)` Compact the space used by this node
`void` `copy(Outputter out)` Copy this node to a given outputter
`void` `copyStringValue(Outputter out)` Copy the string-value of this node to a given outputter
`void` `dropChildren()` Drop a branch of the tree.
`AxisEnumeration` `enumerateChildren(NodeTest test)` Get an enumeration of the children of this node
`java.lang.String` `generateId()` Get a character string that uniquely identifies this node within the document
`protected AxisEnumeration` `getAllElements(int fingerprint)` Get a list of all elements with a given name fingerprint
`java.lang.String` `getBaseURI()` Get the base URI of this root node.
`java.lang.StringBuffer` `getCharacterBuffer()` Get the character buffer
`org.w3c.dom.NodeList` `getChildNodes()` Return a `NodeList` that contains all children of this node.
`org.w3c.dom.Element` `getDocumentElement()` Get the root (outermost) element.
`DocumentInfo` `getDocumentRoot()` Get the root (document) node
`org.w3c.dom.Node` `getFirstChild()` Get the first child node of the element
`java.util.Hashtable` `getKeyIndex(KeyManager keymanager, int fingerprint)` Get the index for a given key
`org.w3c.dom.Node` `getLastChild()` Get the last child node of the element
`int` `getLineNumber()` Get the line number of this root node.
`protected int` `getLineNumber(int sequence)` Get the line number for an element.
`NamePool` `getNamePool()` Get the name pool used for the names in this document
`org.w3c.dom.Node` `getNextSibling()` Get next sibling - always null
`NodeFactory` `getNodeFactory()` Get the node factory that was used to build this document
`short` `getNodeType()` Return the type of node.
`java.lang.String` `getNodeValue()` Get the node value as defined in the DOM.
`protected NodeImpl` `getNthChild(int n)` Get the nth child node of the element (numbering from 0)
`org.w3c.dom.Node` `getPreviousSibling()` Get previous sibling - always null
`protected long` `getSequenceNumber()` Get the node sequence number (in document order).
`java.lang.String` `getStringValue()` Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
`java.lang.String` `getSystemId()` Get the system id of this root node
`protected java.lang.String` `getSystemId(int seq)` Get the system id of an element in the document
`java.lang.String` `getUnparsedEntity(java.lang.String name)` Get the unparsed entity with a given name
`boolean` `hasChildNodes()` Determine if the node has any children.
`void` `removeChild(int index)` Remove node at given index.
`void` `renumberChildren()` Renumber the children of a given parent node.
`NodeInfo` `selectID(java.lang.String id)` Get the element with a given ID.
`protected void` `setCharacterBuffer(java.lang.StringBuffer buffer)` Set the character buffer
`protected void` `setDocumentElement(ElementImpl e)` Set the top-level element of the document (variously called the root element or the document element).
`void` `setKeyIndex(KeyManager keymanager, int fingerprint, java.util.Hashtable keyindex)` Set the index for a given key.
`protected void` `setLineNumber(int sequence, int line)` Set the line number for an element.
`void` `setLineNumbering()` Set line numbering on
`void` `setNamePool(NamePool pool)` Set the name pool used for all names in this document
`void` `setNodeFactory(NodeFactory factory)` Set the node factory that was used to build this document
`protected void` `setSystemId(int seq, java.lang.String uri)` Set the system id of an element in the document
`void` `setSystemId(java.lang.String uri)` Set the system id of this node
`protected void` `setUnparsedEntity(java.lang.String name, java.lang.String uri)` Set an unparsed entity URI associated with this document.
`void` `useChildrenArray(NodeImpl[] array)` Supply an array to be used for the array of children.

Methods inherited from class com.icl.saxon.tree.NodeImpl
`compareOrder, getAttributes, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getNextInDocument, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getURI, hasAttributes, isSameNode, outputNamespaceNodes, removeNode`

Methods inherited from class com.icl.saxon.om.AbstractNode

`appendChild, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLength, getName, getNamespaceURI, getNodeName, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSpecified, getTagName, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setNodeValue, setPrefix, setValue, splitText, substringData, supports`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.icl.saxon.om.NodeInfo
`compareOrder, copyStringValue, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getParent, getPrefix, getStringValue, getURI, hasChildNodes, isSameNode, outputNamespaceNodes`

Methods inherited from interface org.w3c.dom.Document
`createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, importNode`

Methods inherited from interface org.w3c.dom.Node
`appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix`

Field Detail

### sequence

    protected int sequence

Constructor Detail

### DocumentImpl

    public DocumentImpl()

Method Detail

### setCharacterBuffer

    protected void setCharacterBuffer(java.lang.StringBuffer buffer)

  Set the character buffer

### getCharacterBuffer

    public final java.lang.StringBuffer getCharacterBuffer()

  Get the character buffer

### setNamePool

    public void setNamePool(NamePool pool)

  Set the name pool used for all names in this document

  Specified by:
    `setNamePool` in interface `DocumentInfo`

### getNamePool

    public NamePool getNamePool()

  Get the name pool used for the names in this document

  Specified by:
    `getNamePool` in interface `DocumentInfo`
  Overrides:
    `getNamePool` in class `NodeImpl`

### setNodeFactory

    public void setNodeFactory(NodeFactory factory)

  Set the node factory that was used to build this document

### getNodeFactory

    public NodeFactory getNodeFactory()

  Get the node factory that was used to build this document

### setDocumentElement

    protected void setDocumentElement(ElementImpl e)

  Set the top-level element of the document (variously called the root element or the document element). Note that a DocumentImpl may represent the root of a result tree fragment, in which case there is no document element.

  Parameters:
    `e` - the top-level element

### setSystemId

    public void setSystemId(java.lang.String uri)

  Set the system id of this node

  Specified by:
    `setSystemId` in interface `javax.xml.transform.Source`
  Overrides:
    `setSystemId` in class `NodeImpl`

### getSystemId

    public java.lang.String getSystemId()

  Get the system id of this root node

  Specified by:
    `getSystemId` in interface `NodeInfo`
  Overrides:
    `getSystemId` in class `NodeImpl`
  Returns:
    the System Identifier of the entity in the source document containing the node, or null if not known. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.

### getBaseURI

    public java.lang.String getBaseURI()

  Get the base URI of this root node. For a root node the base URI is the same as the System ID.

  Specified by:
    `getBaseURI` in interface `NodeInfo`
  Overrides:
    `getBaseURI` in class `NodeImpl`

### setSystemId

    protected void setSystemId(int seq,
                               java.lang.String uri)

  Set the system id of an element in the document

### getSystemId

    protected java.lang.String getSystemId(int seq)

  Get the system id of an element in the document

### setLineNumbering

    public void setLineNumbering()

  Set line numbering on

### setLineNumber

    protected void setLineNumber(int sequence,
                                 int line)

  Set the line number for an element. Ignored if line numbering is off.

### getLineNumber

    protected int getLineNumber(int sequence)

  Get the line number for an element. Return -1 if line numbering is off.

### getLineNumber

    public int getLineNumber()

  Get the line number of this root node.

  Specified by:
    `getLineNumber` in interface `NodeInfo`
  Overrides:
    `getLineNumber` in class `NodeImpl`
  Returns:
    0 always

### getNodeType

    public final short getNodeType()

  Return the type of node.

  Specified by:
    `getNodeType` in interface `NodeInfo`
  Returns:
    NodeInfo.ROOT (always)

### getNextSibling

    public final org.w3c.dom.Node getNextSibling()

  Get next sibling - always null

  Specified by:
    `getNextSibling` in interface `org.w3c.dom.Node`
  Overrides:
    `getNextSibling` in class `NodeImpl`
  Returns:
    null

### getPreviousSibling

    public final org.w3c.dom.Node getPreviousSibling()

  Get previous sibling - always null

  Specified by:
    `getPreviousSibling` in interface `org.w3c.dom.Node`
  Overrides:
    `getPreviousSibling` in class `NodeImpl`
  Returns:
    null

### getDocumentElement

    public org.w3c.dom.Element getDocumentElement()

  Get the root (outermost) element.

  Specified by:
    `getDocumentElement` in interface `org.w3c.dom.Document`
  Overrides:
    `getDocumentElement` in class `NodeImpl`
  Returns:
    the Element node for the outermost element of the document.

### getDocumentRoot

    public DocumentInfo getDocumentRoot()

  Get the root (document) node

  Specified by:
    `getDocumentRoot` in interface `NodeInfo`
  Overrides:
    `getDocumentRoot` in class `NodeImpl`
  Returns:
    the DocumentInfo representing this document

### generateId

    public java.lang.String generateId()

  Get a character string that uniquely identifies this node within the document

  Specified by:
    `generateId` in interface `NodeInfo`
  Overrides:
    `generateId` in class `NodeImpl`
  Returns:
    the empty string

### getAllElements

    protected AxisEnumeration getAllElements(int fingerprint)

  Get a list of all elements with a given name fingerprint

### selectID

    public NodeInfo selectID(java.lang.String id)

  Get the element with a given ID.

  Specified by:
    `selectID` in interface `DocumentInfo`
  Parameters:
    `id` - The unique ID of the required element, previously registered using registerID()
  Returns:
    The NodeInfo for the given ID if one has been registered, otherwise null.

### getKeyIndex

    public java.util.Hashtable getKeyIndex(KeyManager keymanager,
                                           int fingerprint)

  Get the index for a given key

  Specified by:
    `getKeyIndex` in interface `DocumentInfo`
  Parameters:
    `keymanager` - The key manager managing this key
    `fingerprint` - The fingerprint of the name of the key (unique with the key manager)
  Returns:
    The index, if one has been built, in the form of a Hashtable that maps the key value to a Vector of nodes having that key value. If no index has been built, returns null.

### setKeyIndex

    public void setKeyIndex(KeyManager keymanager,
                            int fingerprint,
                            java.util.Hashtable keyindex)

  Set the index for a given key. The method is synchronized because the same document can be used by several stylesheets at the same time.

  Specified by:
    `setKeyIndex` in interface `DocumentInfo`
  Parameters:
    `keymanager` - The key manager managing this key
    `fingerprint` - The fingerprint of the name of the key (unique with the key manager)
    `keyindex` - the index, in the form of a Hashtable that maps the key value to a Vector of nodes having that key value. Or the String "under construction", indicating that the index is being built.

### setUnparsedEntity

    protected void setUnparsedEntity(java.lang.String name,
                                     java.lang.String uri)

  Set an unparsed entity URI associated with this document. For system use only, while building the document.

### getUnparsedEntity

    public java.lang.String getUnparsedEntity(java.lang.String name)

  Get the unparsed entity with a given name

  Specified by:
    `getUnparsedEntity` in interface `DocumentInfo`
  Parameters:
    `name` - the name of the entity
  Returns:
    the URI of the entity if there is one, or empty string if not

### copy

    public void copy(Outputter out)
              throws javax.xml.transform.TransformerException

  Copy this node to a given outputter

  Specified by:
    `copy` in interface `NodeInfo`
    `javax.xml.transform.TransformerException`

### getSequenceNumber

    protected final long getSequenceNumber()

  Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position.

  Overrides:
    `getSequenceNumber` in class `NodeImpl`

### hasChildNodes

    public final boolean hasChildNodes()

  Determine if the node has any children.

  Specified by:
    `hasChildNodes` in interface `org.w3c.dom.Node`
  Overrides:
    `hasChildNodes` in class `NodeImpl`
  Returns:
    `true` if the node has any children, `false` if the node has no children.

### enumerateChildren

    public final AxisEnumeration enumerateChildren(NodeTest test)

  Get an enumeration of the children of this node

### getFirstChild

    public final org.w3c.dom.Node getFirstChild()

  Get the first child node of the element

  Specified by:
    `getFirstChild` in interface `org.w3c.dom.Node`
  Overrides:
    `getFirstChild` in class `NodeImpl`
  Returns:
    the first child node of the required type, or null if there are no children

### getLastChild

    public final org.w3c.dom.Node getLastChild()

  Get the last child node of the element

  Specified by:
    `getLastChild` in interface `org.w3c.dom.Node`
  Overrides:
    `getLastChild` in class `NodeImpl`
  Returns:
    the last child of the element, or null if there are no children

### getChildNodes

    public final org.w3c.dom.NodeList getChildNodes()

  Return a `NodeList` that contains all children of this node. If there are no children, this is a `NodeList` containing no nodes.

  Specified by:
    `getChildNodes` in interface `org.w3c.dom.Node`
  Overrides:
    `getChildNodes` in class `NodeImpl`

### getNthChild

    protected final NodeImpl getNthChild(int n)

  Get the nth child node of the element (numbering from 0)

  Returns:
    the last child of the element, or null if there is no n'th child

### getStringValue

    public java.lang.String getStringValue()

  Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.

  Returns:
    the accumulated character content of the element, including descendant elements.

### copyStringValue

    public void copyStringValue(Outputter out)
                         throws javax.xml.transform.TransformerException

  Copy the string-value of this node to a given outputter

  Specified by:
    `copyStringValue` in interface `NodeInfo`
  Overrides:
    `copyStringValue` in class `AbstractNode`
    `javax.xml.transform.TransformerException`

### useChildrenArray

    public void useChildrenArray(NodeImpl[] array)

  Supply an array to be used for the array of children. For system use only.

### addChild

    public void addChild(NodeImpl node,
                         int index)

  Add a child node to this node. For system use only. Note: normalizing adjacent text nodes is the responsibility of the caller.

### removeChild

    public void removeChild(int index)

  Remove node at given index. Will always be followed by a renumberChildren().

### renumberChildren

    public void renumberChildren()

  Renumber the children of a given parent node. For system use only

### dropChildren

    public void dropChildren()

  Drop a branch of the tree. The target element remains in the tree, but its children are disconnected from the parent. Unless there are other references to the children (e.g. in a variable) they will be deleted from memory next time the garbage collector comes round.

### compact

    public void compact(int size)

  Compact the space used by this node

### getNodeValue

    public java.lang.String getNodeValue()

  Get the node value as defined in the DOM. This is not the same as the XPath string-value.

  Specified by:
    `getNodeValue` in interface `org.w3c.dom.Node`
  Overrides:
    `getNodeValue` in class `AbstractNode`