XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Little Help :))) (2)
-> + Xquery tag position (2)
-> - Can I connect to MonetDB/XQuer... (1)
-> + Is there a way to format a num... (2)
-> + Please help convert SQL query ... (3)
-> + Connect to SQL Server Express ... (3)
-> - Convert HTML to XML within C# ... (1)
-> + return different result based ... (7)
-> + Java Heap Space (2)
-> + XQuery Results export to multi... (3)
-> + NO RETURN (5)
-> + Part of a csv into a current X... (3)
-> + How to escape ampersand in xqu... (2)
-> + How to Convert CSV lines to in... (5)
-> + Data connection Stylus Studio ... (2)
-> + Nested XQuery FLOWRs with RDBM... (3)
-> + observing xquery at work (2)
-> + alternative for 'exists' (4)
-> + Xquery and webpages how? (2)
-> + Help with another DataDirect p... (5)
-- Previous [121-140] [141-160] [161-180] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
David IsaacSubject: Problems with Java date parameters using DDTEK XQuery engine
Author: David Isaac
Date: 29 Jun 2009 10:39 AM
Hello-

Has anyone successfully passed a date parameter from XQuery to Java using the ddtek XQuery engine?

With SAXON, I can successfully do the following:

declare namespace sdf = "java:java.text.SimpleDateFormat";
declare function local:toDate($stringDate as xs:string?) as xs:dateTime? {
let $format := sdf:new("MM/dd/yyyy")
return sdf:parse($format, $stringDate)
};

which nicely converts the returned Java Date to xs:dateTime.
With DDTEK, I tried unsuccessfully to do the following:

declare namespace sdf = "ddtekjava:java.text.SimpleDateFormat";
declare function sdf:SimpleDateFormat($format as xs:string) as ddtek:javaObject external;
declare function sdf:parse($this as ddtek:javaObject, $stringDate) as ddtek:javaObject external;
declare function local:convert($stringDate as xs:string as xs:date {
let $format := sdfSimpleDateFormat("MM/dd/yyyy")
return xs:dateTime(sdf:parse($format,$stringDate))
};

The ddtek:javaObject returned from parse is not automatically converted to xs:date and cannot be cast either. Any hints what I am doing wrong? I cannot find any default mapping of date types between Java and XQuery in the ddtek documentation, so perhaps it can't be done? Am I approaching this all wrong...is there really no better way to convert dates? Sometimes I am simply trying to process dates in mm/dd/yyyy hh:mm:ss format, and of course XQuery requires ISO yyyy-mm-dd etc. format...is there really no implicit conversion for this common format? Any help would be greatly appreciated!

Postnext
(Deleted User) Subject: Problems with Java date parameters using DDTEK XQuery engine
Author: (Deleted User)
Date: 30 Jun 2009 12:05 PM
Hi David,
the table listing the mapping used by DDXQ to convert between Java and XQuery datatypes is Table 13-1 in chapter 13 of the User Guide (that can be found at <Stylus Studio Install>\Components\DataDirect XQuery\books\ddxquery\ddxqug\ddxqug.pdf).
Unfortunately the java.util.Date type is not automatically converted into xs:date, so you must do one extra step to convert it into a string suitable for constructing an xs:date item.

declare namespace sdf = "ddtekjava:java.text.SimpleDateFormat";
declare function sdf:SimpleDateFormat($format as xs:string) as ddtek:javaObject external;
declare function sdf:parse($this as ddtek:javaObject, $stringDate) as ddtek:javaObject external;
declare function sdf:format($this as ddtek:javaObject, $objDate) as xs:string external;

declare function local:convert($stringDate as xs:string) as xs:date {
let $format := sdf:SimpleDateFormat("MM/dd/yyyy")
let $formatISO := sdf:SimpleDateFormat("yyyy-MM-dd")
return xs:date(sdf:format($formatISO, sdf:parse($format,$stringDate)))
};


Hope this helps,
Alberto

Posttop
David IsaacSubject: Problems with Java date parameters using DDTEK XQuery engine
Author: David Isaac
Date: 07 Jul 2009 05:04 PM
I get it. Thanks!

PS: Implicit Java date type conversion might be a nice feature to add... :)

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.