## net.sf.saxon.tree
Class DocumentImpl

    java.lang.Object
      net.sf.saxon.tree.NodeImpl
          net.sf.saxon.tree.ParentNodeImpl
              net.sf.saxon.tree.DocumentImpl

All Implemented Interfaces:
  DocumentInfo, FingerprintedNode, Item, NodeInfo, javax.xml.transform.Source, javax.xml.transform.SourceLocator, ValueRepresentation

public final class DocumentImpl
extends net.sf.saxon.tree.ParentNodeImpl
implements DocumentInfo

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 net.sf.saxon.tree.NodeImpl
`index, NODE_LETTER, parent`

Fields inherited from interface net.sf.saxon.om.NodeInfo
`ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, LOCAL_NAMESPACES, NO_NAMESPACES`

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(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)` Copy this node to a given outputter
`AxisIterator` `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
`java.lang.String` `getBaseURI()` Get the base URI of this root node.
`Configuration` `getConfiguration()` Get the configuration previously set using setConfiguration
`ElementImpl` `getDocumentElement()` Get the root (outermost) element.
`int` `getDocumentNumber()` Get the unique document number
`DocumentInfo` `getDocumentRoot()` Get the root (document) node
`NodeInfo` `getFirstChild()` Get the first child node of the element
`NodeInfo` `getLastChild()` Get the last child node of the element
`int` `getLineNumber()` Get the line number of this root node.
`NamePool` `getNamePool()` Get the name pool used for the names in this document
`NodeInfo` `getNextSibling()` Get next sibling - always null
`int` `getNodeKind()` Return the type of node.
`protected NodeImpl` `getNthChild(int n)` Get the nth child node of the element (numbering from 0)
`NodeInfo` `getPreviousSibling()` Get previous sibling - always null
`NodeInfo` `getRoot()` Get the root node
`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.CharSequence` `getStringValueCS()` Get the value of the item as a CharSequence.
`java.lang.String` `getSystemId()` Get the system id of this root node
`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.
`NodeInfo` `selectID(java.lang.String id)` Get the element with a given ID.
`void` `setConfiguration(Configuration config)` Set the Configuration that contains this document
`void` `setLineNumbering()` Set line numbering on
`void` `setSystemId(java.lang.String uri)` Set the system id of this node
`void` `useChildrenArray(NodeImpl[] array)` Supply an array to be used for the array of children.

Methods inherited from class net.sf.saxon.tree.NodeImpl
`compareOrder, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getNextInDocument, getParent, getPrefix, getPreviousInDocument, getPublicId, getTypeAnnotation, getTypedValue, getURI, isSameNodeInfo, iterateAxis, iterateAxis, sendNamespaceDeclarations`

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

Methods inherited from interface net.sf.saxon.om.NodeInfo
`compareOrder, getAttributeValue, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getParent, getPrefix, getStringValue, getTypeAnnotation, getURI, hasChildNodes, isSameNodeInfo, iterateAxis, iterateAxis, sendNamespaceDeclarations`

Methods inherited from interface net.sf.saxon.om.Item
`getStringValueCS, getTypedValue`

Field Detail

### sequence

    protected int sequence

Constructor Detail

### DocumentImpl

    public DocumentImpl()

Method Detail

### setConfiguration

    public void setConfiguration(Configuration config)

  Set the Configuration that contains this document

  Specified by:
    `setConfiguration` in interface `DocumentInfo`
  Parameters:
    `config` - The configuration to be used

### getConfiguration

    public Configuration getConfiguration()

  Get the configuration previously set using setConfiguration

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

### getNamePool

    public NamePool getNamePool()

  Get the name pool used for the names in this document

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

### getDocumentNumber

    public int getDocumentNumber()

  Get the unique document number

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

### 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`

### 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`

### setLineNumbering

    public void setLineNumbering()

  Set line numbering on

### 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

### getNodeKind

    public final int getNodeKind()

  Return the type of node.

  Specified by:
    `getNodeKind` in interface `NodeInfo`
  Returns:
    Type.DOCUMENT (always)
  See Also:
    `Type`

### getNextSibling

    public final NodeInfo getNextSibling()

  Get next sibling - always null

  Overrides:
    `getNextSibling` in class `NodeImpl`
  Returns:
    null

### getPreviousSibling

    public final NodeInfo getPreviousSibling()

  Get previous sibling - always null

  Overrides:
    `getPreviousSibling` in class `NodeImpl`
  Returns:
    null

### getDocumentElement

    public ElementImpl getDocumentElement()

  Get the root (outermost) element.

  Returns:
    the Element node for the outermost element of the document.

### getRoot

    public NodeInfo getRoot()

  Get the root node

  Specified by:
    `getRoot` in interface `NodeInfo`
  Overrides:
    `getRoot` in class `NodeImpl`
  Returns:
    the NodeInfo representing the root of this tree

### 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

  Specified by:
    `generateId` in interface `NodeInfo`
  Overrides:
    `generateId` in class `NodeImpl`
  Returns:
    a string based on the document number

### 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.

### 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:
    if the entity exists, return an array of two Strings, the first holding the system ID of the entity, the second holding the public ID if there is one, or null if not. If the entity does not exist, return null. * @return the URI of the entity if there is one, or empty string if not

### copy

    public void copy(Receiver out,
                     int whichNamespaces,
                     boolean copyAnnotations,
                     int locationId)
              throws XPathException

  Copy this node to a given outputter

  Specified by:
    `copy` in interface `NodeInfo`
  Parameters:
    `out` - the Receiver to which the node should be copied
    `whichNamespaces` - in the case of an element, controls which namespace nodes should be copied. Values are `NodeInfo.NO_NAMESPACES`, `NodeInfo.LOCAL_NAMESPACES`, `NodeInfo.ALL_NAMESPACES`
    `copyAnnotations` - indicates whether the type annotations of element and attribute nodes should be copied
    `locationId` - If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information for the original node is to be copied; in this case the Receiver must be a LocationCopier
  Throws:
    `XPathException`

### 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 `NodeInfo`
  Overrides:
    `hasChildNodes` in class `NodeImpl`
  Returns:
    `true` if the node has any children, `false` if the node has no children.

### enumerateChildren

    public final AxisIterator enumerateChildren(NodeTest test)

  Get an enumeration of the children of this node

  Parameters:
    `test` - A NodeTest to be satisfied by the child nodes, or null if all child node are to be returned

### getFirstChild

    public final NodeInfo getFirstChild()

  Get the first child node of the element

  Overrides:
    `getFirstChild` in class `NodeImpl`
  Returns:
    the first child node of the required type, or null if there are no children

### getLastChild

    public final NodeInfo getLastChild()

  Get the last child node of the element

  Overrides:
    `getLastChild` in class `NodeImpl`
  Returns:
    the last child of the element, or null if there are no children

### 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.

### getStringValueCS

    public java.lang.CharSequence getStringValueCS()

  Description copied from class: `NodeImpl`
  Get the value of the item as a CharSequence. This is in some cases more efficient than the version of the method that returns a String.

  Specified by:
    `getStringValueCS` in interface `Item`
  Overrides:
    `getStringValueCS` in class `NodeImpl`

### 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.

### compact

    public void compact(int size)

  Compact the space used by this node