- From: Miles Sabin <msabin@cromwellmedia.co.uk>
- Date: Wed, 3 May 2000 21:15:53 +0100
- To: www-dom-xpath@w3.org
Scott Boag wrote,
> Here's an argument for your side:
>
> void foo(Node n1, Node n2)
> {
> NodeIterator n1i = ((XPath)n1).locate("name/address", ...);
> // uses your implementation
> NodeIterator n2i = ((XPath)n2).locate("name/address", ...);
> // uses my implementation
> ...
> }
>
> i.e. in this case, the method didn't know or care which
> implementation it was using. Using an external
> implementations would make this harder, as you would have to
> match the Node implemenation to the XPath implementation.
That's the sort of thing I'd been thinking about. But: the only
thing I'm committed to is delegating the query to the
_implementation_. Whether that's done by invoking a method on
Node, or via some other route is far less important.
> You could have something like:
[snip: DOMImplementation based method]
> Which is way ugly. As compared to:
[snip: Node based method]
How about a Document based variant,
if(node.getOwnerDocument().supports("http://www.w3.org/TR/xpath"))
{
DocumentXPath doc = (DocumentXPath)node.getOwnerDocument();
XPathQuery query = doc.createQuery("name/address");
NodeIterator ni1 = query.execute(node, someContext);
// etc.
// try again with a diffent root Node and context but
// same query instance (allows implementation to compile
// query and reuse).
NodeIterator ni2 = query.execute(otherNode, someOtherContext);
// etc.
}
Remind me what the context was supposed to be for.
> I suppose an XPath implementation could do something like:
>
> Expression expr = new XPathImpl(node, "name/address");
> NodeIterator n1i =
> expr.findNodes("name/address", exprContext);
>
> ...which would allow looser coupling with the DOM
> implementation, and allow compatibility with DOM1
> implementations.
I don't follow. If you have an XPath implementation you're
free to support Level 1 DOMs whatever happens in Level 3.
Equally you're free to use that XPath implementation in the
implementation of any Level 3 XPath query API. I don't think
anyone was suggesting that you'd _have_ to have an XPath
implementation which could _only_ be used with exactly one
DOM.
Or am I missing something?
Cheers,
Miles
--
Miles Sabin Cromwell Media
Internet Systems Architect 5/6 Glenthorne Mews
+44 (0)20 8817 4030 London, W6 0LJ, England
msabin@cromwellmedia.com http://www.cromwellmedia.com/
Received on Wednesday, 3 May 2000 16:13:56 UTC