morning....
 
Read about conversion functions and the "cast as" operator.  Tried the following which worked:
     declare namespace xsi=http://www.w3.org/2001/XMLSchema-instance;
     declare namespace pojo=http://www.klistret.com/cmdb/ci/pojo;
     /pojo:Element[pojo:fromTimeStamp gt "2010-07-08T16:38:00.478+02:00" cast as xs:dateTime]
 
The literal is directly transformed to a DateTimeValue class.  Cool.  But the warning ("Comparison of xs:untypedAtomic? to xs:dateTime will fail unless the first operand is empty") still occurs?  Assuming this just a log flag or am I still missing something in the expression?
 
 
/ Matthew

Från: Young Matthew (4004) [mailto:matthew.young@forsakringskassan.se]
Skickat: den 16 december 2010 22:46
Till: saxon-help@lists.sourceforge.net
Ämne: [saxon] denoting a literal as dateTime

hej,
 
Using latest Saxon HE with the following xpath:
     declare namespace xs="http://www.w3.org/2001/XMLSchema";
     declare namespace xsi=http://www.w3.org/2001/XMLSchema-instance;
     declare namespace pojo=http://www.klistret.com/cmdb/ci/pojo\;
     /pojo:Element[pojo:fromTimeStamp gt xs:dateTime(\"2010-07-08T16:38:00.478+02:00\")]
 
The fromTimeStamp element is a xs:dateTime and what I am doing is parsing the Saxon expression into my own "expression" representation that is simplified to map the individual steps (in an xpath) to a Hibernate query.  If I don't earmark the literal with the "xs:dateTime" function the literal is a StringValue type.  This bombs since in my Hibernate code I do a restriction off the Java object (which unfortunately is a String rather than a Date).
     value = Value.convertToJava(literal.asItem());
 
 
Using the "xs:dateTime" function casts a warning:
     Warning: Comparison of xs:untypedAtomic? to xs:dateTime will fail unless the first operand is empty
 
Plus the literal is wrapped inside a TraceExpression.  Anyway to write the xpath expression without wrapping the literal (ie. it is automatically transformed by Saxon into a DateTimeValue)?
 
 
thanks in advance / matthew