1


I need to transform a Map into xml, and then using smooks convert it back into a Map. This map can contain complex values (ex: List), How to achieve that using smooks?
ex:

<m:map>
<entry key="a"> <l:list> <a>a1</a> <a>a2</a> </l:list></entry>
<entry key="b"> <l:list> <b>b1</b> <b>b2</b> </l:list></entry>
</m:map>

where <a> and <b> tags are referring to existing A and B models

class A { String property; }
class B { String property; }

Thanks,

Transient
  • 326
  • 2
  • 11

2 Answers2

0

You can do something like this:

<jb:bean beanId="itemList" class="java.util.ArrayList" createOnElement="Element">
     <jb:wiring beanIdRef="item" />
</jb:bean> 
Xavi López
  • 27,550
  • 11
  • 97
  • 161
dkero
  • 121
  • 1
  • 8
0

Maybe you can do it with smooks and groovy:

 <jb:bean beanId="inputValue" class="java.util.HashMap" createOnElement="StartElement">
        <jb:value property="prop"          data="StartElement/SomeValue/AnotherValue" />
    </jb:bean>


<g:groovy executeOnElement="StartElement">
         <g:imports>

        </g:imports>
        <g:script>
        <![CDATA[           
                //code for setting the objects                              

        ]]>
        </g:script>
    </g:groovy>  
Andreas Blomqvist
  • 437
  • 1
  • 9
  • 22