|
Hello,
I have come across a problem with xslt
transformation using xerces 2. The scenerio is as
follows.
JSP containing custom tag, invokes XSLT against a
specified XML file. A list of parameters are set. This
falls over when running from the JSP on Tomcat 4.1.12, but when I both manually
transform from the command line and using the same code but in a standalone Java
application the transformation is successful. Ive tried various ideas but
nothing has solved the problem.
Thanks
Julie.
The Java code is as follows:
public static String transformWithParams(String
xml, String
urlXslt,
ArrayList params) throws Exception Writer
transformedXml = null;
try { transformedXml = new StringWriter(); Transformer transformer = tFactory.newTransformer( new StreamSource(urlXslt)); if (params != null) { int size = params.size(); for (int i = 0; i < size; i++) { XsltParameter param = (XsltParameter)params.get(i); transformer.setParameter(param.getName(), param.getValue()); } } transformer.setParameter("operationName", "AddDevice"); transformer.transform(new StreamSource(xml), new StreamResult(transformedXml)); return transformedXml.toString(); } catch (TransformerException te) { throw new Exception("Transformer exception using XSLT file " + urlXslt, te); } finally {
try {
if (transformedXml
!= null)
{
transformedXml.close();
}
catch(Exception e){}
} }
|
