Class TinyDocumentImpl
java.lang.Object
com.icl.saxon.om.AbstractNode
com.icl.saxon.tinytree.TinyNodeImpl
com.icl.saxon.tinytree.TinyParentNodeImpl
com.icl.saxon.tinytree.TinyDocumentImpl
- All Implemented Interfaces:
DocumentInfo, NodeInfo, DOMLocator, Source, SourceLocator, Document, Node
A node in the XML parse tree representing the Document itself (or equivalently, the root
node of the Document).
- Version:
- 26 April 1999
- Author:
- Michael H. Kay
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[]protected int[]protected String[]protected char[]protected intprotected StringBufferprotected short[]protected intprotected int[]protected int[]protected int[]protected int[]protected int[]protected byte[]protected intprotected intprotected intprotected int[]protected int[]Fields inherited from class TinyNodeImpl
document, nodeNr, parentFields inherited from class AbstractNode
NODE_LETTERFields inherited from interface Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAttribute(int parent0, int code0, String type0, String value0) protected voidaddNamespace(int parent0, int nscode0) protected voidaddNode(short type0, int depth0, int offset0, int length0, int nameCode0) Attempts to adopt a node from another document to this document.protected voidappendChars(char[] chars, int start, int length) voidCopy this node to a given outputtervoidProduce diagnostic print of main tree arraysprotected voidprotected voidprotected voidprotected voidOn demand, make an index for quick access to preceding-sibling nodesGet a character string that uniquely identifies this node within the documentprotected AxisEnumerationgetAllElements(int fingerprint) Get a list of all elements with a given name.protected TinyAttributeImplgetAttributeNode(int nr) Make a (transient) attribute node from the array of attributesGet the base URI of this root node.Get the root (document) nodeThe location of the document ornullif undefined or if theDocumentwas created usingDOMImplementation.createDocument.The configuration used whenDocument.normalizeDocument()is invoked.An attribute specifying the encoding used for this document at the time of the parsing.getKeyIndex(KeyManager keymanager, int fingerprint) Get the index for a given keyintGet the line number of this root node.protected intgetLineNumber(int sequence) Get the line number for an element.Get the name pool used for the names in this documentprotected TinyNamespaceImplgetNamespaceNode(int nr) Make a (transient) namespace node from the array of namespace declarationsgetNode(int nr) final shortReturn the type of node.Find the parent node of this node.longGet the node sequence number (in document order).booleanAn attribute specifying whether error checking is enforced or not.Get the system id of this root nodeprotected StringgetSystemId(int seq) Get the system id of an element in the documentgetUnparsedEntity(String name) Get the unparsed entity with a given nameAn attribute specifying, as part of the XML declaration, the encoding of this document.booleanAn attribute specifying, as part of the XML declaration, whether this document is standalone.An attribute specifying, as part of the XML declaration, the version number of this document.protected booleandetermine whether this document uses namespacesvoidThis method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.renameNode(Node n, String namespaceURI, String qualifiedName) Rename an existing node of typeELEMENT_NODEorATTRIBUTE_NODE.Get the element with a given ID.voidsetDocumentURI(String documentURI) The location of the document ornullif undefined or if theDocumentwas created usingDOMImplementation.createDocument.voidsetKeyIndex(KeyManager keymanager, int fingerprint, Hashtable keyindex) Set the index for a given key.protected voidsetLineNumber(int sequence, int line) Set the line number for an element.voidSet line numbering onvoidsetNamePool(NamePool pool) Set the name pool used for all names in this documentvoidsetStrictErrorChecking(boolean strictErrorChecking) An attribute specifying whether error checking is enforced or not.protected voidsetSystemId(int seq, String uri) Set the system id of an element in the documentvoidsetSystemId(String uri) Set the system id of this nodeprotected voidsetUnparsedEntity(String name, String uri) Set an unparsed entity URI associated with this document.voidsetXmlStandalone(boolean xmlStandalone) An attribute specifying, as part of the XML declaration, whether this document is standalone.voidsetXmlVersion(String xmlVersion) An attribute specifying, as part of the XML declaration, the version number of this document.protected voidtruncate(int nodes) Truncate the tree: used in preview mode to delete an element after it has been processedMethods inherited from class TinyParentNodeImpl
copyStringValue, getStringValue, hasChildNodesMethods inherited from class TinyNodeImpl
compareOrder, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getOriginatingNode, getPrefix, getURI, hasAttributes, isSameNodeInfo, outputNamespaceNodes, setLineNumber, setParentNodeMethods inherited from class AbstractNode
appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getFirstChild, getImplementation, getLastChild, getLength, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getUserData, getValue, getWholeText, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, replaceWholeText, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supportsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Document
createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, importNodeMethods inherited from interface Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserDataMethods inherited from interface NodeInfo
compareOrder, copyStringValue, getAttributeValue, getAttributeValue, getDisplayName, getEnumeration, getFingerprint, getLocalName, getNameCode, getPrefix, getStringValue, getURI, hasChildNodes, isSameNodeInfo, outputNamespaceNodes
-
Field Details
-
charBuffer
protected char[] charBuffer -
charBufferLength
protected int charBufferLength -
commentBuffer
-
numberOfNodes
protected int numberOfNodes -
lastLevelOneNode
protected int lastLevelOneNode -
nodeType
protected byte[] nodeType -
depth
protected short[] depth -
next
protected int[] next -
offset
protected int[] offset -
length
protected int[] length -
nameCode
protected int[] nameCode -
prior
protected int[] prior -
numberOfAttributes
protected int numberOfAttributes -
attParent
protected int[] attParent -
attCode
protected int[] attCode -
attValue
-
numberOfNamespaces
protected int numberOfNamespaces -
namespaceParent
protected int[] namespaceParent -
namespaceCode
protected int[] namespaceCode
-
-
Constructor Details
-
TinyDocumentImpl
public TinyDocumentImpl()
-
-
Method Details
-
setNamePool
Set the name pool used for all names in this document- Specified by:
setNamePoolin interfaceDocumentInfo
-
getNamePool
Get the name pool used for the names in this document- Specified by:
getNamePoolin interfaceDocumentInfo
-
ensureNodeCapacity
protected void ensureNodeCapacity() -
ensureAttributeCapacity
protected void ensureAttributeCapacity() -
ensureNamespaceCapacity
protected void ensureNamespaceCapacity() -
addNode
protected void addNode(short type0, int depth0, int offset0, int length0, int nameCode0) -
appendChars
protected void appendChars(char[] chars, int start, int length) -
truncate
protected void truncate(int nodes) Truncate the tree: used in preview mode to delete an element after it has been processed -
ensurePriorIndex
protected void ensurePriorIndex()On demand, make an index for quick access to preceding-sibling nodes -
addAttribute
-
addNamespace
protected void addNamespace(int parent0, int nscode0) -
getNode
-
getSequenceNumber
public long getSequenceNumber()Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive.- Overrides:
getSequenceNumberin classTinyNodeImpl
-
getAttributeNode
Make a (transient) attribute node from the array of attributes -
isUsingNamespaces
protected boolean isUsingNamespaces()determine whether this document uses namespaces -
getNamespaceNode
Make a (transient) namespace node from the array of namespace declarations -
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. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.
-
getBaseURI
Get the base URI of this root node. For a root node the base URI is the same as the System ID.- Specified by:
getBaseURIin interfaceNode- Specified by:
getBaseURIin interfaceNodeInfo- Overrides:
getBaseURIin classTinyNodeImpl
-
setSystemId
Set the system id of an element in the document -
getSystemId
Get the system id of an element in the document -
setLineNumbering
public void setLineNumbering()Set line numbering on -
setLineNumber
protected void setLineNumber(int sequence, int line) Set the line number for an element. Ignored if line numbering is off. -
getLineNumber
protected int getLineNumber(int sequence) Get the line number for an element. Return -1 if line numbering is off. -
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
-
getNodeType
public final short getNodeType()Return the type of node.- Specified by:
getNodeTypein interfaceNode- Specified by:
getNodeTypein interfaceNodeInfo- Returns:
- NodeInfo.ROOT (always)
-
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.
-
getDocumentRoot
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classTinyNodeImpl- Returns:
- the DocumentInfo representing this document
-
generateId
Get a character string that uniquely identifies this node within the document- Specified by:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classTinyNodeImpl- Returns:
- the empty string
-
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. -
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()- Returns:
- The NodeInfo (always an Element) for the given ID if one has been registered, otherwise null.
-
getKeyIndex
Get the index for a given key- Specified by:
getKeyIndexin interfaceDocumentInfo- Parameters:
keymanager- The key manager managing this keyfingerprint- The fingerprint of the name of the key (unique with the key manager)- Returns:
- The index, if one has been built, in the form of a Hashtable that maps the key value to a set of nodes having that key value. If no index has been built, returns null.
-
setKeyIndex
Set the index for a given key. The method is synchronized because the same document can be used by several stylesheets at the same time.- Specified by:
setKeyIndexin interfaceDocumentInfo- Parameters:
keymanager- The key manager managing this keyfingerprint- The fingerprint of the name of the key (unique with the key manager)keyindex- the index, in the form of a Hashtable that maps the key value to a set of nodes having that key value. Or the String "under construction", indicating that the index is being built.
-
setUnparsedEntity
-
getUnparsedEntity
Get the unparsed entity with a given name- Specified by:
getUnparsedEntityin interfaceDocumentInfo- Parameters:
name- the name of the entity- Returns:
- the URI of the entity if there is one, or empty string if not
-
copy
Copy this node to a given outputter- Specified by:
copyin interfaceNodeInfo- Throws:
TransformerException
-
diagnosticDump
public void diagnosticDump()Produce diagnostic print of main tree arrays -
adoptNode
Attempts to adopt a node from another document to this document.- Specified by:
adoptNodein interfaceDocument- Parameters:
source- The node to move into this document.- Returns:
- The adopted node, or
nullif this operation fails, such as when the source node comes from a different implementation. - Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if the source node is of typeDOCUMENT,DOCUMENT_TYPE.
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly.- Since:
- DOM Level 3
-
getDocumentURI
The location of the document ornullif undefined or if theDocumentwas created usingDOMImplementation.createDocument. No lexical checking is performed when setting this attribute; this could result in anullvalue returned when usingNode.baseURI.
Beware that when theDocumentsupports the feature "HTML" [DOM Level 2 HTML] , the href attribute of the HTML BASE element takes precedence over this attribute when computingNode.baseURI.- Specified by:
getDocumentURIin interfaceDocument- Since:
- DOM Level 3
-
getDomConfig
The configuration used whenDocument.normalizeDocument()is invoked.- Specified by:
getDomConfigin interfaceDocument- Since:
- DOM Level 3
-
getInputEncoding
An attribute specifying the encoding used for this document at the time of the parsing. This isnullwhen it is not known, such as when theDocumentwas created in memory.- Specified by:
getInputEncodingin interfaceDocument- Since:
- DOM Level 3
-
getStrictErrorChecking
public boolean getStrictErrorChecking()An attribute specifying whether error checking is enforced or not. When set tofalse, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise anyDOMExceptionon DOM operations or report errors while usingDocument.normalizeDocument(). In case of error, the behavior is undefined. This attribute istrueby default.- Specified by:
getStrictErrorCheckingin interfaceDocument- Since:
- DOM Level 3
-
getXmlEncoding
An attribute specifying, as part of the XML declaration, the encoding of this document. This isnullwhen unspecified or when it is not known, such as when theDocumentwas created in memory.- Specified by:
getXmlEncodingin interfaceDocument- Since:
- DOM Level 3
-
getXmlStandalone
public boolean getXmlStandalone()An attribute specifying, as part of the XML declaration, whether this document is standalone. This isfalsewhen unspecified.Note: No verification is done on the value when setting this attribute. Applications should use
Document.normalizeDocument()with the "validate" parameter to verify if the value matches the validity constraint for standalone document declaration as defined in [XML 1.0].- Specified by:
getXmlStandalonein interfaceDocument- Since:
- DOM Level 3
-
getXmlVersion
An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is"1.0".- Specified by:
getXmlVersionin interfaceDocument- Since:
- DOM Level 3
-
normalizeDocument
public void normalizeDocument()This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.- Specified by:
normalizeDocumentin interfaceDocument- Since:
- DOM Level 3
-
renameNode
Rename an existing node of typeELEMENT_NODEorATTRIBUTE_NODE.- Specified by:
renameNodein interfaceDocument- Parameters:
n- The node to rename.namespaceURI- The new namespace URI.qualifiedName- The new qualified name.- Returns:
- The renamed node. This is either the specified node or the new node that was created to replace the specified node.
- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised when the type of the specified node is neitherELEMENT_NODEnorATTRIBUTE_NODE, or if the implementation does not support the renaming of the document element.
INVALID_CHARACTER_ERR: Raised if the new qualified name is not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
WRONG_DOCUMENT_ERR: Raised when the specified node was created from a different document than this document.
NAMESPACE_ERR: Raised if thequalifiedNameis a malformed qualified name, if thequalifiedNamehas a prefix and thenamespaceURIisnull, or if thequalifiedNamehas a prefix that is "xml" and thenamespaceURIis different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces] . Also raised, when the node being renamed is an attribute, if thequalifiedName, or its prefix, is "xmlns" and thenamespaceURIis different from "http://www.w3.org/2000/xmlns/".- Since:
- DOM Level 3
-
setDocumentURI
The location of the document ornullif undefined or if theDocumentwas created usingDOMImplementation.createDocument. No lexical checking is performed when setting this attribute; this could result in anullvalue returned when usingNode.baseURI.
Beware that when theDocumentsupports the feature "HTML" [DOM Level 2 HTML] , the href attribute of the HTML BASE element takes precedence over this attribute when computingNode.baseURI.- Specified by:
setDocumentURIin interfaceDocument- Since:
- DOM Level 3
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking) An attribute specifying whether error checking is enforced or not. When set tofalse, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise anyDOMExceptionon DOM operations or report errors while usingDocument.normalizeDocument(). In case of error, the behavior is undefined. This attribute istrueby default.- Specified by:
setStrictErrorCheckingin interfaceDocument- Since:
- DOM Level 3
-
setXmlStandalone
An attribute specifying, as part of the XML declaration, whether this document is standalone. This isfalsewhen unspecified.Note: No verification is done on the value when setting this attribute. Applications should use
Document.normalizeDocument()with the "validate" parameter to verify if the value matches the validity constraint for standalone document declaration as defined in [XML 1.0].- Specified by:
setXmlStandalonein interfaceDocument- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if this document does not support the "XML" feature.- Since:
- DOM Level 3
-
setXmlVersion
An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is"1.0". If this document does not support the "XML" feature, the value is alwaysnull. Changing this attribute will affect methods that check for invalid characters in XML names. Application should invokeDocument.normalizeDocument()in order to check for invalid characters in theNodes that are already part of thisDocument.
DOM applications may use theDOMImplementation.hasFeature(feature, version)method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports [XML 1.0]. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports [XML 1.1]. In both cases, in order to support XML, an implementation must also support the "XML" feature defined in this specification.Documentobjects supporting a version of the "XMLVersion" feature must not raise aNOT_SUPPORTED_ERRexception for the same version number when usingDocument.xmlVersion.- Specified by:
setXmlVersionin interfaceDocument- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if the version is set to a value that is not supported by thisDocumentor if this document does not support the "XML" feature.- Since:
- DOM Level 3
-