You could make the data you'd have passed as a parameter available to your xslt code via an extension function. Or, you could wrap your xml in some additional xml containing the data. You could have additional filters in your chain that do the wrapping, as well as unwrapping it again later.

Eric

Will Holcomb wrote:
I have an application where I would like to have a dynamic list of XMLFilters (because they're easy to write) some of which are XSLT stylesheets where the stylesheets have parameters. I have read that it it not possible to specify parameters on XSLT stylesheets that are entered as:

StreamSource xsltSource = new StreamSource(xsltFilename)
XMLFilter filter = SAXTransformerFactory.newXMLFilter(xsltSource);

I attempted to get around this by doing:

Templates templates = transFactory.newTemplates(xsltSource);
Transformer transform = templates.newTransformer();
for(Map.Entry<String,String> param : templateParams.entrySet()) {
     transform.setParameter(param.getKey(), param.getValue());
}
XMLFilter filter = transFactory.newXMLFilter(templates);

The documentation says newTransform() returns "a transformation context," but apparently that context doesn't actually modify the original Templates object since the parameter values don't seem to be set in the output.

If I knew that all of the custom XMLFilters would come before the Transforms then I think I could build two separate chains. One of XMLFilters that I use with a SAXSource and another of TransformHandlers that I terminate with a Result. I don't want to make that ordering assumption though.

I've tried to find a way to operate entirely using TransformHandlers, but I can't figure out how to convert an XMLFilter into one.

Are there any suggestions for a method of accomplishing the goal of having a chain of XMLFilters which include XSLT stylesheets with parameters specified?

Will

Reply via email to