[ http://jira.codehaus.org/browse/JIBX-14?page=history ]

Dennis Sosnoski updated JIBX-14:
--------------------------------

    Fix Version:     (was: CVS)
                 1.0-RC0

> Problems binding multiple XML structures into 1 object
> ------------------------------------------------------
>
>          Key: JIBX-14
>          URL: http://jira.codehaus.org/browse/JIBX-14
>      Project: JiBX
>         Type: Bug
>   Components: core
>     Versions: 1.0-beta3a
>     Reporter: Aaron
>     Assignee: Dennis Sosnoski
>     Priority: Minor
>      Fix For: 1.0-RC0

>
>
> Given XML (from 3rd party; can't change):
> <current-pitcher first-name="Kazuhisa" last-name="Ishii"/>
> <current-pitcher id="6852" wins="2" losses="0"/>
> Desired class hierarchy of 2 classes, Pitcher and Player, with fields:
> Pitcher.Player.firstName
> Pitcher.Player.lastName
> Pitcher.Player.id
> Pitcher.wins
> Pitcher.losses
> Attempted Binding (excerpt):
> <structure field="pitcher">
>   <structure name="current-pitcher" usage="optional" value-style="attribute">
>     <structure field="player"> 
> <!-- firstName and lastName don't get set, maybe because player defined again 
> below -->
>       <value name="first-name" field="firstName"/>
>       <value name="last-name" field="lastName"/>
>     </structure>
>   </structure>
>   <structure name="current-pitcher" usage="optional" value-style="attribute">
>     <structure field="player"> 
>       <value name="id" field="id"/>
>     </structure>
>     <value name="wins" field="wins"/>
>     <value name="losses" field="losses"/>
>   </structure>
> </structure>
> This doesn't entirely work, though the binding complier doesn't complain 
> about it. The problem seems to be that it is not valid to have more than one 
> <structure field="player"> element that refers to the same field/object. In 
> this case, the second "player" structure is used to unmarshall data while the 
> fields in the first "player" structure are dropped/ignored.
> I also tried another variation of the binding (suggested by Dennis S) where 
> the first "player" field is merged into the first XML element structure:
> <structure field="pitcher">
>   <structure name="current-pitcher" usage="optional"
> value-style="attribute" field="player">
>     <value name="first-name" field="firstName"/>
>     <value name="last-name" field="lastName"/>
>   </structure>
>   <structure name="current-pitcher" usage="optional"
> value-style="attribute">
>     <structure field="player"> 
>       <value name="id" field="id"/>
>     </structure>
>     <value name="wins" field="wins"/>
>     <value name="losses" field="losses"/>
>   </structure>
> </structure>
> This had the same result: The data represented by the second "player" 
> structure was unmarshalled while data from the first was still ignored.
> My application only goes from XML to Java so I only tested unmarshalling with 
> these bindings.
> The work-arounds I've succesfully tested are: 
> 1) Add setter methods for child object (player) fields to the parent object 
> (pitcher).
> 2) Restructure class hierarchy: make Pitcher a subclass of Player.
> Still, it would be nice to at least be able to map data spread across 
> mutliple XML elements into the same child object.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
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-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to