Hi,
fmarchioni wrote:
>
>
> Werner Guttmann wrote:
>> HI,
>>
>> not by the means of XML. But how about working with a base class at the
>> OO Level, and indicate that to the Castor mapping file ?
>>
>> Regards
>> Werner
>>
>
> thanks for your reply Werner, well I have tried something like that but it
> seems not to work. Here's what I would lile to do: Supposing I have a
> superclass Pet extended by two class Dog and Cat.
>
> <class name="Pet">
> <field name="petname" type="java.lang.String">
> <bind-xml name="pet-name" node="attribute" />
> </field>
> ......
> </class>
>
> <class name="Dog">
> <map-to xml="pet-dog" />
> </class>
>
> <class name="Cat">
> <map-to xml="pet-cat" />
> </class>
>
> Now if I istantiate:
>
> Dog dog = new Dog();
> dog.setPetName("tom"); // This method is in class Pet and inherithed by Dog
> marshaller.marshal(dog);
>
> I get
> < pet-dog />
>
> But I would like to get:
> < pet-dog pet-name="tom" />
>
> In other words it seems that Castor doesn't inherit the attributes of
> superclasses when building xml.
Well, this is of no surprise, and you have not told Castor that your
classes (i.e. Dog and Cat) extend another class. Hae a look at the
'extends' attribute of the <class> mapping, documented at
http://castor.org/reference/html/XML%20data%20binding.html#xml.mapping.mappingfile.class
> I'm in a nice mess :-)
But only a few inches away from a solution.
> Regards
> Francesco
>
> fmarchioni wrote:
>> Hello !
>> I have a list of XML commands that I have coded with castor. Since the
>> fields of the commands are always the same I'd like to put them in a
>> template or file and include them in every command, is it possible to do
>> it
>> ?
>> Here's what it looks like:
>> <class name="it.pride.iptv.netcentrex.BaseCommandCreate">
>> <map-to xml="ccsmp-create" />
>>
>> <field name="sessionId" type="java.lang.String">
>> <bind-xml name="session" node="attribute" />
>> </field>
>>
>> <field name="enterprises"
>> type="it.pride.iptv.netcentrex.Enterprise"
>> collection="arraylist">
>> <bind-xml name="enterprise" />
>> </field>
>> .....
>> </class>
>> <class name="it.pride.iptv.netcentrex.BaseCommandDelete">
>> <map-to xml="ccsmp-delete" />
>>
>> <field name="sessionId" type="java.lang.String">
>> <bind-xml name="session" node="attribute" />
>> </field>
>>
>> <field name="enterprises"
>> type="it.pride.iptv.netcentrex.Enterprise"
>> collection="arraylist">
>> <bind-xml name="enterprise" />
>> </field>
>> .....
>> </class>
>> <class name="it.pride.iptv.netcentrex.BaseCommandUpdate">
>> <map-to xml="ccsmp-update" />
>>
>> <field name="sessionId" type="java.lang.String">
>> <bind-xml name="session" node="attribute" />
>> </field>
>>
>> <field name="enterprises"
>> type="it.pride.iptv.netcentrex.Enterprise"
>> collection="arraylist">
>> <bind-xml name="enterprise" />
>> </field>
>> .....
>> </class>
>>
>> Can I avoid to repeat n times the fields list, for every new command ?
>> thanks a lot
>> francesco
>
> ---------------------------------------------------------------------
> 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