net.sf.saxon.tree
Class DocumentImpl

java.lang.Object
  extended by net.sf.saxon.om.AbstractNode
      extended by net.sf.saxon.tree.NodeImpl
          extended by net.sf.saxon.tree.ParentNodeImpl
              extended by net.sf.saxon.tree.DocumentImpl
All Implemented Interfaces:
DOMLocator, Source, SourceLocator, DocumentInfo, Item, NodeInfo, Document, Node

public final class DocumentImpl
extends ParentNodeImpl
implements DocumentInfo, Document

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

Author:
Field Summary
 
Fields inherited from class net.sf.saxon.tree.ParentNodeImpl
sequence
 
Fields inherited from class net.sf.saxon.tree.NodeImpl
index, parent
 
Fields inherited from class net.sf.saxon.om.AbstractNode
NODE_LETTER
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
DocumentImpl()
           
 
Method Summary
 void copy(Receiver out, int whichNamespaces)
          Copy this node to a given outputter
 String generateId()
          Get a character string that uniquely identifies this node
protected  AxisIterator getAllElements(int fingerprint)
          Get a list of all elements with a given name fingerprint
 String getBaseURI()
          Get the base URI of this root node.
 Element getDocumentElement()
          Get the root (outermost) element.
 int getDocumentNumber()
          Get the unique document number
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 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
 Node getNextSibling()
          Get next sibling - always null
 int getNodeKind()
          Return the type of node.
 Node getPreviousSibling()
          Get previous sibling - always null
 NodeInfo getRoot()
          Get the root node
 String getSystemId()
          Get the system id of this root node
protected  String getSystemId(int seq)
          Get the system id of an element in the document
 String[] getUnparsedEntity(String name)
          Get the unparsed entity with a given name
 NodeInfo selectID(String id)
          Get the element with a given ID.
protected  void setDocumentElement(ElementImpl e)
          Set the top-level element of the document (variously called the root element or the document element).
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
protected  void setSystemId(int seq, String uri)
          Set the system id of an element in the document
 void setSystemId(String uri)
          Set the system id of this node
protected  void setUnparsedEntity(String name, String uri, String publicId)
          Set an unparsed entity URI associated with this document.
 
Methods inherited from class net.sf.saxon.tree.ParentNodeImpl
addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNodeValue, getNthChild, getSequenceNumber, getStringValue, hasChildNodes, useChildrenArray
 
Methods inherited from class net.sf.saxon.tree.NodeImpl
compareOrder, copy, getAttributeValue, getDisplayName, getFingerprint, getLocalPart, getNameCode, getNextInDocument, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getURI, hasAttributes, isSameNode, iterateAxis, iterateAxis, outputNamespaceNodes
 
Methods inherited from class net.sf.saxon.om.AbstractNode
appendChild, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLength, getLocalName, getName, getNamespaceURI, getNodeName, getNodeType, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSpecified, getTagName, getTypeAnnotation, getTypedValue, 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 net.sf.saxon.om.NodeInfo
compareOrder, copy, getAttributeValue, getDisplayName, getFingerprint, getLocalPart, getNameCode, getParent, getStringValue, getTypeAnnotation, getURI, hasChildNodes, isSameNode, iterateAxis, iterateAxis, outputNamespaceNodes
 
Methods inherited from interface net.sf.saxon.om.Item
getTypedValue
 
Methods inherited from interface org.w3c.dom.Document
adoptNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, normalizeDocument, renameNode, setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersion
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Constructor Detail

DocumentImpl

public DocumentImpl()
Method Detail

setNamePool

public void setNamePool(NamePool pool)
Set the name pool used for all names in this document

Specified by:
setNamePool in interface DocumentInfo
Parameters:
pool - The name pool to be used

getNamePool

public NamePool getNamePool()
Get the name pool used for the names in this document

Specified by:
getNamePool in interface DocumentInfo
Specified by:
getNamePool in interface NodeInfo
Overrides:
getNamePool in class NodeImpl
Returns:
the namepool

getDocumentNumber

public int getDocumentNumber()
Get the unique document number

Specified by:
getDocumentNumber in interface DocumentInfo
Specified by:
getDocumentNumber in interface NodeInfo
Overrides:
getDocumentNumber in class AbstractNode
Returns:
the unique number identifying this document within the name pool

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(String uri)
Set the system id of this node

Specified by:
setSystemId in interface Source
Overrides:
setSystemId in class NodeImpl

getSystemId

public String getSystemId()
Get the system id of this root node

Specified by:
getSystemId in interface Source
Specified by:
getSystemId in interface SourceLocator
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 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
Specified by:
getBaseURI in interface Node
Overrides:
getBaseURI in class NodeImpl
Returns:
the base URI of the node

setSystemId

protected void setSystemId(int seq,
                           String uri)
Set the system id of an element in the document


getSystemId

protected 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 SourceLocator
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 Node getNextSibling()
Get next sibling - always null

Specified by:
getNextSibling in interface Node
Overrides:
getNextSibling in class NodeImpl
Returns:
null

getPreviousSibling

public final Node getPreviousSibling()
Get previous sibling - always null

Specified by:
getPreviousSibling in interface Node
Overrides:
getPreviousSibling in class NodeImpl
Returns:
null

getDocumentElement

public Element getDocumentElement()
Get the root (outermost) element.

Specified by:
getDocumentElement in interface Document
Overrides:
getDocumentElement in class NodeImpl
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 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

getAllElements

protected AxisIterator getAllElements(int fingerprint)
Get a list of all elements with a given name fingerprint


selectID

public NodeInfo selectID(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.

setUnparsedEntity

protected void setUnparsedEntity(String name,
                                 String uri,
                                 String publicId)
Set an unparsed entity URI associated with this document. For system use only, while building the document.


getUnparsedEntity

public String[] getUnparsedEntity(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)
          throws TransformerException
Copy this node to a given outputter

Specified by:
copy in class NodeImpl
Throws:
TransformerException