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)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] 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.