You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Holger Rauch <ho...@heitec.de> on 2006/09/14 15:13:44 UTC
Checking whether task got the right no of params from beanshell script
Hi,
I'm using a beanshell script to invoke XSLTProcess (which corresponds to
the <xslt> element). I've verified that the no of stylesheet params inside
the script is correct. How can I verify that the xsltproc instance is
parameterized correctly from within the beanshell script?
Any help will be greatly appreciated!
I'm doing something like this:
-----------------------------------------------------------------
// imports omitted
// in, out, style, force, processor passed as parameters
String in = (String) attributes.get("in");
String out = (String) attributes.get("out");
File infile = new File( in );
File outfile = new File( out );
String style = (String) attributes.get("style");
Boolean tmpbool = new Boolean( (String) attributes.get("force") );
boolean force = tmpbool.booleanValue();
String processor = (String) attributes.get("processor");
Reference cpref = new Reference();
if ( cpref != null ) {
if ( processor.equals("saxon8") ) {
cpref.setRefId("saxon8.classpath");
}
// additional classpaths omitted for brevity
} else {
exittask = new Exit();
exittask.execute();
}
XSLTProcess xsltproc = new XSLTProcess();
XSLTProcess.Param currstshparam;
// infile, outfile, style, force
if ( xsltproc != null ) {
xsltproc.setClasspathRef( cpref );
xsltproc.setIn( infile );
xsltproc.setOut( outfile );
// xsltproc.setProcessor( "trax" );
xsltproc.setStyle( style );
xsltproc.setForce( force );
} else {
exittask = new Exit();
exittask.execute();
}
// Inside a loop
try {
currstshparam = xsltproc.createParam();
currstshparam.setName( name );
currstshparam.setExpression( expr );
} catch( NullPointerException npe ) {
npe.printStackTrace();
exittask = new Exit();
exittask.execute();
}
// The script works when this is commented out but unfortunately doesn't do
// anything useful...
xsltproc.execute();
-----------------------------------------------------------------
Kind regards,
Holger