Invert the "structure" tag so that it contains the collection rather
than the collection containing it, like this:

<mapping name="table" class="Table">
   <structure name="rows">
        <collection field="row" item-type="Row"/>
   </structure>
</mapping>
<mapping name="row" class="Row">
   <value name="number" field="number"/>
   <value name="value" field="value" />
</mapping>

The "rows" element contains a collection of "row" items, not the other
way around.

The way I think of the "structure" tag (to keep it straight in my head),
is when I want to "skip over" a level of nesting (of either XML elements
or classes contained within one another), I need a structure tag.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mocky
Habeeb
Sent: Tuesday, March 01, 2005 3:48 PM
To: [email protected]
Subject: [jibx-users] Problem with a collection pushed one level deeper

First I'd like to say that I love this framework. I first learned of it
a few weeks ago when I watched the Javapolis video of the presentation
on XML binding. I immediately knew that this was just what I needed, and
I implemented it in the project I'm working on in a very short time.
It's very flexible and performance is great.

I read the archives looking for a solution to this problem but I haven't
seen one. 
Here is my problem, I have XML that looks like this:

<table>
        <row number="1" value="firstval"/>
        <row number="2" value="second"/>
        <row number="3" value="more"/>
</table>

And I created classes that look like this:

class Table {
        private ArrayList rows;
}

class Row {
        private String number;
        private String value;
}

Then I created a binding that looked something like this:

<mapping name="table" class="Table">
        <collection field="rows" item-type="Row"/>
</mapping>
<mapping name="row" class="Row">
        <value name="number" field="number"/>
        <value name="value" field="value" />
</mapping>

All was good until the XML was changed on me putting a new parent
element named 'rows' around the 'row's

<table>
        <rows>
                <row number="1" value="firstval"/>
                <row number="2" value="second"/>
                <row number="3" value="more"/>
        </rows>
        <metadata desc="a bunch other stuff that doesn't matter to this
problem"/>
</table>

Well I like my class structure and don't want to change it, so I changed
the binding in a number of different ways including this:

<mapping name="table" class="Table">
        <collection field="rows" item-type="Row"/>
</mapping>
<mapping name="rows" class="Row">
        <structure name="rows">
                <value name="number" field="number"/>
                <value name="value" field="value" />
        </structure>
</mapping>

And I could tell you what error messages I'm getting, but basically I
don't know how to express what I want in the binding.xml, so I know that
it's not going to work.

Suggestions?



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to