IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

xquery with java under linux

  • 1.  xquery with java under linux

    Posted Fri February 28, 2003 03:52 PM

    I’m tryng to run a xquery from a java environment under linux
    usign jdk 1.4.
    In the previous post i found an example and i tried to use it:

    import java.util.;
    import com.softwareag.xtools.quip.xqueryAPI.
    ;

    public class XQL2 {

    public static void main(String args){
    Properties prop = new Properties();
    StringBuffer stringbuffer1 = new StringBuffer();
    try {
    stringbuffer1.append( “file://home//federico//xquery” );

    prop.put(“home”,“/home/federico/xquery” );
    prop.put(“quipcmd”,“/home/federico/xquery/QuiP/quip” );
    Connection conex
    = DriverManager.getConnection(stringbuffer1.toString(),(Properties)prop);
    QueryResult res = conex.executeQuery(args[0]);
    System.out.println(res.getRawString());
    }catch (XQueryException e) {
    System.out.println("XQueryException: " + e.getMessage());
    }
    }
    }

    and this is the result i get…
    <?xml version="1.0" encoding="UTF-8" ?>

    <quip:ExecutionError xmlns:quip=“http://namespaces.softwareag.com/tamino/quip/”>
    quip:queryFile/tmp/Query62820.tmp
    </quip:queryFile>
    quip:message<![CDATA[Error (1,1): accessing unspecified implicit input document
    ]]></quip:message>
    </quip:ExecutionError>

    there’s something that i don’t understand…
    can you help?


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: xquery with java under linux

    Posted Tue March 04, 2003 11:52 AM

    ok. I found a solution. the actual problem is that you don’t pass to quip a file like calling it from the shell, but you have to pass a string with the query. I hope this help, many of you.


    import java.io.;
    import java.util.
    ;
    import com.softwareag.xtools.quip.xqueryAPI.;
    import org.w3c.
    ;

    public class XQL2 {

    public static void main(String args) {
    Properties prop = new Properties();
    StringBuffer stringbuffer1 = new StringBuffer();
    String s_temp = new String();
    long start_time; //time at which the processing starts
    long end_time; //time at which the processing ends


    try {
    File f_xrule = new File(args[0]);
    if (!f_xrule.exists())
    throw new Exception(“File " + args[0] + " not found”);
    s_temp = “”;
    String read = “”;
    BufferedReader stdin = new BufferedReader(new FileReader(f_xrule));
    read = stdin.readLine();
    do {
    s_temp = s_temp+ read + “\n”;
    }
    while ( (read = stdin.readLine()) != null);
    stdin.close();
    System.out.println(s_temp);

    }
    catch (Exception e) {
    System.out.println("Exception: " + e.getMessage());
    }
    start_time=java.lang.System.currentTimeMillis();
    try {

    stringbuffer1.append(“file://.”);

    prop.put(“home”, “/home/federico/xquery/Quip”);
    prop.put(“quipcmd”, “/home/federico/xquery/QuiP/quip”);
    Connection conex
    = DriverManager.getConnection(stringbuffer1.toString(),
    (Properties) prop);
    QueryResult res = conex.executeQuery(s_temp);

    FileOutputStream outstream = new FileOutputStream(args[1]);
    outstream.write(res.getRawString().getBytes());
    outstream.close();
    end_time=java.lang.System.currentTimeMillis();
    long tot_time= end_time - start_time;
    System.out.println(tot_time);

    }
    catch (XQueryException e) {
    System.out.println("XQueryException: " + e.getMessage());
    }catch (Exception e) {
    System.out.println("Exception: " + e.getMessage());
    }


    }
    }


    #API-Management
    #webMethods
    #Tamino