Message: A new issue has been created in JIRA.
--------------------------------------------------------------------- View the issue: http://jira.codehaus.org/secure/ViewIssue.jspa?key=JIBX-14 Here is an overview of the issue: --------------------------------------------------------------------- Key: JIBX-14 Summary: Problems binding multiple XML structures into 1 object Type: Bug Status: Unassigned Priority: Minor Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: JiBX Components: core Versions: 1.0-beta3a Assignee: Reporter: Aaron Created: Tue, 27 Apr 2004 5:03 PM Updated: Tue, 27 Apr 2004 5:03 PM Description: 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. --------------------------------------------------------------------- JIRA INFORMATION: 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 ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ jibx-devs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-devs
