[xquery-talk] ddxq external java function question

Charlie c_z90 at yahoo.com
Tue Jun 26 09:54:43 PDT 2007


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/


More information about the talk mailing list