Interface for navigating around an arbitrary object
model, using XPath semantics.
There is a method to obtain a
java.util.Iterator
,
for each axis specified by XPath. If the target object model
does not support the semantics of a particular axis, an
UnsupportedAxisException
is to be thrown. If there are
no nodes on that axis, an empty iterator should be returned.
getAncestorAxisIterator
public Iterator getAncestorAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the ancestor
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getAncestorOrSelfAxisIterator
public Iterator getAncestorOrSelfAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the
ancestor-or-self
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getAttributeAxisIterator
public Iterator getAttributeAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the attribute
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getAttributeName
public String getAttributeName(Object attr)
Retrieve the local name of the given attribute node.
attr
- the context attribute node
- the local name of the attribute node
getAttributeNamespaceUri
public String getAttributeNamespaceUri(Object attr)
Retrieve the namespace URI of the given attribute node.
attr
- the context attribute node
- the namespace URI of the attribute node
getAttributeQName
public String getAttributeQName(Object attr)
Retrieve the qualified name of the given attribute node.
attr
- the context attribute node
- the qualified name of the attribute node
getAttributeStringValue
public String getAttributeStringValue(Object attr)
Retrieve the string-value of an attribute node.
This should be the XML 1.0 normalized attribute value.
This may be the empty string but must not be null.
attr
- the attribute node
- the string-value of the node
getChildAxisIterator
public Iterator getChildAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the child
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getCommentStringValue
public String getCommentStringValue(Object comment)
Retrieve the string-value of a comment node.
This may be the empty string if the comment is empty,
but must not be null.
comment
- the comment node
- the string-value of the node
getDescendantAxisIterator
public Iterator getDescendantAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the descendant
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getDescendantOrSelfAxisIterator
public Iterator getDescendantOrSelfAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the
descendant-or-self
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getDocument
public Object getDocument(String uri)
throws FunctionCallException
Loads a document from the given URI
uri
- the URI of the document to load
getDocumentNode
public Object getDocumentNode(Object contextNode)
Returns the document node that contains the given context node.
contextNode
- the context node
- the document of the context node
getElementById
public Object getElementById(Object contextNode,
String elementId)
Returns the element whose ID is given by elementId.
If no such element exists, returns null.
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.
contextNode
- a node from the document in which to look for the
idelementId
- id to look for
- element whose ID is given by elementId, or null if no such
element exists in the document or if the implementation
does not know about attribute types
getElementName
public String getElementName(Object element)
Retrieve the local name of the given element node.
element
- the context element node
- the local name of the element node
getElementNamespaceUri
public String getElementNamespaceUri(Object element)
Retrieve the namespace URI of the given element node.
element
- the context element node
- the namespace URI of the element node
getElementQName
public String getElementQName(Object element)
Retrieve the qualified name of the given element node.
element
- the context element node
- the qualified name of the element node
getElementStringValue
public String getElementStringValue(Object element)
Retrieve the string-value of an element node.
This may be the empty string if the element is empty,
but must not be null.
element
- the comment node.
- the string-value of the node.
getFollowingAxisIterator
public Iterator getFollowingAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the following
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getFollowingSiblingAxisIterator
public Iterator getFollowingSiblingAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the
following-sibling
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getNamespaceAxisIterator
public Iterator getNamespaceAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the namespace
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getNamespacePrefix
public String getNamespacePrefix(Object ns)
Retrieve the namespace prefix of a namespace node.
- the prefix associated with the node
getNamespaceStringValue
public String getNamespaceStringValue(Object ns)
Retrieve the string-value of a namespace node.
This is generally the namespace URI.
This may be the empty string but must not be null.
- the string-value of the node
getNodeType
public short getNodeType(Object node)
Returns a number that identifies the type of node that the given
object represents in this navigator.
getParentAxisIterator
public Iterator getParentAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the parent
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getParentNode
public Object getParentNode(Object contextNode)
throws UnsupportedAxisException
Returns the parent of the given context node.
The parent of any node must either be a document
node or an element node.
contextNode
- the context node
- the parent of the context node, or null if this is a document node.
getPrecedingAxisIterator
public Iterator getPrecedingAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the preceding
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getPrecedingSiblingAxisIterator
public Iterator getPrecedingSiblingAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the
preceding-sibling
XPath axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getProcessingInstructionData
public String getProcessingInstructionData(Object pi)
Retrieve the data of a processing-instruction.
pi
- the context processing-instruction node
- the data of the processing-instruction node
getProcessingInstructionTarget
public String getProcessingInstructionTarget(Object pi)
Retrieve the target of a processing-instruction.
pi
- the context processing-instruction node
- the target of the processing-instruction node
getSelfAxisIterator
public Iterator getSelfAxisIterator(Object contextNode)
throws UnsupportedAxisException
Retrieve an Iterator
matching the self
XPath
axis.
contextNode
- the original context node
- an Iterator capable of traversing the axis, not null
getTextStringValue
public String getTextStringValue(Object text)
Retrieve the string-value of a text node.
This must not be null and should not be the empty string.
The XPath data model does not allow empty text nodes.
- the string-value of the node
isAttribute
public boolean isAttribute(Object object)
Returns whether the given object is an attribute node.
object
- the object to test
true
if the object is an attribute node,
else false
isComment
public boolean isComment(Object object)
Returns whether the given object is a comment node.
object
- the object to test
true
if the object is a comment node,
else false
isDocument
public boolean isDocument(Object object)
Returns whether the given object is a document node. A document node
is the node that is selected by the XPath expression /
.
object
- the object to test
true
if the object is a document node,
else false
isElement
public boolean isElement(Object object)
Returns whether the given object is an element node.
object
- the object to test
true
if the object is an element node,
else false
isNamespace
public boolean isNamespace(Object object)
Returns whether the given object is a namespace node.
object
- the object to test
true
if the object is a namespace node,
else false
isProcessingInstruction
public boolean isProcessingInstruction(Object object)
Returns whether the given object is a processing-instruction node.
object
- the object to test
true
if the object is a processing-instruction node,
else false
isText
public boolean isText(Object object)
Returns whether the given object is a text node.
object
- the object to test
true
if the object is a text node,
else false
parseXPath
public XPath parseXPath(String xpath)
throws SAXPathException
Returns a parsed form of the given XPath string, which will be suitable
for queries on documents that use the same navigator as this one.
xpath
- the XPath expression
- a new XPath expression object
SAXPathException
- if the string is not a syntactically
correct XPath expression
translateNamespacePrefixToUri
public String translateNamespacePrefixToUri(String prefix,
Object element)
Translate a namespace prefix to a namespace URI,
possibly
considering a particular element node.
Strictly speaking, prefix-to-URI translation should occur
irrespective of any element in the document. This method
is provided to allow a non-conforming ease-of-use enhancement.
prefix
- the prefix to translateelement
- the element to consider during translation
- the namespace URI associated with the prefix