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,PullEvent,DocumentInfo,FingerprintedNode,Item<NodeInfo>,MutableDocumentInfo,MutableNodeInfo,NodeInfo,ValueRepresentation<NodeInfo>,SiblingCountingNode
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.
- Author:
- Michael H. Kay
-
Field Summary
Fields inherited from class net.sf.saxon.tree.linked.NodeImpl
NODE_LETTERFields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACESFields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCopy this node to a given outputtervoidRemove a node from any indexes when it is detached from the treeprotected voidderegisterID(String id) Remove the entry for a given ID (when nodes are deleted).voidgenerateId(FastStringBuffer buffer) Get a character string that uniquely identifies this node(package private) AxisIteratorgetAllElements(int fingerprint) Get a list of all elements with a given name fingerprintGet the base URI of this root node.(package private) intgetColumnNumber(int sequence) Get the column number for an element.Get the configuration previously set using setConfigurationGet the root (outermost) element.longGet the unique document numberGet the root (document) nodeintGet the line number of this root node.(package private) intgetLineNumber(int sequence) Get the line number for an element.Get the name pool used for the names in this documentfinal NodeInfoGet next sibling - always nullfinal intReturn the type of node.Get the physical root of the tree.final NodeInfoGet previous sibling - always nullgetRoot()Get the root nodeGet the type annotationGet the system id of this root node(package private) StringgetSystemId(int seq) Get the system id of an element in the documentintGet the type annotation of this node, if any.String[]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.voidgraftLocationMap(DocumentImpl original) Copy the system ID and line number map from another document (used when grafting a simplified stylesheet)booleanAsk whether this is an imaginary document nodebooleanisTyped()Ask whether the document contains any nodes whose type annotation is anything other than UNTYPEDGet a Builder suitable for building nodes that can be attached to this document.protected voidregisterID(NodeInfo e, String id) Register a unique element ID.voidreplaceStringValue(CharSequence stringValue) Replace the string-value of this nodevoidThis 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.voidsetBaseURI(String uri) Set the base URI of this document nodevoidsetConfiguration(Configuration config) Set the Configuration that contains this document(package private) voidSet the top-level element of the document (variously called the root element or the document element).voidsetImaginary(boolean imaginary) Set whether this is an imaginary document node(package private) voidsetLineAndColumn(int sequence, int line, int column) Set the line number for an element.voidSet line numbering on(package private) voidsetSystemId(int seq, String uri) Set the system id of an element in the documentvoidsetSystemId(String uri) Set the system id (base URI) of this node(package private) voidsetUnparsedEntity(String name, String uri, String publicId) Set an unparsed entity URI associated with this document.voidsetUserData(String key, Object value) Set user data on the document node.Methods inherited from class net.sf.saxon.tree.linked.ParentNodeImpl
addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNthChild, getNumberOfChildren, getRawSequenceNumber, getSequenceNumber, getStringValue, getStringValueCS, hasChildNodes, insertChildren, insertChildrenAt, removeChild, replaceChildrenAt, setChildren, setRawSequenceNumberMethods inherited from class net.sf.saxon.tree.linked.NodeImpl
addAttribute, addNamespace, atomize, compareOrder, delete, equals, getAttributeValue, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getNextInDocument, getParent, getPrefix, getPreviousInDocument, getPublicId, getRawParent, getSiblingPosition, getTypedValue, getURI, insertSiblings, isDeleted, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis, removeAttribute, removeTypeAnnotation, rename, replace, setRawParent, setSiblingPosition, setTypeAnnotationMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.om.Item
getStringValueCS, getTypedValueMethods inherited from interface net.sf.saxon.om.NodeInfo
atomize, compareOrder, equals, getAttributeValue, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getFingerprint, getLocalPart, getNameCode, getParent, getPrefix, getStringValue, getURI, hasChildNodes, hashCode, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis
-
Constructor Details
-
DocumentImpl
public DocumentImpl()Create a DocumentImpl
-
-
Method Details
-
setConfiguration
Set the Configuration that contains this document- Parameters:
config- the Saxon configuration
-
getConfiguration
Get the configuration previously set using setConfiguration- Specified by:
getConfigurationin interfaceNodeInfo- Overrides:
getConfigurationin classNodeImpl- Returns:
- the Saxon configuration
-
getNamePool
Get the name pool used for the names in this document- Specified by:
getNamePoolin interfaceNodeInfo- Overrides:
getNamePoolin classNodeImpl- Returns:
- the namepool
-
newBuilder
Get a Builder suitable for building nodes that can be attached to this document.- Specified by:
newBuilderin interfaceMutableNodeInfo- Overrides:
newBuilderin 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- Specified by:
isTypedin interfaceDocumentInfo- Returns:
- true if the document contains elements whose type is other than UNTYPED
-
getDocumentNumber
public long getDocumentNumber()Get the unique document number- Specified by:
getDocumentNumberin interfaceNodeInfo- Overrides:
getDocumentNumberin classNodeImpl- Returns:
- the document number of the document containing this node
-
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:
setSystemIdin interfaceSource- Overrides:
setSystemIdin classNodeImpl
-
getSystemId
Get the system id of this root node- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfaceSource- Specified by:
getSystemIdin interfaceSourceLocator- Overrides:
getSystemIdin 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:
getBaseURIin interfaceNodeInfo- Overrides:
getBaseURIin classNodeImpl- Returns:
- the base URI
-
setSystemId
Set the system id of an element in the document- Parameters:
seq- the sequence number of the elementuri- the system identifier (base URI) of the element
-
getSystemId
Get the system id of an element in the document- Parameters:
seq- the sequence number of the element- Returns:
- the systemId (base URI) of the element
-
setLineNumbering
public void setLineNumbering()Set line numbering on -
setLineAndColumn
void setLineAndColumn(int sequence, int line, int column) Set the line number for an element. Ignored if line numbering is off.- Parameters:
sequence- the sequence number of the elementline- the line number of the elementcolumn- the column number of the element
-
getLineNumber
int getLineNumber(int sequence) Get the line number for an element.- Parameters:
sequence- the sequence number of the element- Returns:
- the line number for an element. Return -1 if line numbering is off, or if the element was added subsequent to document creation by use of XQuery update
-
getColumnNumber
int getColumnNumber(int sequence) Get the column number for an element.- Parameters:
sequence- the sequence number of the element- Returns:
- the column number for an element. Return -1 if line numbering is off, or if the element was added subsequent to document creation by use of XQuery update
-
getLineNumber
public int getLineNumber()Get the line number of this root node.- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfaceSourceLocator- Overrides:
getLineNumberin classNodeImpl- Returns:
- 0 always
-
getNodeKind
public final int getNodeKind()Return the type of node.- Specified by:
getNodeKindin interfaceNodeInfo- Returns:
- Type.DOCUMENT (always)
- See Also:
-
getNextSibling
Get next sibling - always null- Overrides:
getNextSiblingin classNodeImpl- Returns:
- null
-
getPreviousSibling
Get previous sibling - always null- Overrides:
getPreviousSiblingin classNodeImpl- Returns:
- null
-
getDocumentElement
Get the root (outermost) element.- Returns:
- the Element node for the outermost element of the document.
-
getRoot
Get the root node -
getDocumentRoot
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classNodeImpl- Returns:
- the DocumentInfo representing this document
-
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:
getPhysicalRootin classNodeImpl- Returns:
- the document node, which may be imaginary
-
generateId
Get a character string that uniquely identifies this node- Specified by:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classNodeImpl- Parameters:
buffer- a buffer into which will be placed a string based on the document number
-
getAllElements
Get a list of all elements with a given name fingerprint- Parameters:
fingerprint- the fingerprint of the required element name- Returns:
- an iterator over all the elements with this name
-
deIndex
Remove a node from any indexes when it is detached from the tree- Parameters:
node- the node to be removed from all indexes
-
registerID
Register a unique element ID. Does nothing if there is already an element with that ID.- Parameters:
e- The Element having a particular unique ID valueid- The unique ID value
-
selectID
Get the element with a given ID.- Specified by:
selectIDin interfaceDocumentInfo- 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.
-
deregisterID
Remove the entry for a given ID (when nodes are deleted). Does nothing if the id value is not present in the index.- Parameters:
id- The id value
-
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:
getUnparsedEntityNamesin interfaceDocumentInfo- 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:
getUnparsedEntityin interfaceDocumentInfo- 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.
-
getTypeAnnotation
public int getTypeAnnotation()Get the type annotation of this node, if any. By convention for a document node this is XS_ANY_TYPE if the document is validated, or XS_UNTYPED otherwise- Specified by:
getTypeAnnotationin interfaceNodeInfo- Overrides:
getTypeAnnotationin classNodeImpl- Returns:
- the type annotation, as the integer name code of the type name
-
getSchemaType
Get the type annotation- Specified by:
getSchemaTypein interfaceNodeInfo- Overrides:
getSchemaTypein classNodeImpl- Returns:
- the type annotation of the base node
-
copy
Copy this node to a given outputter- Specified by:
copyin 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 inCopyOptionslocationId- If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information- Throws:
XPathException- if any downstream error occurs
-
replaceStringValue
Replace the string-value of this node- Specified by:
replaceStringValuein 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:
resetIndexesin interfaceMutableDocumentInfo
-
setUserData
Set user data on the document node. The user data can be retrieved subsequently usinggetUserData(java.lang.String)- Specified by:
setUserDatain interfaceDocumentInfo- 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:
getUserDatain interfaceDocumentInfo- 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.
-