Package com.icl.saxon.om
Class AbstractNode
- java.lang.Object
-
- com.icl.saxon.om.AbstractNode
-
- All Implemented Interfaces:
NodeInfo,javax.xml.transform.dom.DOMLocator,javax.xml.transform.Source,javax.xml.transform.SourceLocator,org.w3c.dom.Node
- Direct Known Subclasses:
NodeImpl,TinyNodeImpl
public abstract class AbstractNode extends java.lang.Object implements org.w3c.dom.Node, NodeInfo, javax.xml.transform.SourceLocator, javax.xml.transform.dom.DOMLocator
This class is an abstract implementation of the Saxon NodeInfo interface; it also contains concrete implementations of most of the DOM methods in terms of the NodeInfo methods. These include all the methods defined on the DOM Node class itself, and most of those defined on subclasses such as Document, Text, and Comment: because of the absence of multiple inheritance, this is the only way of making these methods reusable by multiple implementations. The class contains no data, and can be used as a common superclass for different implementations of Node and NodeInfo.- Author:
- Michael H. Kay
-
-
Field Summary
Fields Modifier and Type Field Description static char[]NODE_LETTERChararacteristic letters to identify each type of node, indexed using the node type values.-
Fields inherited from interface org.w3c.dom.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 Constructor Description AbstractNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.NodeappendChild(org.w3c.dom.Node newChild)Adds the nodenewChildto the end of the list of children of this node.voidappendData(java.lang.String arg)Append the string to the end of the character data of the node.org.w3c.dom.NodecloneNode(boolean deep)Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.shortcompareDocumentPosition(org.w3c.dom.Node other)Compares the reference node, i.e.abstract intcompareOrder(NodeInfo other)Determine the relative position of this node and another node, in document order.voidcopyStringValue(Outputter out)Copy the string-value of this node to a given outputter.org.w3c.dom.AttrcreateAttribute(java.lang.String name)Create anAttrof the given name.org.w3c.dom.AttrcreateAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)Create an attribute of the given qualified name and namespace URI.org.w3c.dom.CDATASectioncreateCDATASection(java.lang.String data)Create aCDATASectionnode whose value is the specified string.org.w3c.dom.CommentcreateComment(java.lang.String data)Create aCommentnode given the specified string.org.w3c.dom.DocumentFragmentcreateDocumentFragment()Creates an emptyDocumentFragmentobject.org.w3c.dom.ElementcreateElement(java.lang.String tagName)Creates an element of the type specified.org.w3c.dom.ElementcreateElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)Create an element of the given qualified name and namespace URI.org.w3c.dom.EntityReferencecreateEntityReference(java.lang.String name)Create anEntityReferenceobject.org.w3c.dom.ProcessingInstructioncreateProcessingInstruction(java.lang.String target, java.lang.String data)Create aProcessingInstructionnode given the specified name and data strings.org.w3c.dom.TextcreateTextNode(java.lang.String data)Create aTextnode given the specified string.voiddeleteData(int offset, int count)Remove a range of 16-bit units from the node.protected voiddisallowUpdate()Internal method used to indicate that update operations are not allowedabstract java.lang.StringgenerateId()Get a character string that uniquely identifies this nodejava.lang.StringgetAttribute(java.lang.String name)Retrieves an attribute value by name.org.w3c.dom.AttrgetAttributeNode(java.lang.String name)Retrieves an attribute node by name.org.w3c.dom.AttrgetAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)Retrieves anAttrnode by local name and namespace URI.java.lang.StringgetAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Retrieves an attribute value by local name and namespace URI.org.w3c.dom.NamedNodeMapgetAttributes()Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise.abstract java.lang.StringgetAttributeValue(int fingerprint)Get the value of a given attribute of this nodeabstract java.lang.StringgetAttributeValue(java.lang.String uri, java.lang.String localName)Find the value of a given attribute of this node.abstract java.lang.StringgetBaseURI()Get the base URI for the node.org.w3c.dom.NodeListgetChildNodes()Return aNodeListthat contains all children of this node.intgetColumnNumber()Get the column number of the node.java.lang.StringgetData()Get the character data of a Text or Comment node.java.lang.StringgetDisplayName()Get the display name of this node.org.w3c.dom.DocumentTypegetDoctype()Get the Document Type Declaration (seeDocumentType) associated with this document.org.w3c.dom.ElementgetDocumentElement()Get the outermost element.DocumentInfogetDocumentRoot()Get the root (document) nodeorg.w3c.dom.ElementgetElementById(java.lang.String elementId)Return theElementwhoseIDis given byelementId.org.w3c.dom.NodeListgetElementsByTagName(java.lang.String tagname)Return aNodeListof all theElementswith a given tag name in the order in which they are encountered in a preorder traversal of theDocumenttree.org.w3c.dom.NodeListgetElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)Return aNodeListof all theElementswith a given local name and namespace URI in the order in which they are encountered in a preorder traversal of theDocumenttree.abstract AxisEnumerationgetEnumeration(byte axisNumber, NodeTest nodeTest)Return an enumeration over the nodes reached by the given axis from this nodejava.lang.ObjectgetFeature(java.lang.String feature, java.lang.String version)This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .abstract intgetFingerprint()Get the fingerprint of the node, used for matching namesorg.w3c.dom.NodegetFirstChild()Get first child (DOM method)org.w3c.dom.DOMImplementationgetImplementation()Get aDOMImplementationobject that handles this document.org.w3c.dom.NodegetLastChild()Get last child (DOM method)intgetLength()Get the length of a Text or Comment node.intgetLineNumber()Get the line number of the node within its source document entity.abstract java.lang.StringgetLocalName()Get the local name of this node.java.lang.StringgetName()Get the name of an attribute node (the QName) (DOM method)abstract intgetNameCode()Get the name code of the node, used for displaying namesjava.lang.StringgetNamespaceURI()The namespace URI of this node, ornullif it is unspecified.org.w3c.dom.NodegetNextSibling()Get next sibling node (DOM method)java.lang.StringgetNodeName()Get the name of this node, following the DOM rulesjava.lang.StringgetNodeValue()Get the node value as defined in the DOM.org.w3c.dom.NodegetOriginatingNode()Get the node corresponding to this javax.xml.transform.dom.DOMLocatororg.w3c.dom.DocumentgetOwnerDocument()Return theDocumentobject associated with this node.org.w3c.dom.ElementgetOwnerElement()TheElementnode this attribute is attached to ornullif this attribute is not in use.abstract NodeInfogetParent()Find the parent node of this node.org.w3c.dom.NodegetParentNode()Find the parent node of this node (DOM method).abstract java.lang.StringgetPrefix()Get the prefix part of the name of this node.org.w3c.dom.NodegetPreviousSibling()Get the previous sibling of the node (DOM method)java.lang.StringgetPublicId()Get the public identifier of the document entity containing this node.org.w3c.dom.TypeInfogetSchemaTypeInfo()The type information associated with this attribute.booleangetSpecified()If this attribute was explicitly given a value in the original document, this istrue; otherwise, it isfalse.abstract java.lang.StringgetSystemId()Get the system ID for the entity containing the node.java.lang.StringgetTagName()The name of the element (DOM interface).java.lang.StringgetTextContent()This attribute returns the text content of this node and its descendants.abstract java.lang.StringgetURI()Get the URI part of the name of this node.java.lang.ObjectgetUserData(java.lang.String key)Retrieves the object associated to a key on a this node.java.lang.StringgetValue()Return the character value of an attribute node (DOM method)java.lang.StringgetWholeText()Returns all text ofTextnodes logically-adjacent text nodes to this node, concatenated in document order.booleanhasAttribute(java.lang.String name)Returnstruewhen an attribute with a given name is specified on this element or has a default value,falseotherwise.booleanhasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Returnstruewhen an attribute with a given local name and namespace URI is specified on this element or has a default value,falseotherwise.abstract booleanhasAttributes()Returns whether this node has any attributes.abstract booleanhasChildNodes()Determine whether the node has any children.org.w3c.dom.NodeimportNode(org.w3c.dom.Node importedNode, boolean deep)Import a node from another document to this document.org.w3c.dom.NodeinsertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)Insert the nodenewChildbefore the existing child noderefChild.voidinsertData(int offset, java.lang.String arg)Insert a string at the specified character offset.booleanisDefaultNamespace(java.lang.String namespaceURI)This method checks if the specifiednamespaceURIis the default namespace or not.booleanisElementContentWhitespace()Returns whether this text node contains element content whitespace, often abusively called "ignorable whitespace".booleanisEqualNode(org.w3c.dom.Node arg)Tests whether two nodes are equal.booleanisId()Returns whether this attribute is known to be of type ID (i.e.booleanisSameNode(org.w3c.dom.Node other)Returns whether this node is the same node as the given one.abstract booleanisSameNodeInfo(NodeInfo other)Determine whether this is the same node as another nodebooleanisSupported(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.java.lang.StringlookupNamespaceURI(java.lang.String prefix)Look up the namespace URI associated to the given prefix, starting from this node.java.lang.StringlookupPrefix(java.lang.String namespaceURI)Look up the prefix associated to the given namespace URI, starting from this node.voidnormalize()Puts allTextnodes in the full depth of the sub-tree underneath thisNode, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes.voidoutputNamespaceNodes(Outputter out, boolean includeAncestors)Output all namespace nodes associated with this element.voidremoveAttribute(java.lang.String oldAttr)Removes the specified attribute.org.w3c.dom.AttrremoveAttributeNode(org.w3c.dom.Attr oldAttr)Removes the specified attribute node.voidremoveAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Removes an attribute by local name and namespace URI.org.w3c.dom.NoderemoveChild(org.w3c.dom.Node oldChild)Remove the child node indicated byoldChildfrom the list of children, and returns it.org.w3c.dom.NodereplaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)Replace the child nodeoldChildwithnewChildin the list of children, and returns theoldChildnode.voidreplaceData(int offset, int count, java.lang.String arg)Replace the characters starting at the specified 16-bit unit offset with the specified string.org.w3c.dom.TextreplaceWholeText(java.lang.String content)Replaces the text of the current node and all logically-adjacent text nodes with the specified text.org.w3c.dom.AttrsetAttributeNode(org.w3c.dom.Attr newAttr)Adds a new attribute node.org.w3c.dom.AttrsetAttributeNodeNS(org.w3c.dom.Attr newAttr)Add a new attribute.voidsetAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)Adds a new attribute.voidsetData(java.lang.String data)Set the character data of a Text or Comment node.voidsetIdAttribute(java.lang.String name, boolean isId)If the parameterisIdistrue, this method declares the specified attribute to be a user-determined ID attribute .voidsetIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId)If the parameterisIdistrue, this method declares the specified attribute to be a user-determined ID attribute .voidsetIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId)If the parameterisIdistrue, this method declares the specified attribute to be a user-determined ID attribute .voidsetNodeValue(java.lang.String nodeValue)Set the node value.voidsetPrefix(java.lang.String prefix)Set the namespace prefix of this node.voidsetTextContent(java.lang.String textContent)This attribute returns the text content of this node and its descendants.java.lang.ObjectsetUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)Associate an object to a key on this node.voidsetValue(java.lang.String value)Set the value of an attribute node.org.w3c.dom.TextsplitText(int offset)Break this node into two nodes at the specified offset, keeping both in the tree as siblings.java.lang.StringsubstringData(int offset, int count)Extract a range of data from a Text or Comment node.booleansupports(java.lang.String feature, java.lang.String version)Alternative to isSupported(), defined in a draft DOM spec-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.icl.saxon.om.NodeInfo
copy, getNodeType, getStringValue
-
-
-
-
Method Detail
-
isSameNodeInfo
public abstract boolean isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node- Specified by:
isSameNodeInfoin interfaceNodeInfo- Returns:
- true if this Node object and the supplied Node object represent the same node in the tree.
-
generateId
public abstract java.lang.String generateId()
Get a character string that uniquely identifies this node- Specified by:
generateIdin interfaceNodeInfo- Returns:
- a string.
-
getSystemId
public abstract java.lang.String getSystemId()
Get the system ID for the entity containing the node.- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfacejavax.xml.transform.Source- Specified by:
getSystemIdin interfacejavax.xml.transform.SourceLocator- 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
public abstract java.lang.String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.- Specified by:
getBaseURIin interfaceorg.w3c.dom.Node- Specified by:
getBaseURIin interfaceNodeInfo
-
getOriginatingNode
public org.w3c.dom.Node getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator- Specified by:
getOriginatingNodein interfacejavax.xml.transform.dom.DOMLocator
-
compareOrder
public abstract int compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.- Specified by:
compareOrderin interfaceNodeInfo- Parameters:
other- The other node, whose position is to be compared with this node- Returns:
- -1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())
-
getNameCode
public abstract int getNameCode()
Get the name code of the node, used for displaying names- Specified by:
getNameCodein interfaceNodeInfo- See Also:
allocate,getFingerprint
-
getFingerprint
public abstract int getFingerprint()
Get the fingerprint of the node, used for matching names- Specified by:
getFingerprintin interfaceNodeInfo
-
getNodeName
public java.lang.String getNodeName()
Get the name of this node, following the DOM rules- Specified by:
getNodeNamein interfaceorg.w3c.dom.Node- Returns:
- The name of the node. For an element this is the element name, for an attribute it is the attribute name, as a QName. Other node types return conventional names such as "#text" or "#comment"
-
getPrefix
public abstract java.lang.String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
-
getURI
public abstract 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.
-
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:
getDisplayNamein interfaceNodeInfo- Returns:
- The display name of this node. For a node with no name, return an empty string.
-
getLocalName
public abstract java.lang.String getLocalName()
Get the local name of this node.- Specified by:
getLocalNamein interfaceorg.w3c.dom.Node- Specified by:
getLocalNamein interfaceNodeInfo- Returns:
- The local name of this node. For a node with no name, return an empty string.
-
hasChildNodes
public abstract boolean hasChildNodes()
Determine whether the node has any children.- Specified by:
hasChildNodesin interfaceorg.w3c.dom.Node- Specified by:
hasChildNodesin interfaceNodeInfo- Returns:
trueif this node has any attributes,falseotherwise.
-
hasAttributes
public abstract boolean hasAttributes()
Returns whether this node has any attributes.- Specified by:
hasAttributesin interfaceorg.w3c.dom.Node- Returns:
trueif this node has any attributes,falseotherwise.- Since:
- DOM Level 2
-
getAttributeValue
public abstract 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:
getAttributeValuein interfaceNodeInfo- Parameters:
uri- the namespace uri of an attributelocalName- the local name of an attribute- Returns:
- the value of the attribute, if it exists, otherwise null
-
getAttributeValue
public abstract java.lang.String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node- Specified by:
getAttributeValuein interfaceNodeInfo- Parameters:
fingerprint- The fingerprint of the attribute name- Returns:
- the attribute value if it exists or null if not
-
getLineNumber
public int getLineNumber()
Get the line number of the node within its source document entity. The default implementation returns -1, meaning unknown- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfacejavax.xml.transform.SourceLocator- Returns:
- the line number of the node in its original source document; or -1 if not available
-
getColumnNumber
public int getColumnNumber()
Get the column number of the node. The default implementation returns -1, meaning unknown- Specified by:
getColumnNumberin interfacejavax.xml.transform.SourceLocator
-
getPublicId
public java.lang.String getPublicId()
Get the public identifier of the document entity containing this node. The default implementation returns null, meaning unknown- Specified by:
getPublicIdin interfacejavax.xml.transform.SourceLocator
-
getEnumeration
public abstract AxisEnumeration getEnumeration(byte axisNumber, NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node- Specified by:
getEnumerationin interfaceNodeInfo- Parameters:
axisNumber- The axis to be used (a constant in classAxis)nodeTest- A pattern to be matched by the returned nodes- Returns:
- a AxisEnumeration that scans the nodes reached by the axis in turn.
-
getParent
public abstract NodeInfo getParent()
Find the parent node of this node.
-
getDocumentRoot
public DocumentInfo getDocumentRoot()
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Returns:
- the DocumentInfo representing the containing document
-
getParentNode
public org.w3c.dom.Node getParentNode()
Find the parent node of this node (DOM method).- Specified by:
getParentNodein interfaceorg.w3c.dom.Node- Returns:
- The Node object describing the containing element or root node.
-
getPreviousSibling
public org.w3c.dom.Node getPreviousSibling()
Get the previous sibling of the node (DOM method)- Specified by:
getPreviousSiblingin interfaceorg.w3c.dom.Node- Returns:
- The previous sibling node. Returns null if the current node is the first child of its parent.
-
getNextSibling
public org.w3c.dom.Node getNextSibling()
Get next sibling node (DOM method)- Specified by:
getNextSiblingin interfaceorg.w3c.dom.Node- Returns:
- The next sibling node. Returns null if the current node is the last child of its parent.
-
getFirstChild
public org.w3c.dom.Node getFirstChild()
Get first child (DOM method)- Specified by:
getFirstChildin interfaceorg.w3c.dom.Node- Returns:
- the first child node of this node, or null if it has no children
-
getLastChild
public org.w3c.dom.Node getLastChild()
Get last child (DOM method)- Specified by:
getLastChildin interfaceorg.w3c.dom.Node- Returns:
- last child of this node, or null if it has no children
-
getDocumentElement
public org.w3c.dom.Element getDocumentElement()
Get the outermost element. (DOM method)- Returns:
- the Element for the outermost element of the document. If the document is not well-formed, this returns the last element child of the root if there is one, otherwise null.
-
copyStringValue
public void copyStringValue(Outputter out) throws javax.xml.transform.TransformerException
Copy the string-value of this node to a given outputter. Default implementation does "out.writeContent(getStringValue());" but it is useful to provide an optimized implementation.- Specified by:
copyStringValuein interfaceNodeInfo- Throws:
javax.xml.transform.TransformerException
-
outputNamespaceNodes
public void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws javax.xml.transform.TransformerException
Output all namespace nodes associated with this element. Does nothing if the node is not an element.- Specified by:
outputNamespaceNodesin interfaceNodeInfo- Parameters:
out- The relevant outputterincludeAncestors- True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree- Throws:
javax.xml.transform.TransformerException
-
getNodeValue
public java.lang.String getNodeValue()
Get the node value as defined in the DOM. This is not necessarily the same as the XPath string-value.- Specified by:
getNodeValuein interfaceorg.w3c.dom.Node
-
setNodeValue
public void setNodeValue(java.lang.String nodeValue) throws org.w3c.dom.DOMExceptionSet the node value. DOM method: always fails- Specified by:
setNodeValuein interfaceorg.w3c.dom.Node- Throws:
org.w3c.dom.DOMException
-
getChildNodes
public org.w3c.dom.NodeList getChildNodes()
Return aNodeListthat contains all children of this node. If there are no children, this is aNodeListcontaining no nodes. DOM Method.- Specified by:
getChildNodesin interfaceorg.w3c.dom.Node
-
getAttributes
public org.w3c.dom.NamedNodeMap getAttributes()
Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise. (DOM method)- Specified by:
getAttributesin interfaceorg.w3c.dom.Node
-
getOwnerDocument
public org.w3c.dom.Document getOwnerDocument()
Return theDocumentobject associated with this node. (DOM method)- Specified by:
getOwnerDocumentin interfaceorg.w3c.dom.Node
-
insertBefore
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws org.w3c.dom.DOMExceptionInsert the nodenewChildbefore the existing child noderefChild. DOM method: always fails.- Specified by:
insertBeforein interfaceorg.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.DOMExceptionReplace the child nodeoldChildwithnewChildin the list of children, and returns theoldChildnode. Always fails.- Specified by:
replaceChildin interfaceorg.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.DOMExceptionRemove the child node indicated byoldChildfrom the list of children, and returns it. DOM method: always fails.- Specified by:
removeChildin interfaceorg.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.DOMExceptionAdds the nodenewChildto the end of the list of children of this node. DOM method: always fails.- Specified by:
appendChildin interfaceorg.w3c.dom.Node- Parameters:
newChild- The node to add.- Returns:
- The node added.
- Throws:
org.w3c.dom.DOMException-
NO_MODIFICATION_ALLOWED_ERR: Always raised.
-
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:
cloneNodein interfaceorg.w3c.dom.Node- Parameters:
deep- Iftrue, recursively clone the subtree under the specified node; iffalse, clone only the node itself (and its attributes, if it is anElement).- Returns:
- The duplicate node.
-
normalize
public void normalize()
Puts allTextnodes in the full depth of the sub-tree underneath thisNode, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes.- Specified by:
normalizein interfaceorg.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:
isSupportedin interfaceorg.w3c.dom.Node- Parameters:
feature- The name of the feature to test. This is the same name which can be passed to the methodhasFeatureonDOMImplementation.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 returntrue.- Returns:
- Returns
trueif the specified feature is supported on this node,falseotherwise. - Since:
- DOM Level 2
-
supports
public boolean supports(java.lang.String feature, java.lang.String version)Alternative to isSupported(), defined in a draft DOM spec
-
getNamespaceURI
public java.lang.String getNamespaceURI()
The namespace URI of this node, ornullif it is unspecified. DOM method.
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 thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, this is alwaysnull. 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:
getNamespaceURIin interfaceorg.w3c.dom.Node- Since:
- DOM Level 2
-
setPrefix
public void setPrefix(java.lang.String prefix) throws org.w3c.dom.DOMExceptionSet the namespace prefix of this node. Always fails.- Specified by:
setPrefixin interfaceorg.w3c.dom.Node- Throws:
org.w3c.dom.DOMException
-
disallowUpdate
protected void disallowUpdate() throws org.w3c.dom.DOMExceptionInternal method used to indicate that update operations are not allowed- Throws:
org.w3c.dom.DOMException
-
getDoctype
public org.w3c.dom.DocumentType getDoctype()
Get the Document Type Declaration (seeDocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returnsnull. DOM method.- Returns:
- null: The Saxon tree model does not include the document type information.
-
getImplementation
public org.w3c.dom.DOMImplementation getImplementation()
Get aDOMImplementationobject that handles this document. A DOM application may use objects from multiple implementations. DOM method.
-
createElement
public org.w3c.dom.Element createElement(java.lang.String tagName) throws org.w3c.dom.DOMExceptionCreates an element of the type specified. DOM method: always fails, because the Saxon tree is not updateable.- Throws:
org.w3c.dom.DOMException
-
createDocumentFragment
public org.w3c.dom.DocumentFragment createDocumentFragment()
Creates an emptyDocumentFragmentobject.- Returns:
- A new
DocumentFragment. DOM method: returns null, because the Saxon tree is not updateable.
-
createTextNode
public org.w3c.dom.Text createTextNode(java.lang.String data)
Create aTextnode given the specified string. DOM method: returns null, because the Saxon tree is not updateable.- Parameters:
data- The data for the node.- Returns:
- The new
Textobject.
-
createComment
public org.w3c.dom.Comment createComment(java.lang.String data)
Create aCommentnode given the specified string. DOM method: returns null, because the Saxon tree is not updateable.- Parameters:
data- The data for the node.- Returns:
- The new
Commentobject.
-
createCDATASection
public org.w3c.dom.CDATASection createCDATASection(java.lang.String data) throws org.w3c.dom.DOMExceptionCreate aCDATASectionnode whose value is the specified string. DOM method: always fails, because the Saxon tree is not updateable.- Parameters:
data- The data for theCDATASectioncontents.- Returns:
- The new
CDATASectionobject. - 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.DOMExceptionCreate aProcessingInstructionnode given the specified name and data strings. DOM method: returns null, because the Saxon tree is not updateable.- Parameters:
target- The target part of the processing instruction.data- The data for the node.- Returns:
- The new
ProcessingInstructionobject. - 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.DOMExceptionCreate anAttrof the given name. DOM method: always fails, because the Saxon tree is not updateable.- Parameters:
name- The name of the attribute.- Returns:
- A new
Attrobject with thenodeNameattribute set toname, andlocalName,prefix, andnamespaceURIset tonull. - 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.DOMExceptionCreate anEntityReferenceobject. DOM method: returns null, because the Saxon tree is not updateable.- Parameters:
name- The name of the entity to reference.- Returns:
- The new
EntityReferenceobject. - 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)
Return aNodeListof all theElementswith a given tag name in the order in which they are encountered in a preorder traversal of theDocumenttree.- Parameters:
tagname- The name of the tag to match on. The special value "*" matches all tags.- Returns:
- A new
NodeListobject containing all the matchedElements.
-
importNode
public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep) throws org.w3c.dom.DOMExceptionImport a node from another document to this document. DOM method: always fails, because the Saxon tree is not updateable.- Throws:
org.w3c.dom.DOMException- Since:
- DOM Level 2
-
createElementNS
public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws org.w3c.dom.DOMExceptionCreate an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method. DOM method: always fails, because the Saxon tree is not updateable.- Parameters:
namespaceURI- The namespace URI of the element to create.qualifiedName- The qualified name of the element type to instantiate.- Returns:
- A new
Elementobject - Throws:
org.w3c.dom.DOMException
-
createAttributeNS
public org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws org.w3c.dom.DOMExceptionCreate an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method. DOM method: returns null, because the Saxon tree is not updateable.- Parameters:
namespaceURI- The namespace URI of the attribute to create.qualifiedName- The qualified name of the attribute to instantiate.- Returns:
- A new
Attrobject. - Throws:
org.w3c.dom.DOMException
-
getElementsByTagNameNS
public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)Return aNodeListof all theElementswith a given local name and namespace URI in the order in which they are encountered in a preorder traversal of theDocumenttree. DOM method.- 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
NodeListobject containing all the matchedElements. - Since:
- DOM Level 2
-
getElementById
public org.w3c.dom.Element getElementById(java.lang.String elementId)
Return theElementwhoseIDis given byelementId. If no such element exists, returnsnull. Behavior is not defined if more than one element has thisID. 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 returnnull.- Parameters:
elementId- The uniqueidvalue for an element.- Returns:
- The matching element, or null if there is none.
- Since:
- DOM Level 2
-
getTagName
public java.lang.String getTagName()
The name of the element (DOM interface).
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Retrieves an attribute value by name. Namespace declarations will not be retrieved. DOM interface.- Parameters:
name- The QName of the attribute to retrieve.- Returns:
- The
Attrvalue as a string, or the empty string if that attribute does not have a specified or default value.
-
getAttributeNode
public org.w3c.dom.Attr getAttributeNode(java.lang.String name)
Retrieves an attribute node by name. Namespace declarations will not be retrieved.
To retrieve an attribute node by qualified name and namespace URI, use thegetAttributeNodeNSmethod.- Parameters:
name- The name (nodeName) of the attribute to retrieve.- Returns:
- The
Attrnode with the specified name (nodeName) ornullif there is no such attribute.
-
setAttributeNode
public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr) throws org.w3c.dom.DOMExceptionAdds a new attribute node. Always fails- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
removeAttribute
public void removeAttribute(java.lang.String oldAttr) throws org.w3c.dom.DOMExceptionRemoves the specified attribute. Always fails- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
removeAttributeNode
public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr) throws org.w3c.dom.DOMExceptionRemoves the specified attribute node. Always fails- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
getAttributeNS
public java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.- Parameters:
namespaceURI- The namespace URI of the attribute to retrieve.localName- The local name of the attribute to retrieve.- Returns:
- The
Attrvalue as a string, or the empty string if that attribute does not have a specified or default value. - Since:
- DOM Level 2
-
setAttributeNS
public void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value) throws org.w3c.dom.DOMExceptionAdds a new attribute. Always fails.- Parameters:
namespaceURI- The namespace URI of the attribute to create or alter.qualifiedName- The qualified name of the attribute to create or alter.value- The value to set in string form.- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
removeAttributeNS
public void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName) throws org.w3c.dom.DOMExceptionRemoves an attribute by local name and namespace URI. Always fails- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.- Since:
- DOM Level 2
-
getAttributeNodeNS
public org.w3c.dom.Attr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)Retrieves anAttrnode by local name and namespace URI. DOM method, so namespace declarations count as attributes.- Parameters:
namespaceURI- The namespace URI of the attribute to retrieve.localName- The local name of the attribute to retrieve.- Returns:
- The
Attrnode with the specified attribute local name and namespace URI ornullif there is no such attribute. - Since:
- DOM Level 2
-
setAttributeNodeNS
public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr) throws org.w3c.dom.DOMExceptionAdd a new attribute. Always fails.- Parameters:
newAttr- TheAttrnode to add to the attribute list.- Returns:
- If the
newAttrattribute replaces an existing attribute with the same local name and namespace URI , the replacedAttrnode is returned, otherwisenullis returned. - Throws:
org.w3c.dom.DOMException-
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.- Since:
- DOM Level 2
-
hasAttribute
public boolean hasAttribute(java.lang.String name)
Returnstruewhen an attribute with a given name is specified on this element or has a default value,falseotherwise. Namespace declarations will not be retrieved.- Parameters:
name- The name of the attribute to look for.- Returns:
trueif an attribute with the given name is specified on this element or has a default value,falseotherwise.- Since:
- DOM Level 2
-
hasAttributeNS
public boolean hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Returnstruewhen an attribute with a given local name and namespace URI is specified on this element or has a default value,falseotherwise. Namespace declarations will not be retrieved.- Parameters:
namespaceURI- The namespace URI of the attribute to look for.localName- The local name of the attribute to look for.- Returns:
trueif an attribute with the given local name and namespace URI is specified or has a default value on this element,falseotherwise.- Since:
- DOM Level 2
-
getData
public java.lang.String getData()
Get the character data of a Text or Comment node. DOM method.
-
setData
public void setData(java.lang.String data) throws org.w3c.dom.DOMExceptionSet the character data of a Text or Comment node. DOM method: always fails, Saxon tree is immutable.- Throws:
org.w3c.dom.DOMException
-
getLength
public int getLength()
Get the length of a Text or Comment node. DOM method.
-
substringData
public java.lang.String substringData(int offset, int count) throws org.w3c.dom.DOMExceptionExtract a range of data from a Text or Comment node. DOM method.- Parameters:
offset- Start offset of substring to extract.count- The number of 16-bit units to extract.- Returns:
- The specified substring. If the sum of
offsetandcountexceeds thelength, then all 16-bit units to the end of the data are returned. - Throws:
org.w3c.dom.DOMException- INDEX_SIZE_ERR: Raised if the specifiedoffsetis negative or greater than the number of 16-bit units indata, or if the specifiedcountis negative.
-
appendData
public void appendData(java.lang.String arg) throws org.w3c.dom.DOMExceptionAppend the string to the end of the character data of the node. DOM method: always fails.- Parameters:
arg- TheDOMStringto append.- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
insertData
public void insertData(int offset, java.lang.String arg) throws org.w3c.dom.DOMExceptionInsert a string at the specified character offset. DOM method: always fails.- Parameters:
offset- The character offset at which to insert.arg- TheDOMStringto insert.- Throws:
org.w3c.dom.DOMException
-
deleteData
public void deleteData(int offset, int count) throws org.w3c.dom.DOMExceptionRemove a range of 16-bit units from the node. DOM method: always fails.- Parameters:
offset- The offset from which to start removing.count- The number of 16-bit units to delete.- Throws:
org.w3c.dom.DOMException
-
replaceData
public void replaceData(int offset, int count, java.lang.String arg) throws org.w3c.dom.DOMExceptionReplace the characters starting at the specified 16-bit unit offset with the specified string. DOM method: always fails.- Parameters:
offset- The offset from which to start replacing.count- The number of 16-bit units to replace.arg- TheDOMStringwith which the range must be replaced.- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
splitText
public org.w3c.dom.Text splitText(int offset) throws org.w3c.dom.DOMExceptionBreak this node into two nodes at the specified offset, keeping both in the tree as siblings. DOM method, always fails.- Parameters:
offset- The 16-bit unit offset at which to split, starting from 0.- Returns:
- The new node, of the same type as this node.
- Throws:
org.w3c.dom.DOMException
-
getName
public java.lang.String getName()
Get the name of an attribute node (the QName) (DOM method)
-
getValue
public java.lang.String getValue()
Return the character value of an attribute node (DOM method)- Returns:
- the attribute value
-
getSpecified
public boolean getSpecified()
If this attribute was explicitly given a value in the original document, this istrue; otherwise, it isfalse. (DOM method)- Returns:
- Always true in this implementation.
-
setValue
public void setValue(java.lang.String value) throws org.w3c.dom.DOMExceptionSet the value of an attribute node. (DOM method). Always fails (because tree is readonly)- Throws:
org.w3c.dom.DOMException
-
getOwnerElement
public org.w3c.dom.Element getOwnerElement()
TheElementnode this attribute is attached to ornullif this attribute is not in use.- Since:
- DOM Level 2
-
getSchemaTypeInfo
public org.w3c.dom.TypeInfo getSchemaTypeInfo()
The type information associated with this attribute. While the type information contained in this attribute is guarantee to be correct after loading the document or invokingDocument.normalizeDocument(),schemaTypeInfomay not be reliable if the node was moved.This implementation always returns null;
- Since:
- DOM Level 3
-
isId
public boolean isId()
Returns whether this attribute is known to be of type ID (i.e. to contain an identifier for its owner element) or not.This implementation always returns false.
- Since:
- DOM Level 3
-
compareDocumentPosition
public short compareDocumentPosition(org.w3c.dom.Node other) throws org.w3c.dom.DOMExceptionCompares the reference node, i.e. the node on which this method is being called, with a node, i.e. the one passed as a parameter, with regard to their position in the document and according to the document order.- Specified by:
compareDocumentPositionin interfaceorg.w3c.dom.Node- Parameters:
other- The node to compare against the reference node.- Returns:
- Returns how the node is positioned relatively to the reference node.
- Throws:
org.w3c.dom.DOMException- NOT_SUPPORTED_ERR: when the compared nodes are from different DOM implementations that do not coordinate to return consistent implementation-specific results.- Since:
- DOM Level 3
-
getFeature
public java.lang.Object getFeature(java.lang.String feature, java.lang.String version)This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in . This method also allow the implementation to provide specialized objects which do not support theNodeinterface.- Specified by:
getFeaturein interfaceorg.w3c.dom.Node- Parameters:
feature- The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.version- This is the version number of the feature to test.- Returns:
- Returns an object which implements the specialized APIs of
the specified feature and version, if any, or
nullif there is no object which implements interfaces associated with that feature. If theDOMObjectreturned by this method implements theNodeinterface, it must delegate to the primary coreNodeand not return results inconsistent with the primary coreNodesuch as attributes, childNodes, etc.The Saxon implementation of this method always returns null
- Since:
- DOM Level 3
-
getTextContent
public java.lang.String getTextContent() throws org.w3c.dom.DOMExceptionThis attribute returns the text content of this node and its descendants. When it is defined to benull, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty ornull, replaced by a singleTextnode containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attributeText.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null The Saxon implementation returns the same result as getStringValue()
- Specified by:
getTextContentin interfaceorg.w3c.dom.Node- Throws:
org.w3c.dom.DOMException- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMStringvariable on the implementation platform.- Since:
- DOM Level 3
-
getUserData
public java.lang.Object getUserData(java.lang.String key)
Retrieves the object associated to a key on a this node. The object must first have been set to this node by callingsetUserDatawith the same key.The Saxon implementation always returns null.
- Specified by:
getUserDatain interfaceorg.w3c.dom.Node- Parameters:
key- The key the object is associated to.- Returns:
- Returns the
DOMUserDataassociated to the given key on this node, ornullif there was none. - Since:
- DOM Level 3
-
isDefaultNamespace
public boolean isDefaultNamespace(java.lang.String namespaceURI)
This method checks if the specifiednamespaceURIis the default namespace or not.- Specified by:
isDefaultNamespacein interfaceorg.w3c.dom.Node- Parameters:
namespaceURI- The namespace URI to look for.- Returns:
- Returns
trueif the specifiednamespaceURIis the default namespace,falseotherwise. - Since:
- DOM Level 3
-
isEqualNode
public boolean isEqualNode(org.w3c.dom.Node arg)
Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested withNode.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:- The two nodes are of the same type.
- The following string
attributes are equal:
nodeName,localName,namespaceURI,prefix,nodeValue. This is: they are bothnull, or they have the same length and are character for character identical. - The
attributesNamedNodeMapsare equal. This is: they are bothnull, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index. - The
childNodesNodeListsare equal. This is: they are bothnull, or they have the same length and contain equal nodes at the same index. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.
For twoDocumentTypenodes to be equal, the following conditions must also be satisfied:- The following string attributes
are equal:
publicId,systemId,internalSubset. - The
entitiesNamedNodeMapsare equal. - The
notationsNamedNodeMapsare equal.
On the other hand, the following do not affect equality: theownerDocument,baseURI, andparentNodeattributes, thespecifiedattribute forAttrnodes, theschemaTypeInfoattribute forAttrandElementnodes, theText.isElementContentWhitespaceattribute forTextnodes, as well as any user data or event listeners registered on the nodes.Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.
- Specified by:
isEqualNodein interfaceorg.w3c.dom.Node- Parameters:
arg- The node to compare equality with.- Returns:
- Returns
trueif the nodes are equal,falseotherwise. - Since:
- DOM Level 3
-
isSameNode
public boolean isSameNode(org.w3c.dom.Node other)
Returns whether this node is the same node as the given one.
This method provides a way to determine whether twoNodereferences returned by the implementation reference the same object. When twoNodereferences are references to the same object, even if through a proxy, the references may be used completely interchangeably, such that all attributes have the same values and calling the same DOM method on either reference always has exactly the same effect.- Specified by:
isSameNodein interfaceorg.w3c.dom.Node- Parameters:
other- The node to test against.- Returns:
- Returns
trueif the nodes are the same,falseotherwise. - Since:
- DOM Level 3
-
lookupNamespaceURI
public java.lang.String lookupNamespaceURI(java.lang.String prefix)
Look up the namespace URI associated to the given prefix, starting from this node.
See for details on the algorithm used by this method.- Specified by:
lookupNamespaceURIin interfaceorg.w3c.dom.Node- Parameters:
prefix- The prefix to look for. If this parameter isnull, the method will return the default namespace URI if any.- Returns:
- Returns the associated namespace URI or
nullif none is found. - Since:
- DOM Level 3
-
lookupPrefix
public java.lang.String lookupPrefix(java.lang.String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from this node. The default namespace declarations are ignored by this method.
See for details on the algorithm used by this method.- Specified by:
lookupPrefixin interfaceorg.w3c.dom.Node- Parameters:
namespaceURI- The namespace URI to look for.- Returns:
- Returns an associated namespace prefix if found or
nullif none is found. If more than one prefix are associated to the namespace prefix, the returned namespace prefix is implementation dependent. - Since:
- DOM Level 3
-
setTextContent
public void setTextContent(java.lang.String textContent) throws org.w3c.dom.DOMExceptionThis attribute returns the text content of this node and its descendants. When it is defined to benull, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty ornull, replaced by a singleTextnode containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attributeText.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
setTextContentin interfaceorg.w3c.dom.Node- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.- Since:
- DOM Level 3
-
setUserData
public java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)Associate an object to a key on this node. The object can later be retrieved from this node by callinggetUserDatawith the same key.- Specified by:
setUserDatain interfaceorg.w3c.dom.Node- Parameters:
key- The key to associate the object to.data- The object to associate to the given key, ornullto remove any existing association to that key.handler- The handler to associate to that key, ornull.- Returns:
- Returns the
DOMUserDatapreviously associated to the given key on this node, ornullif there was none. - Since:
- DOM Level 3
-
getWholeText
public java.lang.String getWholeText()
Returns all text ofTextnodes logically-adjacent text nodes to this node, concatenated in document order.
For instance, in the example belowwholeTexton theTextnode that contains "bar" returns "barfoo", while on theTextnode that contains "foo" it returns "barfoo".- Since:
- DOM Level 3
-
isElementContentWhitespace
public boolean isElementContentWhitespace()
Returns whether this text node contains element content whitespace, often abusively called "ignorable whitespace". The text node is determined to contain whitespace in element content during the load of the document or if validation occurs while usingDocument.normalizeDocument().The Saxon implementation always returns false.
- Since:
- DOM Level 3
-
replaceWholeText
public org.w3c.dom.Text replaceWholeText(java.lang.String content) throws org.w3c.dom.DOMExceptionReplaces the text of the current node and all logically-adjacent text nodes with the specified text. All logically-adjacent text nodes are removed including the current node unless it was the recipient of the replacement text.
This method returns the node which received the replacement text. The returned node is:null, when the replacement text is the empty string;- the current node, except when the current node is read-only;
- a new
Textnode of the same type (TextorCDATASection) as the current node inserted at the location of the replacement.
For instance, in the above example callingreplaceWholeTexton theTextnode that contains "bar" with "yo" in argument results in the following:
Where the nodes to be removed are read-only descendants of anEntityReference, theEntityReferencemust be removed instead of the read-only nodes. If anyEntityReferenceto be removed has descendants that are notEntityReference,Text, orCDATASectionnodes, thereplaceWholeTextmethod must fail before performing any modification of the document, raising aDOMExceptionwith the codeNO_MODIFICATION_ALLOWED_ERR.
For instance, in the example below callingreplaceWholeTexton theTextnode that contains "bar" fails, because theEntityReferencenode "ent" contains anElementnode which cannot be removed.- Parameters:
content- The content of the replacingTextnode.- Returns:
- The
Textnode created with the specified content. - Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if one of theTextnodes being replaced is readonly.- Since:
- DOM Level 3
-
setIdAttribute
public void setIdAttribute(java.lang.String name, boolean isId) throws org.w3c.dom.DOMExceptionIf the parameterisIdistrue, this method declares the specified attribute to be a user-determined ID attribute . This affects the value ofAttr.isIdand the behavior ofDocument.getElementById, but does not change any schema that may be in use, in particular this does not affect theAttr.schemaTypeInfoof the specifiedAttrnode. Use the valuefalsefor the parameterisIdto undeclare an attribute for being a user-determined ID attribute.
To specify an attribute by local name and namespace URI, use thesetIdAttributeNSmethod.- Parameters:
name- The name of the attribute.isId- Whether the attribute is a of type ID.- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element.- Since:
- DOM Level 3
-
setIdAttributeNode
public void setIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId) throws org.w3c.dom.DOMExceptionIf the parameterisIdistrue, this method declares the specified attribute to be a user-determined ID attribute . This affects the value ofAttr.isIdand the behavior ofDocument.getElementById, but does not change any schema that may be in use, in particular this does not affect theAttr.schemaTypeInfoof the specifiedAttrnode. Use the valuefalsefor the parameterisIdto undeclare an attribute for being a user-determined ID attribute.- Parameters:
idAttr- The attribute node.isId- Whether the attribute is a of type ID.- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element.- Since:
- DOM Level 3
-
setIdAttributeNS
public void setIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId) throws org.w3c.dom.DOMExceptionIf the parameterisIdistrue, this method declares the specified attribute to be a user-determined ID attribute . This affects the value ofAttr.isIdand the behavior ofDocument.getElementById, but does not change any schema that may be in use, in particular this does not affect theAttr.schemaTypeInfoof the specifiedAttrnode. Use the valuefalsefor the parameterisIdto undeclare an attribute for being a user-determined ID attribute.- Parameters:
namespaceURI- The namespace URI of the attribute.localName- The local name of the attribute.isId- Whether the attribute is a of type ID.- Throws:
org.w3c.dom.DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element.- Since:
- DOM Level 3
-
-