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)
-> + How to resolve XPTY0004 error (3)
-> + Search a sequence of siblings ... (3)
-> + DataDirect process getting XPS... (2)
-> + Find the parent who doesn't ha... (3)
-> + Help with a basic FLWOR query (3)
-> + xQuery Efficient Performance B... (5)
-> + How to break down a sequence a... (3)
-> + Xquery returning odd number fo... (2)
-> - Problems with Java date parame... (3)
-> ->Problems with Java date p...
-> ->Problems with Java date p...
-> + Xquery filter on multiple valu... (2)
-> + Xquery filter by using contain... (5)
-> + multiple xslt execution using ... (2)
-> + How to access to global variab... (6)
-> + "Value can not be converted to... (4)
-> + (simple) problem with xquery (3)
-> + Version of xQuery Included wit... (3)
-> + xQuery 1.0 Produces XPTY0004 E... (3)
-> + Replace Node with Set of Nodes (2)
-> + Unable to Use File Name as Ext... (5)
-> + EDI to XSD and validation (2)
-- 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.