net.sf.saxon.tree
Class DocumentImpl

java.lang.Object
  |
  +--net.sf.saxon.om.AbstractNode
        |
        +--net.sf.saxon.tree.NodeImpl
              |
              +--net.sf.saxon.tree.ParentNodeImpl
                    |
                    +--net.sf.saxon.tree.DocumentImpl
All Implemented Interfaces:
org.w3c.dom.Document, DocumentInfo, javax.xml.transform.dom.DOMLocator, FingerprintedNode, Item, org.w3c.dom.Node, NodeInfo, javax.xml.transform.Source, javax.xml.transform.SourceLocator

public final class DocumentImpl
extends net.sf.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 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_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.
 org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)
           
 void compact(int size)
          Compact the space used by this node
 void copy(Receiver out, int whichNamespaces)
          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
 org.w3c.dom.Element getDocumentElement()
          Get the root (outermost) element.
 int getDocumentNumber()
          Get the unique document number
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 java.lang.String getDocumentURI()
           
 org.w3c.dom.Node getFirstChild()
          Get the first child node of the element
 java.lang.String getInputEncoding()
          The following methods are defined in DOM Level 3, and Saxon includes nominal implementations of these methods so that the code will compile when DOM Level 3 interfaces are installed.
 org.w3c.dom.Node 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
 org.w3c.dom.Node getNextSibling()
          Get next sibling - always null
 int getNodeKind()
          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
 NodeInfo getRoot()
          Get the root node
protected  long getSequenceNumber()
          Get the node sequence number (in document order).
 boolean getStrictErrorChecking()
           
 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
 java.lang.String[] getUnparsedEntity(java.lang.String name)
          Get the unparsed entity with a given name
 java.lang.String getXmlEncoding()
           
 boolean getXmlStandalone()
           
 java.lang.String getXmlVersion()
           
 boolean hasChildNodes()
          Determine if the node has any children.
 void normalizeDocument()
           
 org.w3c.dom.Node renameNode(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String qualifiedName)
           
 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 setDocumentURI(java.lang.String documentURI)
           
 void setLineNumbering()
          Set line numbering on
 void setStrictErrorChecking(boolean strictErrorChecking)
           
 void setSystemId(java.lang.String uri)
          Set the system id of this node
 void setXmlStandalone(boolean xmlStandalone)
           
 void setXmlVersion(java.lang.String xmlVersion)
           
 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, copy, getAttributeValue, getDisplayName, getFingerprint, getLocalPart, getNameCode, getNextInDocument, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getURI, hasAttributes, isSameNodeInfo, iterateAxis, iterateAxis, outputNamespaceNodes
 
Methods inherited from class net.sf.saxon.om.AbstractNode
appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getImplementation, getLength, getLocalName, getName, getNamespaceURI, getNodeName, getNodeType, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getTypeAnnotation, getTypedValue, getUserData, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, 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, isSameNodeInfo, iterateAxis, iterateAxis, outputNamespaceNodes
 
Methods inherited from interface net.sf.saxon.om.Item
getTypedValue
 
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, getNodeType, 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

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 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
Returns:
the name pool in which all the names used in this document are registered

getDocumentNumber

public int getDocumentNumber()
Get the unique document number

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

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
Returns:
the base URI of the node

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

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

getInputEncoding

public java.lang.String getInputEncoding()
The following methods are defined in DOM Level 3, and Saxon includes nominal implementations of these methods so that the code will compile when DOM Level 3 interfaces are installed.


getXmlEncoding

public java.lang.String getXmlEncoding()

getXmlStandalone

public boolean getXmlStandalone()

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
                      throws org.w3c.dom.DOMException
org.w3c.dom.DOMException

getXmlVersion

public java.lang.String getXmlVersion()

setXmlVersion

public void setXmlVersion(java.lang.String xmlVersion)
                   throws org.w3c.dom.DOMException
org.w3c.dom.DOMException

getStrictErrorChecking

public boolean getStrictErrorChecking()

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)

getDocumentURI

public java.lang.String getDocumentURI()

setDocumentURI

public void setDocumentURI(java.lang.String documentURI)

adoptNode

public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)
                           throws org.w3c.dom.DOMException
org.w3c.dom.DOMException

normalizeDocument

public void normalizeDocument()

renameNode

public org.w3c.dom.Node renameNode(org.w3c.dom.Node n,
                                   java.lang.String namespaceURI,
                                   java.lang.String qualifiedName)
                            throws org.w3c.dom.DOMException
org.w3c.dom.DOMException

copy

public void copy(Receiver out,
                 int whichNamespaces)
          throws XPathException
Copy this node to a given outputter

Specified by:
copy in class NodeImpl
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 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 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 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

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.

Specified by:
getStringValue in interface NodeInfo
Specified by:
getStringValue in class AbstractNode
Returns:
the accumulated character content of the element, including descendant elements.

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


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