473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

max() function problem in XQuery using Saxon

Hi,

I'm using Weblogic 9.2 which uses Saxon 8.1.1 as its XQuery Engine. I'm using max function and in the argument I'm passing the node which has two dateTime values. It is giving exception.

Following is part of my XML Document:

<effectiveTime value="2007-03-20T18:10:15"/>

Following is part of my XQuery:

$maxTime := (max($bodySect[code/@code='11502-2']/entry/observation/effectiveTime/@value))

It is giving following exception:

net.sf.saxon.DynamicPathError: Cannot convert {2007-02-13T18:10:15} to a number.

Basically, it is trying to convert it into double.
However, the documentation says that comparison can be done with same base type and return max from that. Here we have same base type i.e., xs:dateTime. So, I think there is some conflict between w3c specification and Saxon implementation or may be I’m misinterpreting it.

Hope somebody can help me.

Thanks,
Ismail
Mar 29 '07 #1
8 4014
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN...

Try to declare $maxTime as a string variable, and see if it works.
Then convert or parse the string using Java, as desired.
If not, please let us know.
Thanks,
Dorin.
Mar 29 '07 #2
Thanks for quick response.

I've tried. But its giving another error:

Required type of value of variable $maxTime [unallocated] is xs:string; supplied value has type xs:double

Reason is that max function requires double as argument, and when it get String, it tries to convert it into double, but due to presence of special characters in the string, it can't.. I think there should be some method which should accept datetime as argument and return their max. Would it be possible? Your expert opinion in this regard will really help me.

Ismail
Mar 29 '07 #3
dorinbogdan
839 Expert 512MB
Use string(max(...)) function to convert the max number to string.
Mar 29 '07 #4
No effect. Same exception. I think I'm unable to understand you the problem. Now I'm re-trying. Basically, it gives exception on the argument of max which is date & time in string format (i.e., 2007-03-30T13:55:15), but max function accepts in double format. And if it is not double (which is in my case), then it tries to convert it into double, which is also not possible (in my case) b/c special characters can't be converted into double.

So, making it string after exception is raised obviously don't have any effect. Exception is raised before converting into string by string(max(...), so it throws

net.sf.saxon.xpath.DynamicError: Failure converting {2007-03-29} to a number
java.lang.RuntimeException: net.sf.saxon.xpath.DynamicError: Failure converting {2007-03-29} to a number
at org.apache.xmlbeans.impl.xquery.saxon.XBeansXQuery .execQuery(XBeansXQuery.java:82)
at org.apache.xmlbeans.impl.store.Query$SaxonQueryImp l$SaxonQueryEngine.
cursorExecute(Query.java:269)
at org.apache.xmlbeans.impl.store.Query$SaxonQueryImp l.cursorExecute(Query.java:170)
at org.apache.xmlbeans.impl.store.Query.cursorExecQue ry(Query.java:48)
at org.apache.xmlbeans.impl.store.Cursor._execQuery(C ursor.java:1328)
at org.apache.xmlbeans.impl.store.Cursor._execQuery(C ursor.java:1323)
at org.apache.xmlbeans.impl.store.Cursor.execQuery(Cu rsor.java:3814)
at Controller.execute(Controller.java:282)


Hope you will now understand what I mean. Anyway, I appreciate your prompt respose.

Thanks,
Ismail
Mar 30 '07 #5
dorinbogdan
839 Expert 512MB
Try to use a method like in this link.
( that uses for loop and xs:dateTime:
Expand|Select|Wrap|Line Numbers
  1. max(for $d in //@modified return xs:dateTime($d)) 
)

If not helpful, please post the XML and XSL you are using.

Thanks,
Dorin.
Mar 30 '07 #6
Thanks a lot. It works for me now. for loop within max has worked fine for me.
Thanks once again

Ismail
Mar 30 '07 #7
dorinbogdan
839 Expert 512MB
Glad to hear that.
You're always welcome.

God bless you,
Dorin.
Mar 30 '07 #8
I have the same problem. I read the post and there is a reference to a link (3 posts ago) that is dead. Could you please share the solution. I'm pretty stuck :-(. I use Saxon 9.

Kind regards,
Maarten Storm
Jan 7 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now...
0
by: Benjamin G. Jones | last post by:
I am having a very basic problem with XQuery. I want to use an XQuery API in Java (either Saxon or Qexo), and I have an XQuery expression that works as expeced from the command line if I specify...
7
by: Jeff Kish | last post by:
Greetings. I can't invest a large amount of time into this, but it would be very helpful if I could do this. I have a directory full of xml files I'd like to be able to query to find out...
1
by: FBS | last post by:
Hi everybody, I wonder if somebody could help me with this issue. I would like to rum some XQuery codes aginst my XML files and since I'm quite new in this area I'm not sure what to do. It is...
0
by: pepin_labulle | last post by:
I'm a newbie with XQuery and I'm trying to execute a query with Saxon. If I don't specify the XML source file name in the query, Saxon raises the following error :...
8
by: Clamps | last post by:
So I've been reading about XQuery, but cannot find a dll or namespace download to use the technology in vs.net 2002 or 2003. Any directions would be great. -- "If I'm the president, we're going...
1
by: Philipp Schumann | last post by:
Hi .NET XML fans, does anyone know ad hoc whether support for the above standards is planned for .NET 2.0? I suppose this would be extremely valuable for many folks... Thanks, Phil
4
by: ismailj | last post by:
Hi, I'm using Saxon v8.9 for XQuery execution. I'm using following code: XQDataSource ds = new SaxonXQDataSource(); XQConnection conn = ds.getConnection(); ...
3
by: Bloody Viking | last post by:
Namaste, Y'all! I've got a valid XQuery expression that I need to convert to XPath 2.0. This expression will be stored in a resource file and applied to XML by a Java program with saxon8.jar...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.