Calling Smooks from Java to do xslt transfomation
standard Feb 4, 2008 11:41 AMHi,
I'm using JBoss ESB for my degree dissertation.
For a transformation a have to do, i wanted to use smooks,
so i can compare diffrent kinds of transfomation tactics.
I wanted to start with a pure xslt transformation applied at the document root, just to test how to call smooks etc.
I'm calling Smooks from Java code and not through
<action>configurations,
because i have multiple output messages for one input message, and as far as I understand the ESB,
you cant use the actions with this kind of setup.
As input I want to use dom.Documents, same as output.
So, my code so far is:
public Document convert(Document inDoc) { Document outDoc = null; Smooks smooks = null; try { smooks = new Smooks(); smooks.addConfigurations("pure-xsl", new URIResourceLocator().getResource("file://c:/pathtToConfig/smooks-config.xml")); DOMSource in = new DOMSource(inDoc); DOMResult out = new DOMResult(); smooks.filter(in, out, smooks.createExecutionContext()); outDoc = (Document)out.getNode(); } catch (IOException e) { log.error(e.getMessage()); } catch (SAXException e) { log.error(e.getMessage()); } catch (Exception e) { log.error(e.getMessage()); } return outDoc; }
and my smooks-config.xml:
<?xml version='1.0' encoding='UTF-8'?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd"> <resource-config selector="$document"> <resource type="xsl">file://C:/pathToXSLT/univis2cdm_v1.0.xslt</resource> <!-- Tryed it with this commented and uncommented --> <!--param name="is-xslt-templatelet">false</param--> </resource-config> </smooks-resource-list>
When i run this, there are not error messages or something like that,
but after the filtering, the output is exactly the same as the input, so nothing really happend.
My questions are now:
Did i do something wrong? I think everything is OK.
The XSLT works when I use it outside of Smooks, the pathes are right, no error messages...
I read in the Smooks Javadoc (Smooks v.1.0) that u can register a Eventhandler for the filter process,
and there is a BasicExecutionEventListener for this out of the box,
but it seems this isnt the case in the version used in JBoss ESB.
Is there some other way i can look into the whole process, to find out whats going wrong?
Thanks alot for your help, I'm really stuck here, and I'm running out of ideas what to try else.
And sorry for my bad english :-).
Andreas
P.S: I also tryed to apply the xslt with the admin console, but I have a problem there too.
Everytime i want to save in "Configure New Message Contract" i get a Exception
(java.util.MissingResourceException: Can't find bundle for base name messages, locale de_DE)