First prototype used following declarations:
- function (namespace) declaration:
xmlns:custom="java:foo.bar.CustomFunction" - class instance injection:
xsl:param name="instance" - sample instance method call:
custom:setTitle($instance, text())
It run smoothly in Tomcat without any problems, even given that I had to use instance method calls on object passed by param.
Then I moved to IBM WebSphere and things got complicated. At first I was blessed by the TransformerConfgiurationException. I took me plenty of googling to figure out what was happening. Eventually it occurred that WebSphere's Xalan was unable to identify the exact type (!) of injected custom class instance. It's well-known limitation, identified in this Apache JIRA issue.
My final XSLT declarations are as follows:
- function (namespace) declaration:
xmlns:my-namespace="xalan://foo.bar.CustomFunction" - class instance injection:
xsl:param name="instance" - sample instance method call:
my-namespace:setTitle(xsltc:cast('foo.bar.CustomFunction', $instance), '', text())
The best thing is that such configuration works in both containers (Tomcat and WebSphere) without any problems :)
Brak komentarzy:
Prześlij komentarz