Hello,
I fixed the issue by using "location" feature in <field> element.
Below is the mapping,
<class name ="package.InnerNode">
<map-to xml="INNER_NODE"/>
<field name="innerNode1" type="string">
<bind-xml name="INNER_NODE1"/>
</field>
<field name="innerNode1AttributeConstant" type="string">
<bind-xml name="SUBSCR" node="attribute"
location="INNER_NODE1"/>
</field>
</class>
This is still not the best way, but atleast i avoided having inner classes
or multiple classes for each element.
-Ramanan.
-Regards,
Ramanan.
Philipp Erlacher wrote:
>
> Hello,
>
> I don't think there is a way to add a constant attribute but I am
> fairly new myself.
>
> You could try to use XSLT to transform the generated XML and add the
> attribute by yourself.
> I would be very interested in the XSLT code that could produce the
> changes you are trying to accomplish.
> So please let me know you are going to tackle this problem.
>
> Cheers,
> Philipp
>
>
> On Thu, Jun 17, 2010 at 2:01 AM, toramanan <[email protected]> wrote:
>>
>> Hi,
>>
>> I am bit new castor and need some help in generating an xml in the below
>> format from a java object.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <PARENT_REQUEST>
>> <NODE1>NODE1_DATA</NODE1>
>> <NODE2>NODE2_DATA</NODE2>
>> <INNER_NODE ATTRIB="ADATA">
>> <INNER_NODE_1 ATTRIB="ADATA">A</INNER_NODE_1>
>> <INNER_NODE_2 ATTRIB="ADATA">B</INNER_NODE_2>
>> <INNER_NODE_3 ATTRIB="ADATA">C</INNER_NODE_3>
>> <INNER_NODE_4 ATTRIB="ADATA">D</INNER_NODE_4>
>> <INNER_NODE_5 ATTRIB="ADATA">E</INNER_NODE_5>
>> <INNER_NODE_6 ATTRIB="ADATA"/>
>> <INNER_NODE_7 ATTRIB="ADATA">F</INNER_NODE_7>
>> <INNER_NODE_8 ATTRIB="ADATA">G</INNER_NODE_8>
>> </INNER_NODE>
>> </PARENT_REQUEST>
>>
>> The issue here is "ATTRIB=ADATA" is constant attribute that need to be
>> applied to all the INNER_NODE and its child nodes. I don't want to write
>> separate class for each INNER_NODE_1 to n to achieve this output. Is
>> there a
>> way to add the attribute ATTRIB=ADATA as a constant during runtime
>> (marshalling) for the elements in the INNER_NODE ?
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Help-in-Castor-Marshalling-tp28909074p28909074.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
>
>
>
>
--
View this message in context:
http://old.nabble.com/Help-in-Castor-Marshalling-tp28909074p28918896.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