Tuesday, June 12, 2012

Custom XSLT Factory within application scope

Yesterday I tried an xsl transformation with the following xsl:

That xsl helps me to transform an xml to an xml which have scoped default namespaces. However that xsl is not working with Xalan. It is ok with Saxon. So I passed

-Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl to jvm.

It is okay with Tomcat but when you deploy to IBM Websphere application server; you recieve:

"[6/12/12 10:09:57:586 EEST] 0000000d UserRegistryC E SECJ0281E: Error creating user registry object. The exception is javax.xml.transform.TransformerFactoryConfigurationError: Provider net.sf.saxon.TransformerFactoryImpl not found" error.

The reason is that saxon.jar is only on application path; but we ask server to use it everywhere; so it looks for that factory as soon as server is running. One solution is to put that jar in the shared folder of ibm webshepre; so that it can locate it.

But then I think not to do it; let ibm webshere (and other deployed applications) to use it own xslt factory and my application use it's own xslt factory.

I was using Spring Integration. Spring Integration has a nice transformer (XsltPayloadTransformer) class; but it does not let you specify the xslt factory; it uses system variable.  So I extend it as:

I was lazy to extend XsltPayloadTransformerParser as well; so in my spring configuration file; I defined it as below:

1 comment: