Class TinyDocumentImpl
java.lang.Object
net.sf.saxon.tree.tiny.TinyNodeImpl
net.sf.saxon.tree.tiny.TinyParentNodeImpl
net.sf.saxon.tree.tiny.TinyDocumentImpl
- All Implemented Interfaces:
Source, SourceLocator, PullEvent, DocumentInfo, FingerprintedNode, Item<NodeInfo>, NodeInfo, ValueRepresentation<NodeInfo>
A node in the XML parse tree representing the Document itself (or equivalently, the root
node of the Document).
-
Field Summary
Fields inherited from class TinyNodeImpl
NODE_LETTER, nodeNr, parent, treeFields inherited from interface NodeInfo
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACESFields inherited from interface ValueRepresentation
EMPTY_VALUE_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionValue<? extends AtomicValue> atomize()Get the typed value.voidCopy this node to a given outputtervoidgenerateId(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.Get the base URI of this root node.Get the configuration previously set using setConfigurationGet the root (document) node(package private) List<TinyElementImpl> getElementList(int fingerprint) Get a list containing all the elements with a given element nameintGet the line number of this root node.final intReturn the type of node.Find the parent node of this node.getRoot()Get the root nodeGet the type annotation of this node, if any.Get the system id of this root nodegetTree()Get the tree containing this nodeintGet the type annotation of this node, if any.SequenceIterator<? extends AtomicValue> Get the typed value of the item.String[]getUnparsedEntity(String name) Get the unparsed entity with a given nameID if there is one, or null if not.Get the list of unparsed entities defined in this documentgetUserData(String key) Get user data held in the document node.inthashCode()The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()booleanisTyped()Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED(package private) voidregisterID(NodeInfo e, String id) Register a unique element ID.Get the element with a given ID.voidsetBaseURI(String uri) Set the base URI of this document nodevoidsetSystemId(String uri) Set the system id 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.voidshowSize()Methods inherited from class TinyParentNodeImpl
getStringValue, getStringValueCS, getStringValueCS, hasChildNodesMethods inherited from class TinyNodeImpl
compareOrder, equals, getAttributeValue, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNameCode, getNamePool, getNodeNumber, getParentNodeNr, getPrefix, getPublicId, getSequenceNumber, getURI, isAncestorOrSelf, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis, setParentNodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Item
getStringValueCSMethods inherited from interface NodeInfo
compareOrder, equals, getAttributeValue, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNameCode, getNamePool, getPrefix, getStringValue, getURI, hasChildNodes, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis
-
Constructor Details
-
TinyDocumentImpl
-
-
Method Details
-
getTree
Get the tree containing this node- Overrides:
getTreein classTinyNodeImpl- Returns:
- the TinyTree. Note that this may also contain other unrelated trees
-
getConfiguration
Get the configuration previously set using setConfiguration- Specified by:
getConfigurationin interfaceNodeInfo- Overrides:
getConfigurationin classTinyNodeImpl- Returns:
- the Configuration
-
setSystemId
Set the system id of this node- Specified by:
setSystemIdin interfaceSource- Overrides:
setSystemIdin classTinyNodeImpl
-
getSystemId
Get the system id of this root node- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfaceSource- Specified by:
getSystemIdin interfaceSourceLocator- Overrides:
getSystemIdin classTinyNodeImpl- 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 base URI
-
getBaseURI
Get the base URI of this root node.- Specified by:
getBaseURIin interfaceNodeInfo- Overrides:
getBaseURIin classTinyNodeImpl- Returns:
- the base URI of the node. This may be null if the base URI is unknown, including the case where the node has no parent.
-
getLineNumber
public int getLineNumber()Get the line number of this root node.- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfaceSourceLocator- Overrides:
getLineNumberin classTinyNodeImpl- Returns:
- 0 always
-
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
-
getNodeKind
public final int getNodeKind()Return the type of node.- Specified by:
getNodeKindin interfaceNodeInfo- Returns:
- Type.DOCUMENT (always)
- See Also:
-
getParent
Find the parent node of this node.- Specified by:
getParentin interfaceNodeInfo- Overrides:
getParentin classTinyNodeImpl- Returns:
- The Node object describing the containing element or root node.
-
getRoot
Get the root node- Specified by:
getRootin interfaceNodeInfo- Overrides:
getRootin classTinyNodeImpl- Returns:
- the NodeInfo that is the root of the tree - not necessarily a document node
-
getDocumentRoot
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classTinyNodeImpl- Returns:
- the DocumentInfo representing the document node, or null if the root of the tree is not a document node
-
generateId
Get a character string that uniquely identifies this node- Specified by:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classTinyNodeImpl- Parameters:
buffer- to contain an identifier based on the document number
-
atomize
Get the typed value. The result of this method will always be consistent with the methodItem.getTypedValue(). However, this method is often more convenient and may be more efficient, especially in the common case where the value is expected to be a singleton.- Specified by:
atomizein interfaceNodeInfo- Returns:
- the typed value. This will either be a single AtomicValue or a Value whose items are atomic values.
- Throws:
XPathException- if the node has no typed value, for example if it is an element node with element-only content- Since:
- 8.5
-
getTypedValue
Get the typed value of the item. For a node, this is the typed value as defined in the XPath 2.0 data model. Since a node may have a list-valued data type, the typed value is in general a sequence, and it is returned in the form of a SequenceIterator. If the node has not been validated against a schema, the typed value will be the same as the string value, either as an instance of xs:string or as an instance of xs:untypedAtomic, depending on the node kind. For an atomic value, this method returns an iterator over a singleton sequence containing the atomic value itself.- Specified by:
getTypedValuein interfaceItem<NodeInfo>- Returns:
- an iterator over the items in the typed value of the node or atomic value. The items returned by this iterator will always be atomic values.
- Throws:
XPathException- where no typed value is available, for example in the case of an element with complex content- Since:
- 8.4
-
getAllElements
Get a list of all elements with a given name. This is implemented as a memo function: the first time it is called for a particular element type, it remembers the result for next time.- Parameters:
fingerprint- the fingerprint identifying the required element name- Returns:
- an iterator over all elements with this name
-
getElementList
Get a list containing all the elements with a given element name- Parameters:
fingerprint- the fingerprint of the element name- Returns:
- list a List containing the TinyElementImpl objects
-
registerID
-
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 required element is the parent of the element of type ID- Returns:
- The NodeInfo (always an Element) 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 name of the unparsed entityuri- 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 nameID if there is one, or null if not. If the entity does not exist, return null.- 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
-
getTypeAnnotation
public int getTypeAnnotation()Get the type annotation of this node, if any.- Specified by:
getTypeAnnotationin interfaceNodeInfo- Overrides:
getTypeAnnotationin classTinyNodeImpl- Returns:
- XS_UNTYPED if no validation has been done, XS_ANY_TYPE if the document has been validated
-
getSchemaType
Get the type annotation of this node, if any. The type annotation is represented as SchemaType object.Types derived from a DTD are not reflected in the result of this method.
- Specified by:
getSchemaTypein interfaceNodeInfo- Overrides:
getSchemaTypein classTinyNodeImpl- Returns:
- For element and attribute nodes: the type annotation derived from schema validation (defaulting to xs:untyped and xs:untypedAtomic in the absence of schema validation). For comments, text nodes, processing instructions, and namespaces: null. For document nodes, either xs:untyped if the document has not been validated, or xs:anyType if it has.
- Since:
- 9.4
-
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
-
showSize
public void showSize() -
hashCode
public int hashCode()The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()- Specified by:
hashCodein interfaceNodeInfo- Overrides:
hashCodein classTinyNodeImpl- Since:
- 8.7 Previously, the effect of the equals() and hashCode() methods was not defined. Callers should therefore be aware that third party implementations of the NodeInfo interface may not implement the correct semantics.
-
setUserData
Set user data on the document node. The user data can be retrieved subsequently usinggetUserData(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(String, 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.
-