Hi, joni.loky wrote: > This is what i'm trying to Unmarshall. It's part of the output of a Microsoft > Project file saved as an XML file. > I have class which represents a WeekDay Element and I want a collection of > WeekDay elements. That should not be a problem at all.
> However I want to add to every one of those elements the > UID (Unique ID i think it means) of the Calendar element and the > BaseCalendarUID value. I am not 100% sure (and I might get corrected soon), but I don't think this can be achieved at all by the means of a mapping. Having said that, you could use a UnmarshalListener and implement the UnmarshalListener.unmarshalled (final Object target, final Object parent); method and inject the properties from the parent; problem with this approach is that you'd need the members at the Project level as well. If that's an option to you, I think this should be achievable. >I don't want to have a Calendar class with a > collection of WeekDays. I want the root element (<Project/>) to have the > collection of WeekDays. Adding to my first comment: if there's a corresponding Project class in Java, this can be done using a location attribute on the field mapping for the WeekDay collection. > > <Calendar> > <UID>1</UID> > <Name>Estándar</Name> > <IsBaseCalendar>1</IsBaseCalendar> > <BaseCalendarUID>-1</BaseCalendarUID> > - <WeekDays> > - <WeekDay> > <DayType>1</DayType> > <DayWorking>0</DayWorking> > </WeekDay> > - <WeekDay> > <DayType>2</DayType> > <DayWorking>1</DayWorking> > - <WorkingTimes> > - <WorkingTime> > <FromTime>09:00:00</FromTime> > <ToTime>13:00:00</ToTime> > </WorkingTime> > - <WorkingTime> > <FromTime>15:00:00</FromTime> > <ToTime>19:00:00</ToTime> > </WorkingTime> > </WorkingTimes> > </WeekDay> > - <WeekDay> > <DayType>3</DayType> > <DayWorking>1</DayWorking> > - <WorkingTimes> > - <WorkingTime> > <FromTime>09:00:00</FromTime> > <ToTime>13:00:00</ToTime> > </WorkingTime> > - <WorkingTime> > <FromTime>15:00:00</FromTime> > <ToTime>19:00:00</ToTime> > </WorkingTime> > </WorkingTimes> > </WeekDay> > - <WeekDay> > <DayType>4</DayType> > <DayWorking>1</DayWorking> > - <WorkingTimes> > - <WorkingTime> > <FromTime>09:00:00</FromTime> > <ToTime>13:00:00</ToTime> > </WorkingTime> > - <WorkingTime> > <FromTime>15:00:00</FromTime> > <ToTime>19:00:00</ToTime> > </WorkingTime> > </WorkingTimes> > </WeekDay> > - <WeekDay> > <DayType>5</DayType> > <DayWorking>1</DayWorking> > - <WorkingTimes> > - <WorkingTime> > <FromTime>09:00:00</FromTime> > <ToTime>13:00:00</ToTime> > </WorkingTime> > - <WorkingTime> > <FromTime>15:00:00</FromTime> > <ToTime>19:00:00</ToTime> > </WorkingTime> > </WorkingTimes> > </WeekDay> > - <WeekDay> > <DayType>6</DayType> > <DayWorking>1</DayWorking> > - <WorkingTimes> > - <WorkingTime> > <FromTime>09:00:00</FromTime> > <ToTime>13:00:00</ToTime> > </WorkingTime> > - <WorkingTime> > <FromTime>15:00:00</FromTime> > <ToTime>19:00:00</ToTime> > </WorkingTime> > </WorkingTimes> > </WeekDay> > - <WeekDay> > <DayType>7</DayType> > <DayWorking>0</DayWorking> > </WeekDay> > </WeekDays> > </Calendar> > > > > > Joachim Grüneis wrote: >> Hello, >> >> Sorry but I do not understand what your example should express. Can >> you please provide some information about the classes involved and put >> more information into the XML sample... >> >> You're writing that you want to have ID and Name in all Elements but >> your sample doesn't reflect it?? >> >> Regards >> >> Joachim >> >> On 17/04/2008, joni.loky <[EMAIL PROTECTED]> wrote: >>> How can i map a collection so that all of its elements will have the >>> same >>> attribute taken from the level which contains them. For example: >>> >>> <root> >>> <ID>id</ID> >>> <Name>name</Name> >>> <Elements> >>> <element1><attr1></attr1><attr2></attr2><attr3></attr3></element1> >>> <element2><attr1></attr1><attr2></attr2><attr3></attr3></element2> >>> <element3><attr1></attr1><attr2></attr2><attr3></attr3></element3> >>> </Elements> >>> </root> >>> >>> I want all of my elements to have the ID and Name of the root. >>> >>> Thnx. >>> Joni. >>> -- >>> View this message in context: >>> http://www.nabble.com/Castor-%2B-Unmarshalling-diff-levels-%2B-Collection-tp16749241p16749241.html >>> Sent from the Castor - User mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> >> >> > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

