Package net.sf.saxon.dom
Class ElementOverNodeInfo
- java.lang.Object
-
- net.sf.saxon.dom.NodeOverNodeInfo
-
- net.sf.saxon.dom.ElementOverNodeInfo
-
- All Implemented Interfaces:
org.w3c.dom.Element,org.w3c.dom.Node
public class ElementOverNodeInfo extends NodeOverNodeInfo implements org.w3c.dom.Element
This class is an implementation of the DOM Element class that wraps a Saxon NodeInfo representation of an element node.The class provides read-only access to the tree; methods that request updates all fail with an UnsupportedOperationException.
Note that contrary to the DOM specification, this implementation does not expose namespace declarations as attributes.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.dom.NodeOverNodeInfo
node
-
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 ElementOverNodeInfo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.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.org.w3c.dom.NodeListgetElementsByTagName(java.lang.String name)Returns aNodeListof all descendantElementswith a given tag name, in document order.org.w3c.dom.NodeListgetElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)Returns aNodeListof all the descendantElementswith a given local name and namespace URI in document order.org.w3c.dom.TypeInfogetSchemaTypeInfo()Get the schema type information for this node.java.lang.StringgetTagName()The name of the element (DOM interface).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.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.voidsetAttribute(java.lang.String name, java.lang.String value)Adds a new attribute.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.voidsetIdAttribute(java.lang.String name, boolean isId)Mark an attribute as an ID.voidsetIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId)Mark an attribute as an ID.voidsetIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId)Mark an attribute as an ID.-
Methods inherited from class net.sf.saxon.dom.NodeOverNodeInfo
appendChild, cloneNode, compareDocumentPosition, disallowUpdate, equals, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUnderlyingNodeInfo, getUserData, hasAttributes, hasChildNodes, hashCode, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData, wrap
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
-
-
-
Method Detail
-
getTagName
public java.lang.String getTagName()
The name of the element (DOM interface).- Specified by:
getTagNamein interfaceorg.w3c.dom.Element
-
getElementsByTagName
public org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
Returns aNodeListof all descendantElementswith a given tag name, in document order.- Specified by:
getElementsByTagNamein interfaceorg.w3c.dom.Element- Parameters:
name- The name of the tag to match on. The special value "*" matches all tags.- Returns:
- A list of matching
Elementnodes.
-
getElementsByTagNameNS
public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName) throws org.w3c.dom.DOMExceptionReturns aNodeListof all the descendantElementswith a given local name and namespace URI in document order.- Specified by:
getElementsByTagNameNSin interfaceorg.w3c.dom.Element- 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. - Throws:
org.w3c.dom.DOMException- NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature"XML"and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).- Since:
- DOM Level 2
-
getAttributes
public org.w3c.dom.NamedNodeMap getAttributes()
Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise. Note that namespace declarations are treated as attributes.- Specified by:
getAttributesin interfaceorg.w3c.dom.Node- Overrides:
getAttributesin classNodeOverNodeInfo
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Retrieves an attribute value by name.- Specified by:
getAttributein interfaceorg.w3c.dom.Element- 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.
To retrieve an attribute node by qualified name and namespace URI, use thegetAttributeNodeNSmethod.- Specified by:
getAttributeNodein interfaceorg.w3c.dom.Element- 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- Specified by:
setAttributeNodein interfaceorg.w3c.dom.Element- 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- Specified by:
removeAttributein interfaceorg.w3c.dom.Element- 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- Specified by:
removeAttributeNodein interfaceorg.w3c.dom.Element- 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. This implementation does not expose namespace nodes as attributes.- Specified by:
getAttributeNSin interfaceorg.w3c.dom.Element- 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
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value) throws org.w3c.dom.DOMExceptionAdds a new attribute. Always fails- Specified by:
setAttributein interfaceorg.w3c.dom.Element- Parameters:
name- The name of the attribute to create or alter.value- Value to set in string form.- Throws:
org.w3c.dom.DOMException- INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
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.- Specified by:
setAttributeNSin interfaceorg.w3c.dom.Element- 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- Specified by:
removeAttributeNSin interfaceorg.w3c.dom.Element- 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. This implementation does not expose namespace nodes as attributes.- Specified by:
getAttributeNodeNSin interfaceorg.w3c.dom.Element- 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.- Specified by:
setAttributeNodeNSin interfaceorg.w3c.dom.Element- 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.- Specified by:
hasAttributein interfaceorg.w3c.dom.Element- 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.- Specified by:
hasAttributeNSin interfaceorg.w3c.dom.Element- 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
-
setIdAttribute
public void setIdAttribute(java.lang.String name, boolean isId) throws java.lang.UnsupportedOperationExceptionMark an attribute as an ID. Always fails.- Specified by:
setIdAttributein interfaceorg.w3c.dom.Element- Throws:
java.lang.UnsupportedOperationException- always
-
setIdAttributeNS
public void setIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean isId) throws java.lang.UnsupportedOperationExceptionMark an attribute as an ID. Always fails.- Specified by:
setIdAttributeNSin interfaceorg.w3c.dom.Element- Throws:
java.lang.UnsupportedOperationException- always
-
setIdAttributeNode
public void setIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId) throws java.lang.UnsupportedOperationExceptionMark an attribute as an ID. Always fails.- Specified by:
setIdAttributeNodein interfaceorg.w3c.dom.Element- Throws:
java.lang.UnsupportedOperationException- always
-
getSchemaTypeInfo
public org.w3c.dom.TypeInfo getSchemaTypeInfo()
Get the schema type information for this node.- Specified by:
getSchemaTypeInfoin interfaceorg.w3c.dom.Element- Returns:
- the type information. Returns null for an untyped node.
-
-