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

XPathEvaluator and DOM 3

Hello

According to the W3C recommendation, an XPahEvaluator object could be
obtained by a cast of a Document implementation, if the DOM 
implementation supports the DOM 3 XPath feature.

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

the response is true.

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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: XPathEvaluator and DOM 3

Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Frédéric.

Frédéric Laurent <fl...@opikanoba.org> wrote on 2004-05-04 04:41:37 PM:
> Elena Litani wrote:
> > Xerced does not support direct casting, but as described in the "Mixed
> > implementations" [2] section the implementation can be obtained using
> > Node.getFeature(..) method.
> > 
> > There are might be a bug in Xerces though, I believe it should only 
return
> > true for Node.isSupported(feature, version) with "+XPath" not "XPath"
> 
> Thanks for the precision. I guess there are bugs in xerces on this 
> topic, because :
> both isSupported("XPath", "3.0") and isSupported("+XPath", "3.0") give 
> the same answer : true.

That appears to be a bug in Xerces-J.  It should only return true for 
"+XPath".

> 
>    I have tested the cvs version. The getFeature method is declared in 
> the Node interface. good.
> But after
> evaluator = (XPathEvaluator) doc.getFeature("XPath", "3.0");
> 
> evaluator is null.

I spoke with Elena about this problem, and she agreed that that also 
appears to be a bug in Xerces-J (probably caused by a miscommunication 
between Xerces-J and Xalan-J developers).

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com


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


Re: XPathEvaluator and DOM 3

Posted by Frédéric Laurent <fl...@opikanoba.org>.
Elena Litani wrote:
>>According to the W3C recommendation, an XPahEvaluator
> 
> The XPath module is a working group Note, not a W3C recommendation [1].

you're right, sorry...

> In general Xerces will only support XPath module if Xalan implementation is
> in the classpath.

I've got both.

> Xerced does not support direct casting, but as described in the "Mixed
> implementations" [2] section the implementation can be obtained using
> Node.getFeature(..) method.
> 
> There are might be a bug in Xerces though, I believe it should only return
> true for Node.isSupported(feature, version) with "+XPath" not "XPath"

Thanks for the precision. I guess there are bugs in xerces on this 
topic, because :
both isSupported("XPath", "3.0") and isSupported("+XPath", "3.0") give 
the same answer : true.

Concerning isSupported("XPath", "3.0")
   it should be false, because the direct casting is not supported

Concerning isSupported("+XPath", "3.0")
   in the xerces 2.6.2 release, the org.w3c.dom.Node lacks the 
getFeature declaration. Then I can not write
evaluator = (XPathEvaluator) doc.getFeature("XPath", "3.0");
because there is a compilation error.

   I have tested the cvs version. The getFeature method is declared in 
the Node interface. good.
But after
evaluator = (XPathEvaluator) doc.getFeature("XPath", "3.0");

evaluator is null.

well, any comments ? Am I wrong ?

regards

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


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


Re: XPathEvaluator and DOM 3

Posted by Elena Litani <el...@ca.ibm.com>.



Hi,

> According to the W3C recommendation, an XPahEvaluator
The XPath module is a working group Note, not a W3C recommendation [1].

In general Xerces will only support XPath module if Xalan implementation is
in the classpath.
Xerced does not support direct casting, but as described in the "Mixed
implementations" [2] section the implementation can be obtained using
Node.getFeature(..) method.

There are might be a bug in Xerces though, I believe it should only return
true for Node.isSupported(feature, version) with "+XPath" not "XPath"
feature since direct casting is not supported [2]:
[[
if a plus sign "+" is prepended to any feature name, implementations are
considered in which the specified feature may not be directly castable but
would require discovery through DOMImplementation.getFeature(feature,
version) and Node.getFeature(feature, version).
]]



[1] http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/
[2]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMFeatures

Thank you,
--
Elena Litani / IBM Toronto

Frédéric Laurent <fl...@opikanoba.org> wrote on 05/03/2004 04:05:26 PM:

> Hello
>
> According to the W3C recommendation, an XPahEvaluator object could be
> obtained by a cast of a Document implementation, if the DOM
> implementation supports the DOM 3 XPath feature.
>
> My DOM implementation is xerces 2.6.2 and at the question
> impl.hasFeature("XPath", "3.0")
>
> the response is true.
>
> 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: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>


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