public interface XNode extends Comparable<XNode>
Modifier and Type | Interface and Description |
---|---|
static class |
XNode.Type
The type of an XNode as returned by
type() . |
Modifier and Type | Method and Description |
---|---|
Iterator<XNode> |
attributes()
Returns iterator over the attributes contained in this element
node.
|
String |
attributeValue(Name name)
Returns the value of attribute having specified name contained in this
element node.
|
int |
compareTo(XNode other)
Compares this node with specified object which must be an XNode too.
|
String |
data()
Returns the value of this attribute node or the text contained in this
text, comment or processing-instruction node.
|
XNode |
deepCopy()
Returns a deep copy of this node.
|
XNode |
document()
Returns the document containing this node.
|
boolean |
equals(Object other)
Tests if this node is equivalent to specified object.
|
XNode |
firstChild()
Returns the first child node of this element or document node.
|
XNode |
following()
Returns the node following this node.
|
URL |
getBaseURL()
Returns the URL which can be used to resolve URLs which are relative to
this node.
|
String |
getLabel()
Returns a string which represents this XNode.
|
URL |
getSourceURL()
Returns the URL of the file from which this XNode has been loaded.
|
XNode |
lastChild()
Returns the last child node of this element or document node.
|
Name |
name()
Returns the name of this element node, the name of this attribute node
or the target of this processing-instruction node.
|
NamespacePrefixMap |
namespacePrefixMap()
Returns the NamespacePrefixMap which can be used to map prefixes to
namespaces and namespaces to prefixes in the context of this node.
|
XNode |
parent()
Returns the parent of the node.
|
XNode |
preceding()
Returns the node preceding this node.
|
XNode.Type |
type()
Returns the type of this node.
|
XNode.Type type()
XNode document()
XNode parent()
null
.XNode following()
null
for an
attribute or a document node.XNode preceding()
null
for an
attribute or a document node.Name name()
null
for all other types of nodes.
The target of a processing-instruction has no namespace.
String data()
null
for all other types of nodes.NamespacePrefixMap namespacePrefixMap()
XNode firstChild()
null
for all other types of nodes.XNode lastChild()
null
for all other types of nodes.String attributeValue(Name name)
null
if this node is not an element
node.Iterator<XNode> attributes()
null
if this node is not an element node.
This iterator does not support the remove
method.
boolean equals(Object other)
==
because attribute nodes
are synthesized when needed to (that is, they are not real nodes).int compareTo(XNode other)
Document order has no meaning for attribute nodes contained in the same element. Attribute nodes contained in the same element are compared by their names.
The two nodes may belong to two different documents. In such case, the two documents are compared by their URLs.
compareTo
in interface Comparable<XNode>
XNode deepCopy()
URL getSourceURL()
null
if such URL is unknown.
This URL is mainly useful in error messages or in a GUI.
If you need to resolve URLs which are relative to this node,
use getBaseURL()
instead.
URL getBaseURL()
null
if such URL is unknown.
This URL is often the same as the one returned by
getSourceURL()
, but not always. Example:
<root> <list xml:base="file:///home/john/"> <item/><item/><item/> </list> </root>If the SourceURL of element root is "file:///tmp/doc.xml", then the SourceURL of element list is also "file:///tmp/doc.xml", but the BaseURL of this element is "file:///home/john/".
String getLabel()