[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] jd.xsltc translet performs System.exit ?


Subject: Re: [xsl] jd.xsltc translet performs System.exit ?
From: Johannes Döbler <jd@xxxxxxxxxxxxxx>
Date: Fri, 15 Aug 2003 22:33:22 +0200


Hi,

I want to run a translet generated by jd.xsltc via a java-program
several times in a loop. It seems that only the first pass is done
and after this the program stops. Does the translet do this? How
can I prevent it from doing so?

In the following code "hello1" is printed only one time, "hello2"
doesn't get printed at all. Diml2cmsTranslet is the translet created
by jd.xsltc (Version 1.0, released 13 May 2003).

for(int s=0; s<parts.getLength(); s++) {

[ ... ]

       Diml2cmsTranslet cmstranslet = new Diml2cmsTranslet();
       String transletarguments[];
       transletarguments = new String[6];
       transletarguments[0]= "-out";
       transletarguments[1]= cmsContainerFile;
       transletarguments[2]= "-param";
       transletarguments[3]= "SELECTID";
       transletarguments[4]= "'" + id + "'";
       transletarguments[5]= dimlFileName;

       System.out.println("hello1");
       cmstranslet.main(transletarguments);
       System.out.println("hello2");

} // end for

Hope thats not a too stupid question,

Burghard ;)


This question might be too product specific for xsl-list but here is the answer:
The main method of a Translets ends with a call to System.exit() to set an appropriate exit code.
Use the following code schema to access the commandline interface without System.exit() being called:


import jd.xml.xslt.translet.TransletCmdLine;
...
MyTranslet mytranslet = new MyTranslet();
String transletArgs[] = ...

try
{
    TransletCmdLine cmdline = new TransletCmdLine(myTranslet);
    cmdline.evaluate(transletArgs);
}
catch(Exception e)
{
    ...
}

best regards,
Johannes Döbler


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords