net.sf.saxon.tinytree

Class TinyDocumentImpl

public final class TinyDocumentImpl extends TinyParentNodeImpl implements DocumentInfo

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

Constructor Summary
TinyDocumentImpl(TinyTree tree)
Method Summary
Valueatomize()
Get the typed value.
voidcopy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
Copy this node to a given outputter
voidgenerateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node
AxisIteratorgetAllElements(int fingerprint)
Get a list of all elements with a given name.
StringgetBaseURI()
Get the base URI of this root node.
ConfigurationgetConfiguration()
Get the configuration previously set using setConfiguration
DocumentInfogetDocumentRoot()
Get the root (document) node
ListgetElementList(int fingerprint)
Get a list containing all the elements with a given element name
intgetLineNumber()
Get the line number of this root node.
intgetNodeKind()
Return the type of node.
NodeInfogetParent()
Find the parent node of this node.
NodeInfogetRoot()
Get the root node
StringgetSystemId()
Get the system id of this root node
TinyTreegetTree()
Get the tree containing this node
intgetTypeAnnotation()
Get the type annotation of this node, if any.
SequenceIteratorgetTypedValue()
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.
Iterator<String>getUnparsedEntityNames()
Get the list of unparsed entities defined in this document
voidregisterID(NodeInfo e, String id)
Register a unique element ID.
NodeInfoselectID(String id, boolean getParent)
Get the element with a given ID.
voidsetBaseURI(String uri)
Set the base URI of this document node
voidsetConfiguration(Configuration config)
Set the Configuration that contains this document
voidsetSystemId(String uri)
Set the system id of this node
voidsetUnparsedEntity(String name, String uri, String publicId)
Set an unparsed entity URI associated with this document.
voidshowSize()

Constructor Detail

TinyDocumentImpl

public TinyDocumentImpl(TinyTree tree)

Method Detail

atomize

public Value atomize()
Get the typed value. The result of this method will always be consistent with the method 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.

Returns: the typed value. This will either be a single AtomicValue or a Value whose items are atomic values.

Since: 8.5

copy

public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
Copy this node to a given outputter

generateId

public void generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node

Parameters: buffer to contain an identifier based on the document number

getAllElements

AxisIterator getAllElements(int fingerprint)
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.

getBaseURI

public String getBaseURI()
Get the base URI of this root node.

getConfiguration

public Configuration getConfiguration()
Get the configuration previously set using setConfiguration

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root (document) node

Returns: the DocumentInfo representing the document node, or null if the root of the tree is not a document node

getElementList

List getElementList(int fingerprint)
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

getLineNumber

public int getLineNumber()
Get the line number of this root node.

Returns: 0 always

getNodeKind

public final int getNodeKind()
Return the type of node.

Returns: Type.DOCUMENT (always)

getParent

public NodeInfo getParent()
Find the parent node of this node.

Returns: The Node object describing the containing element or root node.

getRoot

public NodeInfo getRoot()
Get the root node

Returns: the NodeInfo that is the root of the tree - not necessarily a document node

getSystemId

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

getTree

public TinyTree getTree()
Get the tree containing this node

getTypeAnnotation

public int getTypeAnnotation()
Get the type annotation of this node, if any.

Returns: XS_UNTYPED if no validation has been done, XS_ANY_TYPE if the document has been validated

getTypedValue

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

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: net.sf.saxon.trans.XPathException where no typed value is available, for example in the case of an element with complex content

Since: 8.4

getUnparsedEntity

public String[] getUnparsedEntity(String name)
Get the unparsed entity with a given nameID if there is one, or null if not. If the entity does not exist, return null.

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

getUnparsedEntityNames

public Iterator<String> getUnparsedEntityNames()
Get the list of unparsed entities defined in this document

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

registerID

void registerID(NodeInfo e, String id)
Register a unique element ID. Fails if there is already an element with that ID.

Parameters: e The NodeInfo (always an element) having a particular unique ID value id The unique ID value. The caller is responsible for checking that this is a valid NCName.

selectID

public NodeInfo selectID(String id, boolean getParent)
Get the element with a given ID.

Parameters: id The unique ID of the required element, previously registered using registerID() getParent

Returns: The NodeInfo (always an Element) for the given ID if one has been registered, otherwise null.

setBaseURI

public void setBaseURI(String uri)
Set the base URI of this document node

setConfiguration

public void setConfiguration(Configuration config)
Set the Configuration that contains this document

setSystemId

public void setSystemId(String uri)
Set the system id of this node

setUnparsedEntity

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.

showSize

public void showSize()