com.icl.saxon.tree

Class DocumentImpl

public final class DocumentImpl extends ParentNodeImpl implements DocumentInfo, Document

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

Author: Michael H. Kay

Constructor Summary
DocumentImpl()
Method Summary
NodeadoptNode(Node source)
Attempts to adopt a node from another document to this document.
voidcopy(Outputter out)
Copy this node to a given outputter
StringgenerateId()
Get a character string that uniquely identifies this node within the document
protected AxisEnumerationgetAllElements(int fingerprint)
Get a list of all elements with a given name fingerprint
StringgetBaseURI()
Get the base URI of this root node.
StringBuffergetCharacterBuffer()
Get the character buffer
ElementgetDocumentElement()
Get the root (outermost) element.
DocumentInfogetDocumentRoot()
Get the root (document) node
StringgetDocumentURI()
The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.
DOMConfigurationgetDomConfig()
The configuration used when Document.normalizeDocument() is invoked.
StringgetInputEncoding()
An attribute specifying the encoding used for this document at the time of the parsing.
HashtablegetKeyIndex(KeyManager keymanager, int fingerprint)
Get the index for a given key
protected intgetLineNumber(int sequence)
Get the line number for an element.
intgetLineNumber()
Get the line number of this root node.
NamePoolgetNamePool()
Get the name pool used for the names in this document
NodegetNextSibling()
Get next sibling - always null
NodeFactorygetNodeFactory()
Get the node factory that was used to build this document
shortgetNodeType()
Return the type of node.
NodegetPreviousSibling()
Get previous sibling - always null
booleangetStrictErrorChecking()
An attribute specifying whether error checking is enforced or not.
StringgetSystemId()
Get the system id of this root node
protected StringgetSystemId(int seq)
Get the system id of an element in the document
StringgetUnparsedEntity(String name)
Get the unparsed entity with a given name
StringgetXmlEncoding()
An attribute specifying, as part of the XML declaration, the encoding of this document.
booleangetXmlStandalone()
An attribute specifying, as part of the XML declaration, whether this document is standalone.
StringgetXmlVersion()
An attribute specifying, as part of the XML declaration, the version number of this document.
voidnormalizeDocument()
This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.
NoderenameNode(Node n, String namespaceURI, String qualifiedName)
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.
NodeInfoselectID(String id)
Get the element with a given ID.
protected voidsetCharacterBuffer(StringBuffer buffer)
Set the character buffer
protected voidsetDocumentElement(ElementImpl e)
Set the top-level element of the document (variously called the root element or the document element).
voidsetDocumentURI(String documentURI)
The location of the document or null if undefined or if the Document was created using DOMImplementation.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.
voidsetLineNumbering()
Set line numbering on
voidsetNamePool(NamePool pool)
Set the name pool used for all names in this document
voidsetNodeFactory(NodeFactory factory)
Set the node factory that was used to build this document
voidsetStrictErrorChecking(boolean strictErrorChecking)
An attribute specifying whether error checking is enforced or not.
voidsetSystemId(String uri)
Set the system id of this node
protected voidsetSystemId(int seq, String uri)
Set the system id of an element in the document
protected 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.

Constructor Detail

DocumentImpl

public DocumentImpl()

Method Detail

adoptNode

public Node adoptNode(Node source)
Attempts to adopt a node from another document to this document.

Parameters: source The node to move into this document.

Returns: The adopted node, or null if this operation fails, such as when the source node comes from a different implementation.

Throws: org.w3c.dom.DOMException NOT_SUPPORTED_ERR: Raised if the source node is of type DOCUMENT, DOCUMENT_TYPE.
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly.

Since: DOM Level 3

copy

public void copy(Outputter out)
Copy this node to a given outputter

generateId

public String generateId()
Get a character string that uniquely identifies this node within the document

Returns: the empty string

getAllElements

protected AxisEnumeration getAllElements(int fingerprint)
Get a list of all elements with a given name fingerprint

getBaseURI

public String getBaseURI()
Get the base URI of this root node. For a root node the base URI is the same as the System ID.

getCharacterBuffer

public final StringBuffer getCharacterBuffer()
Get the character buffer

getDocumentElement

public Element getDocumentElement()
Get the root (outermost) element.

Returns: the Element node for the outermost element of the document.

getDocumentRoot

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

Returns: the DocumentInfo representing this document

getDocumentURI

public String getDocumentURI()
The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument. No lexical checking is performed when setting this attribute; this could result in a null value returned when using Node.baseURI .
Beware that when the Document supports the feature "HTML" [DOM Level 2 HTML] , the href attribute of the HTML BASE element takes precedence over this attribute when computing Node.baseURI.

Since: DOM Level 3

getDomConfig

public DOMConfiguration getDomConfig()
The configuration used when Document.normalizeDocument() is invoked.

Since: DOM Level 3

getInputEncoding

public String getInputEncoding()
An attribute specifying the encoding used for this document at the time of the parsing. This is null when it is not known, such as when the Document was created in memory.

Since: DOM Level 3

getKeyIndex

public Hashtable getKeyIndex(KeyManager keymanager, int fingerprint)
Get the index for a given key

Parameters: keymanager The key manager managing this key fingerprint 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 Vector of nodes having that key value. If no index has been built, returns null.

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.

Returns: 0 always

getNamePool

public NamePool getNamePool()
Get the name pool used for the names in this document

getNextSibling

public final Node getNextSibling()
Get next sibling - always null

Returns: null

getNodeFactory

public NodeFactory getNodeFactory()
Get the node factory that was used to build this document

getNodeType

public final short getNodeType()
Return the type of node.

Returns: NodeInfo.ROOT (always)

getPreviousSibling

public final Node getPreviousSibling()
Get previous sibling - always null

Returns: null

getStrictErrorChecking

public boolean getStrictErrorChecking()
An attribute specifying whether error checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException on DOM operations or report errors while using Document.normalizeDocument(). In case of error, the behavior is undefined. This attribute is true by default.

Since: DOM Level 3

getSystemId

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

getSystemId

protected String getSystemId(int seq)
Get the system id of an element in the document

getUnparsedEntity

public String getUnparsedEntity(String name)
Get the unparsed entity with a given name

Parameters: name the name of the entity

Returns: the URI of the entity if there is one, or empty string if not

getXmlEncoding

public String getXmlEncoding()
An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified or when it is not known, such as when the Document was created in memory.

Since: DOM Level 3

getXmlStandalone

public boolean getXmlStandalone()
An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when 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].

Since: DOM Level 3

getXmlVersion

public String 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".

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.

Since: DOM Level 3

renameNode

public Node renameNode(Node n, String namespaceURI, String qualifiedName)
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.

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: org.w3c.dom.DOMException NOT_SUPPORTED_ERR: Raised when the type of the specified node is neither ELEMENT_NODE nor ATTRIBUTE_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 the Document.xmlVersion attribute.
WRONG_DOCUMENT_ERR: Raised when the specified node was created from a different document than this document.
NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces] . Also raised, when the node being renamed is an attribute, if the qualifiedName, or its prefix, is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".

Since: DOM Level 3

selectID

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

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

Returns: The NodeInfo for the given ID if one has been registered, otherwise null.

setCharacterBuffer

protected void setCharacterBuffer(StringBuffer buffer)
Set the character buffer

setDocumentElement

protected void setDocumentElement(ElementImpl e)
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

setDocumentURI

public void setDocumentURI(String documentURI)
The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument. No lexical checking is performed when setting this attribute; this could result in a null value returned when using Node.baseURI .
Beware that when the Document supports the feature "HTML" [DOM Level 2 HTML] , the href attribute of the HTML BASE element takes precedence over this attribute when computing Node.baseURI.

Since: DOM Level 3

setKeyIndex

public void setKeyIndex(KeyManager keymanager, int fingerprint, Hashtable keyindex)
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.

Parameters: keymanager The key manager managing this key fingerprint 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 Vector of nodes having that key value. Or the String "under construction", indicating that the index is being built.

setLineNumber

protected void setLineNumber(int sequence, int line)
Set the line number for an element. Ignored if line numbering is off.

setLineNumbering

public void setLineNumbering()
Set line numbering on

setNamePool

public void setNamePool(NamePool pool)
Set the name pool used for all names in this document

setNodeFactory

public void setNodeFactory(NodeFactory factory)
Set the node factory that was used to build this document

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
An attribute specifying whether error checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException on DOM operations or report errors while using Document.normalizeDocument(). In case of error, the behavior is undefined. This attribute is true by default.

Since: DOM Level 3

setSystemId

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

setSystemId

protected void setSystemId(int seq, String uri)
Set the system id of an element in the document

setUnparsedEntity

protected void setUnparsedEntity(String name, String uri)
Set an unparsed entity URI associated with this document. For system use only, while building the document.

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when 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].

Throws: org.w3c.dom.DOMException NOT_SUPPORTED_ERR: Raised if this document does not support the "XML" feature.

Since: DOM Level 3

setXmlVersion

public void setXmlVersion(String xmlVersion)
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 always null. Changing this attribute will affect methods that check for invalid characters in XML names. Application should invoke Document.normalizeDocument() in order to check for invalid characters in the Nodes that are already part of this Document.
DOM applications may use the DOMImplementation.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. Document objects supporting a version of the "XMLVersion" feature must not raise a NOT_SUPPORTED_ERR exception for the same version number when using Document.xmlVersion.

Throws: org.w3c.dom.DOMException NOT_SUPPORTED_ERR: Raised if the version is set to a value that is not supported by this Document or if this document does not support the "XML" feature.

Since: DOM Level 3