ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Holger Rauch <holger.ra...@heitec.de>
Subject Checking whether <xslt> task got the right no of params from beanshell script
Date Thu, 14 Sep 2006 13:13:44 GMT
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

Mime
View raw message