com.icl.saxon.tree
Class DocumentImpl

java.lang.Object
  |
  +--com.icl.saxon.tree.NodeImpl
        |
        +--com.icl.saxon.tree.ParentNodeImpl
              |
              +--com.icl.saxon.tree.DocumentImpl
All Implemented Interfaces:
org.w3c.dom.Document, DocumentInfo, org.w3c.dom.DOMImplementation, org.w3c.dom.Node, NodeInfo

public class DocumentImpl
extends com.icl.saxon.tree.ParentNodeImpl
implements DocumentInfo, org.w3c.dom.Document, org.w3c.dom.DOMImplementation

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


Field Summary
protected static NodeInfo[] emptyArray
           
protected static SingletonEnumeration emptyEnumeration
           
protected  int index
           
protected  com.icl.saxon.tree.ParentNodeImpl parent
           
protected  int sequence
           
 
Fields inherited from interface com.icl.saxon.om.NodeInfo
ATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NODE_TYPE_NAMES, NONE, NUMBER_OF_TYPES, PI, ROOT, TEXT
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
DocumentImpl(int docNr)
           
 
Method Summary
 void addChild(com.icl.saxon.tree.NodeImpl node, int index)
          Add a child node to this node.
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 org.w3c.dom.Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 void compact(int size)
          Compact the space used by this node
 void copy(Outputter out)
          Copy this node to a given outputter
 void copyStringValue(Outputter out)
          Copy the string-value of this node to a given outputter
 org.w3c.dom.Attr createAttribute(java.lang.String name)
          Creates an Attr of the given name.
 org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Creates an attribute of the given qualified name and namespace URI.
 org.w3c.dom.CDATASection createCDATASection(java.lang.String data)
          Creates a CDATASection node whose value is the specified string.
 org.w3c.dom.Comment createComment(java.lang.String data)
          Creates a Comment node given the specified string.
 org.w3c.dom.Document createDocument(java.lang.String namespaceURI, java.lang.String qualifiedName, org.w3c.dom.DocumentType doctype)
          Creates an XML Document object of the specified type with its document element.
 org.w3c.dom.DocumentFragment createDocumentFragment()
          Creates an empty DocumentFragment object.
 org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId)
          Creates an empty DocumentType node.
 org.w3c.dom.Element createElement(java.lang.String tagName)
          Creates an element of the type specified.
 org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Creates an element of the given qualified name and namespace URI.
 org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
          Creates an EntityReference object.
 org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          Creates a ProcessingInstruction node given the specified name and data strings.
 org.w3c.dom.Text createTextNode(java.lang.String data)
          Creates a Text node given the specified string.
 void defaultAction(Context c)
          Perform default action for this kind of node (built-in template rule)
protected  void disallowUpdate()
          Internal method used to indicate that update operations are not allowed
 void dropChildren()
          Drop a branch of the tree.
 NodeEnumeration enumerateChildren()
          Get an enumeration of the children of this node
 NodeInfo[] getAllChildNodes()
          Get all child nodes of the element (child elements and character nodes).
 NodeSetValue getAllElements(int fingerprint)
          Get a list of all elements with a given name fingerprint
 org.w3c.dom.NamedNodeMap getAttributes()
          Return a NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise.
 java.lang.String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 java.lang.String getAttributeValue(java.lang.String name)
          Find the value of a given attribute of this node.
 java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)
          Find the value of a given attribute of this node.
protected  java.lang.String getBaseURI(int seq)
          Get the system id of an element in the document
 java.lang.StringBuffer getCharacterBuffer()
          Get the character buffer
 org.w3c.dom.NodeList getChildNodes()
          Return a NodeList that contains all children of this node.
 java.lang.String getDisplayName()
          Get the display name of this node.
 org.w3c.dom.DocumentType getDoctype()
          The Document Type Declaration (see DocumentType ) associated with this document.
 org.w3c.dom.Element getDocumentElement()
          Get the root (outermost) element.
 int getDocumentNumber()
          Get a unique number identifying this document
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 org.w3c.dom.Element getElementById(java.lang.String elementId)
          Returns the Element whose ID is given by elementId .
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)
          Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
 PreparedStyleSheet getEmbeddedStylesheet(java.lang.String id)
          Prepare an embedded stylesheet within this document
 int getFingerprint()
          Get the fingerprint of the node.
 org.w3c.dom.Node getFirstChild()
          Get the first child node of the element
 org.w3c.dom.DOMImplementation getImplementation()
          The DOMImplementation object that handles this document.
 int getIndex()
          Get the index of this node, i.e.
 java.util.Hashtable getKeyIndex(KeyManager keymanager, int fingerprint)
          Get the index for a given key
 org.w3c.dom.Node getLastChild()
          Get the last child node of the element
 int getLineNumber()
          Get the line number of this root node.
protected  int getLineNumber(int sequence)
          Get the line number for an element.
 java.lang.String getLocalName()
          Get the local name of this node.
 int getNameCode()
          Get the nameCode of the node.
 NamePool getNamePool()
          Get the name pool used for the names in this document
 java.lang.String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 NodeInfo getNextInDocument(NodeInfo anchor)
          Get the next node in document order
 org.w3c.dom.Node getNextSibling()
          Get next sibling - always null
 NodeFactory getNodeFactory()
          Get the node factory that was used to build this document
 java.lang.String getNodeName()
          Get the name of this node, following the DOM rules
 short getNodeType()
          Return the type of node.
 java.lang.String getNodeValue()
          Get the node value as defined in the DOM.
protected  NodeInfo getNthChild(int n)
          Get the nth child node of the element (numbering from 0)
 int getNumberOfChildren()
          Get the number of children.
 org.w3c.dom.Document getOwnerDocument()
          Return the Document object associated with this node.
 org.w3c.dom.Node getParentNode()
          Find the parent node of this node.
 java.lang.String getPath()
          Generate a path to this node
 java.lang.String getPrefix()
          Get the prefix part of the name of this node.
 NodeInfo getPreviousInDocument()
          Get the previous node in document order
 org.w3c.dom.Node getPreviousSibling()
          Get previous sibling - always null
 java.lang.String getPublicId()
          Get the public identifier of the document entity containing this node.
 long getSequenceNumber()
          Get the node sequence number (in document order).
 java.lang.String getSequentialKey()
          Get a character string that uniquely identifies this node
 java.lang.String getSystemId()
          Get the system id of this node
 java.lang.String getUnparsedEntity(java.lang.String name)
          Get the unparsed entity with a given name
 java.lang.String getURI()
          Get the URI part of the name of this node.
 short getURICode()
          Get URI code.
 java.lang.String getValue()
          Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          Determine whether the node has any children.
 boolean hasFeature(java.lang.String feature, java.lang.String version)
          Test if the DOM implementation implements a specific feature.
 org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)
          Imports a node from another document to this document.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Insert the node newChild before the existing child node refChild.
 boolean isa(int nodeType)
          Determine whether the node is of a given type.
 boolean isDocumentElement()
          Determine whether this node is the outermost element.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 boolean isSupported(java.lang.String feature, java.lang.String version)
          Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
 void normalize()
          Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
 void removeChild(int index)
          Remove node at given index.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Remove the child node indicated by oldChild from the list of children, and returns it.
 void removeNode()
          Remove this node from the tree.
 void renumberChildren()
          Renumber the children of a given parent node.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replace the child node oldChild with newChild in the list of children, and returns the oldChild node.
 ElementInfo selectID(java.lang.String id)
          Get the element with a given ID.
protected  void setBaseURI(int seq, java.lang.String uri)
          Set the system id of an element in the document
protected  void setCharacterBuffer(java.lang.StringBuffer buffer)
          Set the character buffer
protected  void setDocumentElement(ElementInfo e)
          Set the top-level element of the document (variously called the root element or the document element).
 void setKeyIndex(KeyManager keymanager, int fingerprint, java.lang.Object keyindex)
          Set the index for a given key.
protected  void setLineNumber(int sequence, int line)
          Set the line number for an element.
 void setLineNumbering()
          Set line numbering on
 void setNamePool(NamePool pool)
          Set the name pool used for all names in this document
 void setNodeFactory(NodeFactory factory)
          Set the node factory that was used to build this document
 void setNodeValue(java.lang.String nodeValue)
          Set the node value.
 void setPrefix(java.lang.String prefix)
          Set the namespace prefix of this node.
protected  void setSystemId(java.lang.String uri)
          Set the system id of this node
protected  void setUnparsedEntity(java.lang.String name, java.lang.String uri)
          Set an unparsed entity URI associated with this document.
 java.lang.String toString()
          Diagnostic string representation
 void useChildrenArray(com.icl.saxon.tree.NodeImpl[] array)
          Supply an array to be used for the array of children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.icl.saxon.om.NodeInfo
copyStringValue, defaultAction, enumerateChildren, getAllChildNodes, getAttributeValue, getAttributeValue, getAttributeValue, getDisplayName, getFingerprint, getIndex, getLocalName, getNameCode, getNextInDocument, getNumberOfChildren, getPrefix, getPreviousInDocument, getSequenceNumber, getURI, getURICode, getValue, isDocumentElement, isSameNode
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getNamespaceURI, getNodeValue, getOwnerDocument, getParentNode, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

sequence

protected int sequence

emptyArray

protected static NodeInfo[] emptyArray

emptyEnumeration

protected static SingletonEnumeration emptyEnumeration

parent

protected com.icl.saxon.tree.ParentNodeImpl parent

index

protected int index
Constructor Detail

DocumentImpl

public DocumentImpl(int docNr)
Method Detail

setCharacterBuffer

protected void setCharacterBuffer(java.lang.StringBuffer buffer)
Set the character buffer

getCharacterBuffer

public final java.lang.StringBuffer getCharacterBuffer()
Get the character buffer

setNamePool

public void setNamePool(NamePool pool)
Set the name pool used for all names in this document
Specified by:
setNamePool in interface DocumentInfo

getNamePool

public NamePool getNamePool()
Get the name pool used for the names in this document
Specified by:
getNamePool in interface DocumentInfo
Overrides:
getNamePool in class com.icl.saxon.tree.NodeImpl

setNodeFactory

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

getNodeFactory

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

setDocumentElement

protected void setDocumentElement(ElementInfo 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

setSystemId

protected void setSystemId(java.lang.String uri)
Set the system id of this node

getSystemId

public java.lang.String getSystemId()
Get the system id of this node
Specified by:
getSystemId in interface NodeInfo
Overrides:
getSystemId in class com.icl.saxon.tree.NodeImpl
Following copied from interface: com.icl.saxon.om.NodeInfo
Returns:
the System Identifier of the entity in the source document containing the node, or null if not known

setBaseURI

protected void setBaseURI(int seq,
                          java.lang.String uri)
Set the system id of an element in the document

getBaseURI

protected java.lang.String getBaseURI(int seq)
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:
getLineNumber in interface NodeInfo
Overrides:
getLineNumber in class com.icl.saxon.tree.NodeImpl
Returns:
0 always

getNodeType

public final short getNodeType()
Return the type of node.
Specified by:
getNodeType in interface NodeInfo
Returns:
NodeInfo.ROOT (always)

getNodeName

public final java.lang.String getNodeName()
Get the name of this node, following the DOM rules
Specified by:
getNodeName in interface NodeInfo
Overrides:
getNodeName in class com.icl.saxon.tree.NodeImpl
Returns:
"#document"

getNextSibling

public final org.w3c.dom.Node getNextSibling()
Get next sibling - always null
Specified by:
getNextSibling in interface org.w3c.dom.Node
Overrides:
getNextSibling in class com.icl.saxon.tree.NodeImpl
Returns:
null

getPreviousSibling

public final org.w3c.dom.Node getPreviousSibling()
Get previous sibling - always null
Specified by:
getPreviousSibling in interface org.w3c.dom.Node
Overrides:
getPreviousSibling in class com.icl.saxon.tree.NodeImpl
Returns:
null

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Get the root (outermost) element.
Specified by:
getDocumentElement in interface NodeInfo
Overrides:
getDocumentElement in class com.icl.saxon.tree.NodeImpl
Returns:
the ElementInfo for the outermost element of the document.

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root (document) node
Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class com.icl.saxon.tree.NodeImpl
Returns:
the DocumentInfo representing this document

getSequentialKey

public java.lang.String getSequentialKey()
Get a character string that uniquely identifies this node
Specified by:
getSequentialKey in interface NodeInfo
Overrides:
getSequentialKey in class com.icl.saxon.tree.NodeImpl
Returns:
a string based on the document identifier

getDocumentNumber

public int getDocumentNumber()
Get a unique number identifying this document
Specified by:
getDocumentNumber in interface DocumentInfo

getAllElements

public NodeSetValue getAllElements(int fingerprint)
Get a list of all elements with a given name fingerprint
Specified by:
getAllElements in interface DocumentInfo
Following copied from interface: com.icl.saxon.om.DocumentInfo
Parameters:
fingerprint - The fingerprint of the required name

selectID

public ElementInfo selectID(java.lang.String id)
                     throws org.xml.sax.SAXException
Get the element with a given ID.
Specified by:
selectID in interface DocumentInfo
Parameters:
id - The unique ID of the required element, previously registered using registerID()
Returns:
The ElementInfo for the given ID if one has been registered, otherwise null.

getKeyIndex

public java.util.Hashtable getKeyIndex(KeyManager keymanager,
                                       int fingerprint)
                                throws org.xml.sax.SAXException
Get the index for a given key
Specified by:
getKeyIndex in interface DocumentInfo
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.
Throws:
SAXExcetpion - If the index is under construction, throws an exception, as this implies a key defined in terms of itself.

setKeyIndex

public void setKeyIndex(KeyManager keymanager,
                        int fingerprint,
                        java.lang.Object keyindex)
                 throws org.xml.sax.SAXException
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:
setKeyIndex in interface DocumentInfo
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.

setUnparsedEntity

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

getUnparsedEntity

public java.lang.String getUnparsedEntity(java.lang.String name)
Get the unparsed entity with a given name
Specified by:
getUnparsedEntity in interface DocumentInfo
Parameters:
name - the name of the entity
Returns:
the URI of the entity if there is one, or empty string if not

getEmbeddedStylesheet

public PreparedStyleSheet getEmbeddedStylesheet(java.lang.String id)
                                         throws org.xml.sax.SAXException
Prepare an embedded stylesheet within this document
Specified by:
getEmbeddedStylesheet in interface DocumentInfo
Parameters:
id - The id of the required embedded stylesheet
Returns:
the prepared Stylesheet if there is one, or null.

copy

public void copy(Outputter out)
          throws org.xml.sax.SAXException
Copy this node to a given outputter
Specified by:
copy in interface NodeInfo

getPath

public java.lang.String getPath()
Generate a path to this node
Specified by:
getPath in interface NodeInfo

toString

public java.lang.String toString()
Diagnostic string representation
Overrides:
toString in class com.icl.saxon.tree.NodeImpl

getDoctype

public org.w3c.dom.DocumentType getDoctype()
The Document Type Declaration (see DocumentType ) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null . The DOM Level 2 does not support editing the Document Type Declaration, therefore docType cannot be altered in any way, including through the use of methods, such as insertNode or removeNode , which are inherited from the Node interface.
Specified by:
getDoctype in interface org.w3c.dom.Document

getImplementation

public org.w3c.dom.DOMImplementation getImplementation()
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.
Specified by:
getImplementation in interface org.w3c.dom.Document

createElement

public org.w3c.dom.Element createElement(java.lang.String tagName)
                                  throws org.w3c.dom.DOMException
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
Specified by:
createElement in interface org.w3c.dom.Document

createDocumentFragment

public org.w3c.dom.DocumentFragment createDocumentFragment()
Creates an empty DocumentFragment object.
Specified by:
createDocumentFragment in interface org.w3c.dom.Document
Returns:
A new DocumentFragment .

createTextNode

public org.w3c.dom.Text createTextNode(java.lang.String data)
Creates a Text node given the specified string.
Specified by:
createTextNode in interface org.w3c.dom.Document
Parameters:
data - The data for the node.
Returns:
The new Text object.

createComment

public org.w3c.dom.Comment createComment(java.lang.String data)
Creates a Comment node given the specified string.
Specified by:
createComment in interface org.w3c.dom.Document
Parameters:
data - The data for the node.
Returns:
The new Comment object.

createCDATASection

public org.w3c.dom.CDATASection createCDATASection(java.lang.String data)
                                            throws org.w3c.dom.DOMException
Creates a CDATASection node whose value is the specified string.
Specified by:
createCDATASection in interface org.w3c.dom.Document
Parameters:
data - The data for the CDATASection contents.
Returns:
The new CDATASection object.
Throws:
org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createProcessingInstruction

public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                                     java.lang.String data)
                                                              throws org.w3c.dom.DOMException
Creates a ProcessingInstruction node given the specified name and data strings.
Specified by:
createProcessingInstruction in interface org.w3c.dom.Document
Parameters:
target - The target part of the processing instruction.
data - The data for the node.
Returns:
The new ProcessingInstruction object.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createAttribute

public org.w3c.dom.Attr createAttribute(java.lang.String name)
                                 throws org.w3c.dom.DOMException
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.
Specified by:
createAttribute in interface org.w3c.dom.Document
Parameters:
name - The name of the attribute.
Returns:
A new Attr object with the nodeName attribute set to name , and localName , prefix , and namespaceURI set to null .
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createEntityReference

public org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
                                                  throws org.w3c.dom.DOMException
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node. If any descendant of the Entity node has an unbound namespace prefix , the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null ). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.
Specified by:
createEntityReference in interface org.w3c.dom.Document
Parameters:
name - The name of the entity to reference.
Returns:
The new EntityReference object.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
Specified by:
getElementsByTagName in interface org.w3c.dom.Document
Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A new NodeList object containing all the matched Elements .

importNode

public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode,
                                   boolean deep)
                            throws org.w3c.dom.DOMException
Imports a node from another document to this document.
Specified by:
importNode in interface org.w3c.dom.Document
Throws:
org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.
Since:
DOM Level 2

createElementNS

public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI,
                                           java.lang.String qualifiedName)
                                    throws org.w3c.dom.DOMException
Creates an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.
Specified by:
createElementNS in interface org.w3c.dom.Document
Parameters:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
A new Element object with the following attributes: Attribute ValueNode.nodeName qualifiedNameNode.namespaceURI namespaceURINode.prefix prefix, extracted from qualifiedName , or null if there is no prefixNode.localName local name , extracted from qualifiedNameElement.tagName qualifiedName
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null or an empty string, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace " .
Since:
DOM Level 2

createAttributeNS

public org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI,
                                          java.lang.String qualifiedName)
                                   throws org.w3c.dom.DOMException
Creates an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.
Specified by:
createAttributeNS in interface org.w3c.dom.Document
Parameters:
namespaceURI - The namespace URI of the attribute to create.
qualifiedName - The qualified name of the attribute to instantiate.
Returns:
A new Attr object with the following attributes: Attribute ValueNode.nodeName qualifiedName Node.namespaceURInamespaceURI Node.prefix prefix, extracted from qualifiedName , or null if there is no prefixNode.localName local name , extracted from qualifiedNameAttr.name qualifiedName
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null or an empty string, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace ", or if the qualifiedName is "xmlns" and the namespaceURI is different from " http://www.w3.org/2000/xmlns/ ".
Since:
DOM Level 2

getElementsByTagNameNS

public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                                   java.lang.String localName)
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
Specified by:
getElementsByTagNameNS in interface org.w3c.dom.Document
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements .
Since:
DOM Level 2

getElementById

public org.w3c.dom.Element getElementById(java.lang.String elementId)
Returns the Element whose ID is given by elementId . If no such element exists, returns null . Behavior is not defined if more than one element has this ID . The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null .
Specified by:
getElementById in interface org.w3c.dom.Document
Parameters:
elementId - The unique id value for an element.
Returns:
The matching element.
Since:
DOM Level 2

hasFeature

public boolean hasFeature(java.lang.String feature,
                          java.lang.String version)
Test if the DOM implementation implements a specific feature.
Specified by:
hasFeature in interface org.w3c.dom.DOMImplementation
Parameters:
feature - The name of the feature to test (case-insensitive).
version - This is the version number of the feature to test.
Returns:
true if the feature is implemented in the specified version, false otherwise.

createDocumentType

public org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName,
                                                   java.lang.String publicId,
                                                   java.lang.String systemId)
                                            throws org.w3c.dom.DOMException
Creates an empty DocumentType node.
Specified by:
createDocumentType in interface org.w3c.dom.DOMImplementation
Parameters:
qualifiedName - The qualified name of the document type to be created.
publicId - The external subset public identifier.
systemId - The external subset system identifier.
Returns:
A new DocumentType node with Node.ownerDocument set to null .
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed.
Since:
DOM Level 2

createDocument

public org.w3c.dom.Document createDocument(java.lang.String namespaceURI,
                                           java.lang.String qualifiedName,
                                           org.w3c.dom.DocumentType doctype)
                                    throws org.w3c.dom.DOMException
Creates an XML Document object of the specified type with its document element.
Specified by:
createDocument in interface org.w3c.dom.DOMImplementation
Parameters:
namespaceURI - The namespace URI of the document element to create.
qualifiedName - The qualified name of the document element to be created.
doctype - The type of document to be created or null.
Returns:
A new Document object.
Throws:
org.w3c.dom.DOMException -  
Since:
DOM Level 2

getSequenceNumber

public long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position.
Overrides:
getSequenceNumber in class com.icl.saxon.tree.NodeImpl

getNumberOfChildren

public int getNumberOfChildren()
Get the number of children.
Overrides:
getNumberOfChildren in class com.icl.saxon.tree.NodeImpl

getAllChildNodes

public NodeInfo[] getAllChildNodes()
Get all child nodes of the element (child elements and character nodes).
Overrides:
getAllChildNodes in class com.icl.saxon.tree.NodeImpl
Returns:
a vector containing a NodeInfo for each child node

enumerateChildren

public NodeEnumeration enumerateChildren()
Get an enumeration of the children of this node
Overrides:
enumerateChildren in class com.icl.saxon.tree.NodeImpl

getFirstChild

public org.w3c.dom.Node getFirstChild()
Get the first child node of the element
Overrides:
getFirstChild in class com.icl.saxon.tree.NodeImpl
Returns:
the first child node of the required type, or null if there are no children

getLastChild

public org.w3c.dom.Node getLastChild()
Get the last child node of the element
Overrides:
getLastChild in class com.icl.saxon.tree.NodeImpl
Returns:
the last child of the element, or null if there are no children

getNthChild

protected final NodeInfo getNthChild(int n)
Get the nth child node of the element (numbering from 0)
Returns:
the last child of the element, or null if there is no n'th child

getValue

public java.lang.String getValue()
Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
Returns:
the accumulated character content of the element, including descendant elements.

copyStringValue

public void copyStringValue(Outputter out)
                     throws org.xml.sax.SAXException
Copy the string-value of this node to a given outputter
Overrides:
copyStringValue in class com.icl.saxon.tree.NodeImpl

defaultAction

public void defaultAction(Context c)
                   throws org.xml.sax.SAXException
Perform default action for this kind of node (built-in template rule)

useChildrenArray

public void useChildrenArray(com.icl.saxon.tree.NodeImpl[] array)
Supply an array to be used for the array of children. For system use only.

addChild

public void addChild(com.icl.saxon.tree.NodeImpl node,
                     int index)
Add a child node to this node. For system use only. Note: normalizing adjacent text nodes is the responsibility of the caller.

removeChild

public void removeChild(int index)
Remove node at given index. Will always be followed by a renumberChildren().

renumberChildren

public void renumberChildren()
Renumber the children of a given parent node. For system use only

dropChildren

public void dropChildren()
Drop a branch of the tree. The target element remains in the tree, but its children are disconnected from the parent. Unless there are other references to the children (e.g. in a variable) they will be deleted from memory next time the garbage collector comes round.

compact

public void compact(int size)
Compact the space used by this node

getNodeValue

public java.lang.String getNodeValue()
Get the node value as defined in the DOM. This is not the same as the XPath string-value.
Overrides:
getNodeValue in class com.icl.saxon.tree.NodeImpl

isSameNode

public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node
Specified by:
isSameNode in interface NodeInfo
Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

getNameCode

public int getNameCode()
Get the nameCode of the node. This is used to locate the name in the NamePool
Specified by:
getNameCode in interface NodeInfo

getFingerprint

public int getFingerprint()
Get the fingerprint of the node. This is used to compare whether two nodes have equivalent names.
Specified by:
getFingerprint in interface NodeInfo

getPrefix

public java.lang.String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
Specified by:
getPrefix in interface NodeInfo
Returns:
the prefix part of the name. For an unnamed node, return an empty string.

getURI

public java.lang.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
Returns:
The URI of the namespace of this node. For the default namespace, return an empty string. For an unnamed node, return null.

getURICode

public short getURICode()
Get URI code. This is a number that uniquely identifies the namespace URI of the node, within its NamePool
Specified by:
getURICode in interface NodeInfo

getDisplayName

public java.lang.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
Returns:
The display name of this node. For a node with no name, return an empty string.

getLocalName

public java.lang.String getLocalName()
Get the local name of this node.
Specified by:
getLocalName in interface NodeInfo
Returns:
The local name of this node. For a node with no name, return an empty string.

getPublicId

public java.lang.String getPublicId()
Get the public identifier of the document entity containing this node. This is not currently maintained: return null

getIndex

public final int getIndex()
Get the index of this node, i.e. its position among its siblings
Specified by:
getIndex in interface NodeInfo
Following copied from interface: com.icl.saxon.om.NodeInfo
Returns:
the number of preceding sibling nodes at the same level

getParentNode

public final org.w3c.dom.Node getParentNode()
Find the parent node of this node.
Specified by:
getParentNode in interface org.w3c.dom.Node
Returns:
The Node object describing the containing element or root node.

isa

public final boolean isa(int nodeType)
Determine whether the node is of a given type.

Note, this can also be done by testing the node using "instanceof". But this is inconvenient when passing the class as a parameter to another routine.

Parameters:
nodeType - One of the specific node types such as ELEMENT or TEXT, or the general node type NODE
Returns:
true if the node is an instance of the specified node type

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes.
Specified by:
hasAttributes in interface org.w3c.dom.Node
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String uri,
                                          java.lang.String localName)
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.
Specified by:
getAttributeValue in interface NodeInfo
Parameters:
uri - the namespace uri of an attribute
localName - the local name of an attribute
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name)
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.
Specified by:
getAttributeValue in interface NodeInfo
Parameters:
name - the name of an attribute. This must be an unqualified attribute name, i.e. one with no namespace prefix.
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue

public java.lang.String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node
Specified by:
getAttributeValue in interface NodeInfo
Parameters:
fingerprint - The fingerprint of the attribute name
Returns:
the attribute value if it exists or null if not

isDocumentElement

public boolean isDocumentElement()
Determine whether this node is the outermost element.
Specified by:
isDocumentElement in interface NodeInfo
Returns:
True if this element is the document (outermost) element.

getNextInDocument

public NodeInfo getNextInDocument(NodeInfo anchor)
Get the next node in document order
Specified by:
getNextInDocument in interface NodeInfo
Parameters:
anchor: - the scan stops when it reaches a node that is not a descendant of the specified anchor node
Returns:
the next node in the document, or null if there is no such node

getPreviousInDocument

public NodeInfo getPreviousInDocument()
Get the previous node in document order
Specified by:
getPreviousInDocument in interface NodeInfo
Returns:
the previous node in the document, or null if there is no such node

removeNode

public void removeNode()
                throws org.xml.sax.SAXException
Remove this node from the tree. For system use only. When one or more nodes have been removed, renumberChildren() must be called to adjust the numbering of remaining nodes. PRECONDITION: The node must have a parent node.

setNodeValue

public void setNodeValue(java.lang.String nodeValue)
                  throws org.w3c.dom.DOMException
Set the node value. DOM method: always fails
Specified by:
setNodeValue in interface org.w3c.dom.Node

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Return a NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.
Specified by:
getChildNodes in interface org.w3c.dom.Node

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Return a NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise. (DOM method)
Specified by:
getAttributes in interface org.w3c.dom.Node

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
Return the Document object associated with this node. (DOM mehod)
Specified by:
getOwnerDocument in interface org.w3c.dom.Node

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
Insert the node newChild before the existing child node refChild. DOM method: always fails.
Specified by:
insertBefore in interface org.w3c.dom.Node
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
                              throws org.w3c.dom.DOMException
Replace the child node oldChild with newChild in the list of children, and returns the oldChild node. Always fails.
Specified by:
replaceChild in interface org.w3c.dom.Node
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
Remove the child node indicated by oldChild from the list of children, and returns it. DOM method: always fails.
Specified by:
removeChild in interface org.w3c.dom.Node
Parameters:
oldChild - The node being removed.
Returns:
The node removed.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
Adds the node newChild to the end of the list of children of this node. DOM method: always fails.
Specified by:
appendChild in interface org.w3c.dom.Node
Parameters:
newChild - The node to add.
Returns:
The node added.
Throws:
org.w3c.dom.DOMException -
NO_MODIFICATION_ALLOWED_ERR: Always raised.

hasChildNodes

public boolean hasChildNodes()
Determine whether the node has any children.
Specified by:
hasChildNodes in interface org.w3c.dom.Node
Returns:
true if the node has any children, false if the node has no children.

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent. Not implemented: always returns null. (Because trees are read-only, there would be no way of using the resulting node.)
Specified by:
cloneNode in interface org.w3c.dom.Node
Parameters:
deep - If true , recursively clone the subtree under the specified node; if false , clone only the node itself (and its attributes, if it is an Element ).
Returns:
The duplicate node.

normalize

public void normalize()
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
Specified by:
normalize in interface org.w3c.dom.Node
Since:
DOM Level 2

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
Specified by:
isSupported in interface org.w3c.dom.Node
Parameters:
feature - The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation .
version - This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true .
Returns:
Returns true if the specified feature is supported on this node, false otherwise.
Since:
DOM Level 2

getNamespaceURI

public java.lang.String getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null . Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
Specified by:
getNamespaceURI in interface org.w3c.dom.Node
Since:
DOM Level 2

setPrefix

public void setPrefix(java.lang.String prefix)
               throws org.w3c.dom.DOMException
Set the namespace prefix of this node. Always fails.
Specified by:
setPrefix in interface org.w3c.dom.Node

disallowUpdate

protected void disallowUpdate()
                       throws org.w3c.dom.DOMException
Internal method used to indicate that update operations are not allowed