[xquery-talk] ddxq external java function question
Carlo Innocenti
minollo at minollo.com
Tue Jun 26 13:11:39 PDT 2007
Product specific questions are better asked on our developer forum
(http://forums.datadirect.com/ddforums/forum.jspa?forumID=9).
The problem in your case is with the declaration of the XQuery
function, which should use "xs:int", instead of "xs:integer" for its arguments.
See more details about mapping of Java types to XML types in the
context of DataDirect XQuery Java extension functions at:
http://media.datadirect.com/download/docs/ddxquery/allddxq/reference/functions2.html#wp214238
Hope this helps,
Minollo
At 11:54 AM 6/26/2007, Charlie wrote:
>Hi,
>
>I am trying to use datadirect external java functions.
>
>The bottom are the files from other websites. I
>compiled the java to the class file under the same
>folder as .xq and .xml. When I have the classpath
>setup but got the error msg from the following
>command:
>
>java com.ddtek.xquery.Query -s IntDate.xml IntDate.xq
>
>XQQueryException: [DataDirect][XQuery]Error at line 9,
>column 57. Static error during resolving of external
>Java function. No matching Java external function
>found for 'IntDate:getDate(xs:integer, xs:integer,
>xs:integer, xs:string)'. [Call stack: ext:getDate at 9.8]
> Line: 9
> Column: 57
> VendorCode: EJF0002
>
>
>==============
>IntDate.xml:
>
><?xml version="1.0"?>
><doc>
> <date year="1997" month="5" day="7"
>format="EEEE, MMMM dd (D), yyyy z"/>
> <date year="1998" month="1" day="10"
>format="MMM d, yy"/>
> <date year="1999" month="2" day="5"
>format="EE, MMM dd, yyyy"/>
></doc>
>
>==============
>IntDate.xq:
>
>declare namespace ext = "ddtekjava:IntDate";
>declare function ext:getDate($year as xs:integer,
> $month as xs:integer,
> $day as xs:integer,
> $format as xs:string)
> as xs:string external;
>
>for $date in /doc/date
>return
>ext:getDate($date/@year,$date/@month,$date/@day,$date/@format)
>
>==============
>IntDate.java
>
>import java.util.Date;
>import java.util.Calendar;
>import java.text.SimpleDateFormat;
>
>public class IntDate
>{
> public static void main (String[] args) {
> System.out.println(getDate(1939, 12, 5, "EEEE,
>MMMM dd (D), yyyy z") );
> }
>
> public static String getDate(int year, int month,
>int day, String format)
> {
> Calendar c = Calendar.getInstance();
> c.set((int)year,(int)month,(int)day);
> SimpleDateFormat dateFormat = new
>SimpleDateFormat(format);
> return dateFormat.format(c.getTime());
> }
>}
>
>
>
>
>
>____________________________________________________________________________________
>It's here! Your new message!
>Get new email alerts with the free Yahoo! Toolbar.
>http://tools.search.yahoo.com/toolbar/features/mail/
>_______________________________________________
>talk at x-query.com
>http://x-query.com/mailman/listinfo/talk
More information about the talk
mailing list