Anderson, Rob (Global Trade) wrote:
Ant Gurus, I am having a little trouble using the XSLTProcess task from within
the logger/listener that I am writing. Here is the code that is causing me
greif:
XSLTProcess xslt = (XSLTProcess) project.createTask("xslt");
xslt.setBasedir(new File("."));
xslt.setIn(new File("log.xml"));
xslt.setOut(new File("log.html"));
xslt.execute();
I don't thing I am calling the project.createTask() correclty, the xslt object is null when I step through this with the degugger. Any help is appreciated.
Rob,
I would recommend that you actually go
XSLTProcess xslt=new XSLTProcess();
then bind it to the owner. Ant1.7 has a method in Task to do that, which
you will need to adapt into your own code if you want to work on ant1.6:
/**
* Bind a task to another; use this when configuring a newly created
* task to do work on behalf of another.
* Project, OwningTarget, TaskName, Location and Description are
all copied
* @param owner owning target
*/
public final void bindToOwner(Task owner) {
setProject(owner.getProject());
setOwningTarget(owner.getOwningTarget());
setTaskName(owner.getTaskName());
setDescription(owner.getDescription());
setLocation(owner.getLocation());
setTaskType(owner.getTaskType());
}
The reason for doing it this way is that
1. you are isolated from any surprises if people use <presetdef> to
change the class that task "xslt" maps to
2. you can be sure that the task is created right.
3. stuff like the error line and name propagates down correctly.
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]