This content has been marked as final.
Show 1 reply
-
1. Re: Java-to-xml transformation
mlog Jul 4, 2011 10:06 AM (in response to mlog)I’m afraid that I didn’t clearly explain my problem. Ok then, I’ll try again.
I have an action that produces a domain specific java class. I need to transform it to an xml document. I am trying to do that with Smooks. My class looks like this:
package my.namespace.domain; class className { private String field; private anotherClassName innerClass; }
The default Smooks transformation (just like java-to-xml Smooks’ example) produces this result:
<my.namespace.domain.className> <field>field value</field> <innerClass> <!-- inner class fields --> </innerClass> </my.namespace.domain.className>
So the name of the root element is fully qualified java class name. Now, I can use Freemarker templates like ${innerClass.field} but cannot like ${my.namespace.domain.className.field}. That is I cannot use direct descendants of the root element in my template.
Yes, I could wrap my class to another one (and I did for a while) but it isn’t the right way, is it?