0

I have a simple binding:

<binding>
    <mapping name="entry" class="google.vo.GoogleContactsEntry" ordered="false">
        <value name="title" field="title" usage="optional" />
        <value name="email" field="email" usage="optional" />   
    </mapping>


    <mapping name="feed" class="google.vo.GoogleContacts" ordered="false" flexible="true">
        <namespace uri="http://www.w3.org/2005/Atom" default="elements"/>
        <value name="id" field="id" usage="optional" />
        <value name="updated" field="updatedString" usage="optional" />
        <value name="title" field="title" usage="optional" />
        <collection item-type="google.vo.GoogleContactsEntry" name="entries" field="entries"/>
    </mapping>
</binding>

The problem is in Collection element, which needs name="entries". Google returns entries without a wrapping element. Just like this:

<feed>

    <entry>

    </entry>

    <entry>

    </entry>

</feed>

And JiBX expects:

<feed>
    <entries>
        <entry>

        </entry>

        <entry>

        </entry>
    <entries>       
</feed>

Without element name in the binding scheme at collection, JiBX doesn't compile. Is there a solution?

Trick
  • 3,779
  • 12
  • 49
  • 76

2 Answers2

3

Better solution will be use of xsl transformation and change your incoming response into expected by jibx, it should be simple.

This topic will help: How can I wrap a group of adjacent elements using XSLT?

Community
  • 1
  • 1
kemot
  • 31
  • 2
1

Notorious work-A-round:

resp = StringUtils.replaceOnce(resp, "<entry>", "<entries><entry>");
resp = StringUtils.replaceOnce(resp, "</feed>", "</entries></feed>");
Trick
  • 3,779
  • 12
  • 49
  • 76