> I dont have any problems with how values are being returned from Jaxen when
> an XPath evaluation (using evaluate() or selectNodes()) is done, but WHILE
> evaluating the expression using a custom VariableContext. Jaxen call my
> VariableContext back for each variable defined in the XPath expression and
> my question is of what type should that value be. Currently my
> VariableContext is returning Strings for everything but if they are further
> used in boolean expression such as $result > 10 I get a ClassCastException.
> 
> Looking at the source, it seems that you guys are using Comparator for all
> expression evaluations. Either Jaxen should be smart related to simple type
> conversions (and then use the comparator) or the contract of VariableContext
> should be further specified, such as
> VariableContext.getBooleanVariableValue,
> VariableContext.getStringVariableValue, etc.

For things that Jaxen internally churns up, it is fairly smart about
conversions.  If you have an expr 'count(/foo/bar) * /foo/bar[1]/@value'
it'll do promotion/conversion.  I should think at least Integer->Double
conversion should occur for things passed in a variables.  

Mark recently redid our handling of numeric types (defaulting everything
to java.lang.Double, I think).  Mark, any idea what's going on here?

        -bob


> 
> -----------
>  FROM: James StrachanDATE: 11/21/2001 01:05:57SUBJECT: RE:  [Jaxen] Jaxen
> and VariableContext Problem: Java Object types If you work off the latest
> CVS image, then using the evaluate() method
> should return a Boolean object.
> 
> If you call the selectNodes() method right now it will probably return a
> List containing a single Boolean object.
> 
> James
> ----- Original Message -----
> From: "Yuri de Wit" <<EMAIL: PROTECTED>>
> To: <<EMAIL: PROTECTED>>
> Sent: Wednesday, November 21, 2001 1:47 AM
> Subject: [Jaxen] Jaxen and VariableContext Problem: Java Object types
> 
> 
> >
> > I am using Jaxen and a VariableContext but I am having problems with the
> > following XPath expression:
> > $result > 10
> >
> > What is the actual Java Object class that VariableContext implementation
> > should be returning? Is Jaxen smart enough so that a String returned would
> > be properly converted to Integer or Double, for instance? If no, what is
> the
> > contract that a VariableContext should be implementing in terms of Objects
> > returned?
> >
> > This is the exception I am getting:
> > ava.lang.ClassCastException: java.lang.Integer at
> > java.lang.Double.compareTo(Double.java:576) at
> >
> org.jaxen.expr.DefaultGreaterThanExpr.evaluateObjectObject(DefaultGreaterTha
> > nExpr.java:128) at
> >
> org.jaxen.expr.DefaultRelationalExpr.evaluate(DefaultRelationalExpr.java:85)
> > at
> >
> org.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFunctionCallExpr.java
> > :135) at org.jaxen.expr.DefaultXPath.asList(DefaultXPath.java:46) at
> > org.jaxen.JaXPath.jaSelectNodes(JaXPath.java:33) at
> > org.jaxen.BaseXPath.selectNodes(BaseXPath.java:21)
> >
> >
> > _______________________________________________
> > Jaxen-interest mailing list
> > <EMAIL: PROTECTED>
> > https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> _______________________________________________
> Jaxen-interest mailing list
> <EMAIL: PROTECTED>
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> 
> 
> 
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> 


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to