com.saxonica.pull
Class UnconstructedDocument

java.lang.Object
  extended by com.saxonica.pull.UnconstructedParent
      extended by com.saxonica.pull.UnconstructedDocument
All Implemented Interfaces:
Source, PullEvent, DocumentInfo, Item<NodeInfo>, NodeInfo, ValueRepresentation<NodeInfo>

public class UnconstructedDocument
extends UnconstructedParent
implements DocumentInfo

A document node whose construction is deferred.

(TODO) NOTE: this class is an exception to the general rule that for document nodes, node identity implies object identity


Field Summary
 
Fields inherited from class com.saxonica.pull.UnconstructedParent
instruction, node, savedXPathContext
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Constructor Summary
UnconstructedDocument(DocumentInstr instruction, XPathContext context)
          Create an unconstructed (pending) document node
 
Method Summary
 String getDisplayName()
          Get the display name of this node.
 DocumentInfo getDocumentRoot()
          Get the root node, if it is a document node.
 int getFingerprint()
          Get fingerprint.
 String getLocalPart()
          Get the local part of the name of this node.
 int getNameCode()
          Get name code.
 int getNodeKind()
          Get the kind of node.
 String getPrefix()
          Get the prefix of the name of the node.
 String[] getUnparsedEntity(String name)
          Get the unparsed entity with a given name
 Iterator<String> getUnparsedEntityNames()
          Get the list of unparsed entities defined in this document
 String getURI()
          Get the URI part of the name of this node.
 Object getUserData(String key)
          Get user data held in the document node.
 boolean isTyped()
          Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED
 NodeInfo selectID(String id, boolean getParent)
          Get the element with a given ID, if any
 void setUserData(String key, Object value)
          Set user data on the document node.
 
Methods inherited from class com.saxonica.pull.UnconstructedParent
atomize, compareOrder, copy, equals, generateId, getAttributeValue, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDocumentNumber, getInstruction, getLineNumber, getNamePool, getParent, getPuller, getRoot, getSchemaType, getStringValue, getStringValueCS, getSystemId, getTypeAnnotation, getTypedValue, getXPathContext, hasChildNodes, hashCode, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis, setSystemId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.NodeInfo
atomize, compareOrder, copy, equals, generateId, getAttributeValue, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDocumentNumber, getLineNumber, getNamePool, getParent, getRoot, getSchemaType, getStringValue, getSystemId, getTypeAnnotation, hasChildNodes, hashCode, isId, isIdref, isNilled, isSameNodeInfo, iterateAxis, iterateAxis
 
Methods inherited from interface javax.xml.transform.Source
setSystemId
 
Methods inherited from interface net.sf.saxon.om.Item
getStringValueCS, getTypedValue
 

Constructor Detail

UnconstructedDocument

public UnconstructedDocument(DocumentInstr instruction,
                             XPathContext context)
Create an unconstructed (pending) document node

Parameters:
instruction - the instruction responsible for creating the node
context - the XPath dynamic context
Method Detail

getNameCode

public int getNameCode()
Get name code. The name code is a coded form of the node name: two nodes with the same name code have the same namespace URI, the same local name, and the same prefix. By masking the name code with &0xfffff, you get a fingerprint: two nodes with the same fingerprint have the same local name and namespace URI.

Specified by:
getNameCode in interface NodeInfo
Returns:
an integer name code, which may be used to obtain the actual node name from the name pool
See Also:
allocate, getFingerprint

getNodeKind

public int getNodeKind()
Description copied from interface: NodeInfo
Get the kind of node. This will be a value such as Type.ELEMENT or Type.ATTRIBUTE. There are seven kinds of node: documents, elements, attributes, text, comments, processing-instructions, and namespaces.

Specified by:
getNodeKind in interface NodeInfo
Returns:
an integer identifying the kind of node. These integer values are the same as those used in the DOM
See Also:
Type

isTyped

public boolean isTyped()
Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED

Specified by:
isTyped in interface DocumentInfo
Returns:
true if the document contains elements whose type is other than UNTYPED

getFingerprint

public int getFingerprint()
Get fingerprint. The fingerprint is a coded form of the expanded name of the node: two nodes with the same name code have the same namespace URI and the same local name. A fingerprint of -1 should be returned for a node with no name.

Specified by:
getFingerprint in interface NodeInfo
Overrides:
getFingerprint in class UnconstructedParent
Returns:
an integer fingerprint; two nodes with the same fingerprint have the same expanded QName

getLocalPart

public String getLocalPart()
Get the local part of the name of this node. This is the name after the ":" if any.

Specified by:
getLocalPart in interface NodeInfo
Overrides:
getLocalPart in class UnconstructedParent
Returns:
the local part of the name. For an unnamed node, returns "". Unlike the DOM interface, this returns the full name in the case of a non-namespaced name.

getURI

public String getURI()
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.

Specified by:
getURI in interface NodeInfo
Overrides:
getURI in class UnconstructedParent
Returns:
The URI of the namespace of this node. For an unnamed node, or for a node with an empty prefix, return an empty string.

getDisplayName

public String getDisplayName()
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.

Specified by:
getDisplayName in interface NodeInfo
Overrides:
getDisplayName in class UnconstructedParent
Returns:
The display name of this node. For a node with no name, return an empty string.

getPrefix

public String getPrefix()
Get the prefix of the name of the node. This is defined only for elements and attributes. If the node has no prefix, or for other kinds of node, return a zero-length string.

Specified by:
getPrefix in interface NodeInfo
Overrides:
getPrefix in class UnconstructedParent
Returns:
The prefix of the name of the node.

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root node, if it is a document node.

Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class UnconstructedParent
Returns:
the DocumentInfo representing the containing document. If this node is part of a tree that does not have a document node as its root, return null.

selectID

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

Specified by:
selectID in interface DocumentInfo
Parameters:
id - the required ID value
getParent -
Returns:
the element with the given ID, or null if there is no such ID present (or if the parser has not notified attributes as being of type ID)
Since:
8.4

getUnparsedEntityNames

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

Specified by:
getUnparsedEntityNames in interface DocumentInfo
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

public String[] getUnparsedEntity(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, the method returns null. Applications should be written on the assumption that this array may be extended in the future to provide additional information.
Since:
8.4

setUserData

public void setUserData(String key,
                        Object value)
Set user data on the document node. The user data can be retrieved subsequently using getUserData(java.lang.String)

Specified by:
setUserData in interface DocumentInfo
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

public Object getUserData(String key)
Get user data held in the document node. This retrieves properties previously set using setUserData(java.lang.String, java.lang.Object)

Specified by:
getUserData in interface DocumentInfo
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.


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.