You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Frédéric Laurent <fl...@opikanoba.org> on 2004/05/03 17:12:49 UTC

XPathEvaluator and DOM 3

Hello

According to the W3C recommendation, an XPahEvaluator object could be
obtained by a cast of a Document implementation.
Then, the following code should be ok :

doc = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputsource);

XPathEvaluator evaluator = (XPathEvaluator) doc;

XPathResult result = (XPathResult) evaluator.evaluate(xpath, doc,...

right ?

But I've got
[java] java.lang.ClassCastException
[java] at test.XPathW3C.evalXpath(Unknown Source)
[java] at test.XPathW3C.main(Unknown Source)
[java] Exception in thread "main"
[java] Java Result: 1

while

XPathEvaluator evaluator = new
               org.apache.xpath.domapi.XPathEvaluatorImpl(doc);

works fine.

So my question is : this error is the consequence of the immature 
implementation of DOM 3 XPath recommendation ? and will it work as 
described in my first example ?

thanks in advance.

regards

-- 
XPath free testing software :  http://www.opikanoba.org/lantern/
Frédéric Laurent                        http://www.opikanoba.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Re: XPathEvaluator and DOM 3

Posted by Frédéric Laurent <fl...@opikanoba.org>.
Joseph Kesselman wrote:
> 
> 
> 
>>My DOM implementation is xerces and at the question
>>impl.hasFeature("XPath", "3.0")
>>the response is true.
> 
> 
> Contact the Xerces folks, then, and ask them why your code isn't working?

ok, I will
thanks

regards

-- 
XPath free testing software :  http://www.opikanoba.org/lantern/
Frédéric Laurent                        http://www.opikanoba.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Re: XPathEvaluator and DOM 3

Posted by Joseph Kesselman <ke...@us.ibm.com>.



>My DOM implementation is xerces and at the question
>impl.hasFeature("XPath", "3.0")
>the response is true.

Contact the Xerces folks, then, and ask them why your code isn't working?

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Re: XPathEvaluator and DOM 3

Posted by Frédéric Laurent <fl...@opikanoba.org>.
Joseph Kesselman wrote:

> 
>>According to the W3C recommendation, an XPahEvaluator object could be
>>obtained by a cast of a Document implementation.
> 
> 
> That works if and only if that particular DOM implementation supports the
> DOM Xpath feature. Most don't.

My DOM implementation is xerces and at the question
impl.hasFeature("XPath", "3.0")

the response is true.

So I guess, it's a good answer...

> If yours doesn't, consider using a stand-alone implementation of the
> XPathEvaluator which runs on top of a DOM -- I think Xalan provides one,
> though I haven't checked at all recently -- or using Xalan's own
> XPathAPI/CachedXPathAPI calls.

Well I really want to use independant API, especially the W3C ones.

thanks


regards

-- 
XPath free testing software :  http://www.opikanoba.org/lantern/
Frédéric Laurent                        http://www.opikanoba.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Re: XPathEvaluator and DOM 3

Posted by Joseph Kesselman <ke...@us.ibm.com>.



>According to the W3C recommendation, an XPahEvaluator object could be
>obtained by a cast of a Document implementation.

That works if and only if that particular DOM implementation supports the
DOM Xpath feature. Most don't.

If yours doesn't, consider using a stand-alone implementation of the
XPathEvaluator which runs on top of a DOM -- I think Xalan provides one,
though I haven't checked at all recently -- or using Xalan's own
XPathAPI/CachedXPathAPI calls.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org