Lukas,
imho, the container attribute makes sense in the context of multi-valued
fields only. Imagine a Java member 'items' (within an Order class) which
holds a java.util.List of Item instances
A vanilla mapping for this could look like ...
<field name="items" type="Item" collection="arraylist">
<bind-xml name="items" />
</field>
Such a mapping would produce XML as follows:
<oder>
<items>
<item>
...
</item>
<item>
...
</item>
</items>
</order>
Now imagine there's folks who consider the <items> element to be
redundant, in other words want to avoid it. In that case you can use the
container attribute to signal to Castor that the <item> elements should
be placed within the <order> itself.
I hope this makes (more) sense ....
Werner
Lukas Lang wrote:
> Hey Dan,
>
> as far as I know there is an attribute called "container".
>
> Have a look at the mapping.dtd:
>
> <!ELEMENT field ( description?, sql?, bind-xml?, ldap? )>
> <!ATTLIST field
> name CDATA #REQUIRED
> type CDATA #IMPLIED
> ...
> transient (true|false) "false"
> identity (true|false) "false"
> container ( true | false ) #IMPLIED
> ...
>
> I'm wondering, I couldn't find it on the website documentation.
> Elements being a container are not marshalled as far as I know.
>
> Greetings,
> Lukas
>
> [EMAIL PROTECTED] schrieb:
>> Hi All,
>>
>> I have a class called Service with two attributes, mode and id.
>>
>> Currently I am using Castor to unmarshal this xml:
>>
>> <service mode="R" id="D2MAX"/>
>>
>> The fields are mapped like this:
>>
>> <class name="com.Service">
>> <map-to xml="service"/>
>> <field name="id"><bind-xml node="attribute"/></field>
>> <field name="mode"><bind-xml node="attribute"/></field>
>> </class>
>>
>> Is there any way to map the class so that the id attribute is mapped
>> like this:
>>
>> <service mode="R">D2STD</service>
>>
>> Rather than like this:
>>
>> <service mode="R"><id>D2STD</id></service>
>>
>> Much appreciated,
>>
>> Dan.
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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