Hi Jeff,
have you already tried something like:
<class name="mypackage.sensors.IPMISensors" auto-complete="false"
verify-constructable="false">
<field name="redund" type="boolean">
<bind-xml name="redund" location="psSensors" node="attribute" />
</field>
<field name="powerSupplySensors"
type="mypackage.sensors.IPMIPowerSupplySensor"
required="false" direct="false" transient="false"
container="false" collection="collection">
<bind-xml name="psSensors" node="element" />
</field>
</class>
Regards
Ralf
Jeff Crump schrieb:
> Hi Werner,
>
> I would prefer to not use the intermediate class approach. Can you
> point me to documentation on the property approach? Thanks.
>
> Jeff
>
> 2008/12/5 Werner Guttmann <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>>
>
> Hi Jeff,
>
> Jeff Crump wrote:
> > I'm having trouble unmarshalling a list of elements into a
> collection that
> > itself has an attribute:
> >
> > <ipmiSensors>
> > <psSensors redund="True">
> > <powerSupply status="ok" present="True" name="Power
> Supply1"/>
> > <powerSupply status="ok" present="True" name="Power
> Supply2"/>
> > </psSensors>
> > </ipmiSensors>
> >
> > If I ignore the 'redund' attribute, I can unmarshall this into a
> > Collection<T> instance easily:
> >
> > <class name="mypackage.sensors.IPMISensors" auto-complete="false"
> > verify-constructable="false">
> > <field name="powerSupplySensors"
> > type="mypackage.sensors.IPMIPowerSupplySensor"
> > required="false" direct="false" transient="false"
> > container="false" collection="collection">
> > <bind-xml name="psSensors" node="element" />
> > </field>
> > </class>
> >
> > This does exactly what I would expect, and add the <powerSupply>
> instances
> > to the Collection.
> >
> > But that attribute on the <psSensors> element is puzzling me.
> Obviously I
> > can't unmarshall this into a Collection<T> anymore - I have to
> create my own
> > subclass of, say, ArrayList<T>, right? Except nothing I try
> seems to work.
> >
> > Am I on the right track?
> No, not really. Let me ask you a question and suggest one possible
> solution.
>
> Question: where (in your object model) would you like to store the
> value
> of the 'redund' attribute.
>
> Possible solution:
>
> a) Store the attribute value in a property on the class
> mypackage.sensors.IPMISensors, and use a location in the XML
> binding for
> this attribute.
> b) Create an intermediate class for <psSensors> that has two members,
> one for the collection of PowerSupply#s and one for the attribute
> value.
>
> > I really don't want to create a collection within
> > a collection -- I don't want to make this one class different
> than all of
> > the others in the set I'm working with.
> >
> > Any advice?
> >
> > Jeff
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
72127 Kusterdingen
Germany
Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98
Internet: www.syscon.eu
E-Mail: [EMAIL PROTECTED]
Sitz der Gesellschaft: D-72127 Kusterdingen
Registereintrag: Amtsgericht Stuttgart, HRB 382295
Geschäftsleitung: Jens Joachim, Ralf Joachim