Hi, i've solved the problem by myself. The error was to use "flexibile=true" instead of "usage=optional". Infact, the Goal list can be empty, but when present should be parsed... so it is optional... not "to be ignored" with flexible=true. Adding usage=optional to the collection the data are parsed in the right way!
Thanks Davide On Tue, Jun 30, 2009 at 4:12 PM, mr.abanjo <mr.aba...@gmail.com> wrote: > Hi, > i'm trying to map an xml like this one: > ... > <MatchData uID="........."> > <TeamData Score="........"> > <Goal Period="SecondHalf" PlayerRef="p9808" Type="Goal" /> > <Goal Period="SecondHalf" PlayerRef="p14791" Type="Goal" /> > </TeamData> > <TeamData Score="0" Side="Away" TeamRef="t129" /> > </MatchData> > ... > > So a TeamData can be empty! > > my mappgin jibx xml file is like this one: > > ... > <collection field="matches" > factory="it.foo.SoccerDocument.matchesListFactory"> > <structure name="MatchData" type="it.foo.MatchData" > ordered="false" > > <value name="uID" style="attribute" field="uId" > usage="optional"/> > <collection field="teamDatas" > factory="it.foo.MatchData.teamDatasListFactory"> > <structure name="TeamData" type="it.foo.TeamData" > ordered="false"> > <value name="Score" style="attribute" > field="score" usage="optional"/> > <collection field="goals" > factory="it.foo.TeamData.goalsListFactory"> > <structure name="Goal" type="it.foo.Goal" > ordered="false" > > <value name="Period" style="attribute" > field="period" usage="optional"/> > <value name="PlayerRef" > style="attribute" field="playerRef" usage="optional"/> > <value name="Type" style="attribute" > field="type" usage="optional"/> > </structure> > </collection> > </structure> > </collection> > </structure> > </collection> > ... > > This is compiled correctly by jibx.. but give me an error at runtime: > Missing required element "(unknown name, position 0 in binding > structure)"(line 20, col 56) > > This is because (i've tested id) the second "TeamData" is empty. > So i tryed to add "flexibile=true" to the "TeamData" structure, but jibx > tell me that all the childs need a name. > But if i give to the "goals" collection a name it can't be the same of the > child structure "Goal".. but it also can't be different because i don't have > a "wrapper" element on a Goal list. > > Anyone have some ideas? > There is a way to have a "flexible" collection? > > Thanks > Davide > > > > >
------------------------------------------------------------------------------
_______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users