Package net.sf.saxon.tree.linked
Class DocumentImpl
java.lang.Object
net.sf.saxon.tree.linked.NodeImpl
net.sf.saxon.tree.linked.ParentNodeImpl
net.sf.saxon.tree.linked.DocumentImpl
- All Implemented Interfaces:
Source
,SourceLocator
,ActiveSource
,GroundedValue
,Item
,MutableDocumentInfo
,MutableNodeInfo
,NodeInfo
,Sequence
,TreeInfo
,Location
,SteppingNode
,SiblingCountingNode
,Locator
A node in the XML parse tree representing the Document itself (or equivalently, the root
node of the Document).
A DocumentImpl object may either represent a real document node, or it may represent an imaginary container for a parentless element.
-
Field Summary
Fields inherited from class net.sf.saxon.tree.linked.NodeImpl
NODE_LETTER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNilledElement
(ElementImpl element) Add a nilled element.void
Copy this node to a given outputtervoid
Remove a node from any indexes when it is detached from the treevoid
generateId
(StringBuilder buffer) Get a character string that uniquely identifies this nodeGet the base URI of this root node.Get the configuration previously set using setConfigurationGet the root (outermost) element.long
Get the unique document numberGet the durability of nodes in the tree.int
Get the line number of this root node.Get the name pool used for the names in this documentfinal NodeImpl
Get next sibling - always nullfinal int
Return the type of node.Get the physical root of the tree.final NodeImpl
Get previous sibling - always nullgetRoot()
Get the root nodeGet the NodeInfo object representing the document node at the root of the treeGet the type annotationGet details of space stripping action that was applied to this document during construction.Get the system id of this root nodeString[]
getUnparsedEntity
(String name) Get the unparsed entity with a given nameGet the list of unparsed entities defined in this documentgetUserData
(String key) Get user data held in the document node.void
graftLocationMap
(DocumentImpl original) Copy the system ID and line number map from another document (used when grafting a simplified stylesheet)boolean
Ask whether this is an imaginary document nodeboolean
Ask whether the tree is mutable.boolean
isTopWithinEntity
(ElementImpl element) boolean
isTyped()
Ask whether the document contains any nodes whose type annotation is anything other than UNTYPEDvoid
markTopWithinEntity
(ElementImpl element) Get a Builder suitable for building nodes that can be attached to this document.void
replaceStringValue
(UnicodeString stringValue) Replace the string-value of this nodevoid
This method is called before performing a batch of updates; it allows all cached data that might be invalidated by such updates to be clearedGet the element with a given ID.void
setBaseURI
(String uri) Set the base URI of this document nodevoid
setConfiguration
(Configuration config) Set the Configuration that contains this documentvoid
Set the top-level element of the document (variously called the root element or the document element).void
setImaginary
(boolean imaginary) Set whether this is an imaginary document nodevoid
Set line numbering onvoid
setMutable
(boolean mutable) Say whether the tree is mutable.void
Set details of space stripping action that was applied to this document during construction.void
setSystemId
(String uri) Set the system id (base URI) of this nodevoid
setUnparsedEntity
(String name, String uri, String publicId) Set an unparsed entity URI associated with this document.void
setUserData
(String key, Object value) Set user data on the document node.Methods inherited from class net.sf.saxon.tree.linked.ParentNodeImpl
addChild, compact, getFirstChild, getLastChild, getNthChild, getNumberOfChildren, getRawSequenceNumber, getSequenceNumber, getUnicodeStringValue, hasChildNodes, insertChildren, insertChildrenAt, iterateChildren, removeChild, replaceChildrenAt, setChildren, setRawSequenceNumber
Methods inherited from class net.sf.saxon.tree.linked.NodeImpl
addAttribute, addNamespace, atomize, attributes, compareOrder, delete, effectiveBooleanValue, equals, getAllNamespaces, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNamespaceUri, getNextInDocument, getNodeName, getParent, getPrefix, getPreviousInDocument, getRawParent, getSiblingPosition, getSuccessorElement, getTreeInfo, hasFingerprint, hashCode, head, insertSiblings, isDeleted, iterateAxis, iterateAxis, removeAttribute, removeTypeAnnotation, rename, replace, saveLocation, setAttributes, setRawParent, setSiblingPosition, setTypeAnnotation
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.MutableNodeInfo
addNamespace, removeNamespace
Methods inherited from interface net.sf.saxon.om.NodeInfo
asActiveSource, children, children, deliver, getAttributeValue, getGenre, getPublicId, getURI, isId, isIdref, isNilled, isSameNodeInfo, isStreamed, toShortString
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
DocumentImpl
public DocumentImpl()Create a DocumentImpl
-
-
Method Details
-
getRootNode
Get the NodeInfo object representing the document node at the root of the tree- Specified by:
getRootNode
in interfaceTreeInfo
- Returns:
- the document node
-
setConfiguration
Set the Configuration that contains this document- Parameters:
config
- the Saxon configuration
-
getConfiguration
Get the configuration previously set using setConfiguration- Specified by:
getConfiguration
in interfaceNodeInfo
- Specified by:
getConfiguration
in interfaceTreeInfo
- Overrides:
getConfiguration
in classNodeImpl
- Returns:
- the Saxon configuration
-
isMutable
public boolean isMutable()Ask whether the tree is mutable. This is true only ifsetMutable(boolean)
has been called supplying the valuetrue
-
getDurability
Get the durability of nodes in the tree. This affects how they are handled in a memo function cache, to optimize memory and garbage collection. By default, all nodes are considered durable unless otherwise specified- Specified by:
getDurability
in interfaceTreeInfo
- Returns:
- the durability property of this node tree
-
setMutable
public void setMutable(boolean mutable) Say whether the tree is mutable.- Parameters:
mutable
- true if and only if the tree is to be marked as mutable
-
getNamePool
Get the name pool used for the names in this document- Overrides:
getNamePool
in classNodeImpl
- Returns:
- the namePool for the configuration owning this node
-
newBuilder
Get a Builder suitable for building nodes that can be attached to this document.- Specified by:
newBuilder
in interfaceMutableNodeInfo
- Overrides:
newBuilder
in classNodeImpl
- Returns:
- a new TreeBuilder
-
setImaginary
public void setImaginary(boolean imaginary) Set whether this is an imaginary document node- Parameters:
imaginary
- if true, this is an imaginary node - the tree is really rooted at the topmost element
-
isImaginary
public boolean isImaginary()Ask whether this is an imaginary document node- Returns:
- true if this is an imaginary node - the tree is really rooted at the topmost element
-
isTyped
public boolean isTyped()Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED -
getDocumentNumber
public long getDocumentNumber()Get the unique document number- Specified by:
getDocumentNumber
in interfaceTreeInfo
- Returns:
- the document number
-
setDocumentElement
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
-
graftLocationMap
Copy the system ID and line number map from another document (used when grafting a simplified stylesheet)- Parameters:
original
- the document whose system ID and line number maps are to be grafted onto this tree
-
setSystemId
Set the system id (base URI) of this node- Specified by:
setSystemId
in interfaceNodeInfo
- Specified by:
setSystemId
in interfaceSource
- Overrides:
setSystemId
in classNodeImpl
-
getSystemId
Get the system id of this root node- Specified by:
getSystemId
in interfaceLocation
- Specified by:
getSystemId
in interfaceLocator
- Specified by:
getSystemId
in interfaceNodeInfo
- Specified by:
getSystemId
in interfaceSource
- Specified by:
getSystemId
in interfaceSourceLocator
- Overrides:
getSystemId
in classNodeImpl
- Returns:
- the System Identifier of the entity in the source document containing the node, or null if not known or not applicable.
-
setBaseURI
Set the base URI of this document node- Parameters:
uri
- the new base URI
-
getBaseURI
Get the base URI of this root node.- Specified by:
getBaseURI
in interfaceNodeInfo
- Overrides:
getBaseURI
in classNodeImpl
- Returns:
- the base URI
-
setLineNumbering
public void setLineNumbering()Set line numbering on -
addNilledElement
Add a nilled element. Nilled elements are unusual, so we avoid allocating a boolean in the element node; instead we keep a list of nilled elements at the document level- Parameters:
element
- a nilled element
-
markTopWithinEntity
-
isTopWithinEntity
-
getLineNumber
public int getLineNumber()Get the line number of this root node.- Specified by:
getLineNumber
in interfaceLocation
- Specified by:
getLineNumber
in interfaceLocator
- Specified by:
getLineNumber
in interfaceNodeInfo
- Specified by:
getLineNumber
in interfaceSourceLocator
- Overrides:
getLineNumber
in classNodeImpl
- Returns:
- 0 always
-
getNodeKind
public final int getNodeKind()Return the type of node.- Specified by:
getNodeKind
in interfaceNodeInfo
- Returns:
- Type.DOCUMENT (always)
- See Also:
-
getNextSibling
Get next sibling - always null- Specified by:
getNextSibling
in interfaceSteppingNode
- Overrides:
getNextSibling
in classNodeImpl
- Returns:
- null
-
getPreviousSibling
Get previous sibling - always null- Specified by:
getPreviousSibling
in interfaceSteppingNode
- Overrides:
getPreviousSibling
in classNodeImpl
- Returns:
- null
-
getDocumentElement
Get the root (outermost) element.- Returns:
- the Element node for the outermost element of the document. May return null if the document node contains no element node.
-
getRoot
Get the root node -
getPhysicalRoot
Get the physical root of the tree. This may be an imaginary document node: this method should be used only when control information held at the physical root is required- Overrides:
getPhysicalRoot
in classNodeImpl
- Returns:
- the document node, which may be imaginary
-
generateId
Get a character string that uniquely identifies this node- Specified by:
generateId
in interfaceNodeInfo
- Overrides:
generateId
in classNodeImpl
- Parameters:
buffer
- a buffer into which will be placed a string based on the document number
-
deIndex
Remove a node from any indexes when it is detached from the tree- Parameters:
node
- the node to be removed from all indexes
-
selectID
Get the element with a given ID.- Specified by:
selectID
in interfaceTreeInfo
- Parameters:
id
- The unique ID of the required element, previously registered using registerID()getParent
- true if the requirement is for the parent of the node with the given ID, not the node itself.- Returns:
- The NodeInfo for the given ID if one has been registered, otherwise null.
-
setUnparsedEntity
Set an unparsed entity URI associated with this document. For system use only, while building the document.- Parameters:
name
- the entity nameuri
- the system identifier of the unparsed entitypublicId
- the public identifier of the unparsed entity
-
getUnparsedEntityNames
Get the list of unparsed entities defined in this document- Specified by:
getUnparsedEntityNames
in interfaceTreeInfo
- Returns:
- an Iterator, whose items are of type String, containing the names of all unparsed entities defined in this document. If there are no unparsed entities or if the information is not available then an empty iterator is returned
-
getUnparsedEntity
Get the unparsed entity with a given name- Specified by:
getUnparsedEntity
in interfaceTreeInfo
- 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.
-
getSchemaType
Get the type annotation- Specified by:
getSchemaType
in interfaceNodeInfo
- Overrides:
getSchemaType
in classNodeImpl
- Returns:
- the type annotation of the base node
-
copy
Copy this node to a given outputter- Specified by:
copy
in interfaceNodeInfo
- Parameters:
out
- the Receiver to which the node should be copied. It is the caller's responsibility to ensure that this Receiver is open before the method is called (or that it is self-opening), and that it is closed after use.copyOptions
- a selection of the options defined inCopyOptions
locationId
- If non-null, identifies the location of the instruction that requested this copy. If null, indicates that the location information is not available- Throws:
XPathException
- if any downstream error occurs
-
replaceStringValue
Replace the string-value of this node- Specified by:
replaceStringValue
in interfaceMutableNodeInfo
- Parameters:
stringValue
- the new string value
-
resetIndexes
public void resetIndexes()This method is called before performing a batch of updates; it allows all cached data that might be invalidated by such updates to be cleared- Specified by:
resetIndexes
in interfaceMutableDocumentInfo
-
setSpaceStrippingRule
Set details of space stripping action that was applied to this document during construction. This ensures that space stripping is not applied twice to the same document.- Specified by:
setSpaceStrippingRule
in interfaceTreeInfo
- Parameters:
rule
- details of the space stripping rules that have been applied to this document during its construction.- Since:
- 9.9
-
getSpaceStrippingRule
Get details of space stripping action that was applied to this document during construction. This ensures that space stripping is not applied twice to the same document.- Specified by:
getSpaceStrippingRule
in interfaceTreeInfo
- Returns:
- details of the space stripping rules that have been applied to this
document during its construction. By default, returns
NoElementsSpaceStrippingRule
, indicating that no space stripping has been applied - Since:
- 9.9
-
setUserData
Set user data on the document node. The user data can be retrieved subsequently usinggetUserData(java.lang.String)
- Specified by:
setUserData
in interfaceTreeInfo
- Parameters:
key
- A string giving the name of the property to be set. Clients are responsible for choosing a key that is likely to be unique. Must not be null. Keys used internally by Saxon are prefixed "saxon:".value
- The value to be set for the property. May be null, which effectively removes the existing value for the property.
-
getUserData
Get user data held in the document node. This retrieves properties previously set usingsetUserData(java.lang.String, java.lang.Object)
- Specified by:
getUserData
in interfaceTreeInfo
- Parameters:
key
- A string giving the name of the property to be retrieved.- Returns:
- the value of the property, or null if the property has not been defined.
-