|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
DOM Level 3 WD Experimental: The DOM Level 3 specification is at the stage of Working Draft, which represents work in progress and thus may be updated, replaced, or obsoleted by other documents at any time.
XPathEvaluator
, which will provide evaluation of XPath 1.0
expressions with no specialized extension functions or variables. It is
expected that the XPathEvaluator
interface will be
implemented on the same object which implements the Document
interface in an implementation which supports the XPath DOM module.
XPathEvaluator
implementations may be available from other
sources that may provide support for special extension functions or
variables which are not defined in this specification. The methods of
XPathExpression should be named with more-XPath- specific names because
the interface will often be implemented by the same object which
implements document.No change.The point of interfaces is to localize the
implementing namespace. This would make the method names unnecessarily
long and complex even though there are no conflicts in the interface
itself. The new core method getInterface is designed for discovering
interfaces of additional modules that may not be directly implemented on
the objects to which they are attached. This could be used to implement
XPath on a separate object. The user only refers to the separate
interfaces and not the proprietary aggregate implementation.Should entity
refs be supported so that queries can be made on them?No change.We will
not do this now. They are not part of the XPath data model. Note that
they may be present in the hierarchy of returned nodes, but may not
directly be requested or returned in the node set.What does createResult
create when one wants to reuse the XPath?It is not useful.Removed method.
Should ordering be a separate flag, or a type of result that can be
requested. As a type of result, it can be better optimized in
implementations.It makes sense as a type of result. Changed.Removed
method.Implementing XPathEvaluator on Document can be a problem due to
conflicts in the names of the methods.The working group finds no better
solution. GetInterface in Level 3 permits the object to be implemented
separately. We should be committed to this. We will leave this issue open
to see if we get more feedback on it.How does this interface adapt to
XPath 2.0 and other query languages.No change.This interface is not
intended to adapt to XPath 2.0 or other languages. The models of these
are likely to be incompatible enough to require new APIs.For alternate
implementations that can use this API, it can be obtained from different
sources.Support for custom variables and functions would be very useful.
No change.It is possible for an implementation to supply alternative
sources of an XPathEvaluator that can be customized with a custom
variable and function context. We do not specify how this is
accomplished. It is too complex to address in this version of the XPath
DOM.
See also the Document Object Model (DOM) Level 3 XPath Specification.
Method Summary | |
XPathExpression |
createExpression(java.lang.String expression,
XPathNSResolver resolver)
Creates a parsed XPath expression with resolved namespaces. |
XPathNSResolver |
createNSResolver(Node nodeResolver)
Adapts any DOM node to resolve namespaces so that an XPath expression can be easily evaluated relative to the context of the node where it appeared within the document. |
java.lang.Object |
evaluate(java.lang.String expression,
Node contextNode,
XPathNSResolver resolver,
short type,
java.lang.Object result)
Evaluates an XPath expression string and returns a result of the specified type if possible.An exception needs to be raised when an XPath expression is evaluated on a node such as an EntityReference which cannot serve as an XPath context node.Done: NOT_SUPPORTED_ERR.A description is needed of what happens when the node passed to the evaluation function is a Text or CDATASection in the DOM case where the text may be fragmented between text nodes.Done.Eliminate the evaluate method from XPathEvaluator, forcing everyone to create expressions.No change.Any implementor can easily implement it by creating an expression. |
Method Detail |
public XPathExpression createExpression(java.lang.String expression, XPathNSResolver resolver) throws XPathException, DOMException
expression
- The XPath expression string to be parsed.resolver
- The resolver
permits translation of
prefixes within the XPath expression into appropriate namespace URIs
. If this is specified as null
, any namespace prefix
within the expression will result in DOMException
being thrown with the code NAMESPACE_ERR
.
XPathException
- INVALID_EXPRESSION_ERR: Raised if the expression is not legal
according to the rules of the XPathEvaluator
i
DOMException
- NAMESPACE_ERR: Raised if the expression contains namespace prefixes
which cannot be resolved by the specified
XPathNSResolver
.public XPathNSResolver createNSResolver(Node nodeResolver)
lookupNamespacePrefix
on Node
.It
should be possible to create an XPathNSResolver that does not rely on
a node, but which implements a map of resolutions that can be added
to by the application.No change.The application can easily create
this, which was why the interface was designed as it is. The
specification will not require a specific factory at this time for
application populated maps.There should be type restrictions on which
types of nodes may be adapted by createNSResolver.No change.The
namespace methods on the Node interface of the Level 3 core may be
called without exception on all node types. In some cases no non-null
namespace resolution will ever be returned. That is what may also be
expected of this adapter.
nodeResolver
- The node to be used as a context for namespace
resolution.
XPathNSResolver
which resolves namespaces with
respect to the definitions in scope for a specified node.public java.lang.Object evaluate(java.lang.String expression, Node contextNode, XPathNSResolver resolver, short type, java.lang.Object result) throws XPathException, DOMException
expression
- The XPath expression string to be parsed and
evaluated.contextNode
- The context
is context node for the
evaluation of this XPath expression. If the XPathEvaluator was
obtained by casting the Document
then this must be
owned by the same document and must be a Document
,
Element
, Attribute
, Text
,
CDATASection
, Comment
,
ProcessingInstruction
, or XPathNamespace
node. If the context node is a Text
or a
CDATASection
, then the context is interpreted as the
whole logical text node as seen by XPath, unless the node is empty
in which case it may not serve as the XPath context.resolver
- The resolver
permits translation of
prefixes within the XPath expression into appropriate namespace URIs
. If this is specified as null
, any namespace prefix
within the expression will result in DOMException
being thrown with the code NAMESPACE_ERR
.type
- If a specific type
is specified, then the
result will be coerced to return the specified type relying on
XPath type conversions and fail if the desired coercion is not
possible. This must be one of the type codes of
XPathResult
.result
- The result
specifies a specific
XPathResult
which may be reused and returned by this
method. If this is specified as null
or the
implementation cannot reuse the specified result, a new
XPathResult
will be constructed and returned.
XPathException
- INVALID_EXPRESSION_ERR: Raised if the expression is not legal
according to the rules of the XPathEvaluator
i
DOMException
- NAMESPACE_ERR: Raised if the expression contains namespace prefixes
which cannot be resolved by the specified
XPathNSResolver
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |