Hi Werner ,
It worked .Thanks a lot for your input.
This is what I did
<field name = "count" type = "src.lesson3.RecordCount">
<bind-xml name="count"/>
</field>
<class name = "src.lesson3.RecordCount" >
<map-to xml="count"/>
<field name = "value" type = "integer">
<bind-xml node="text"/>
</field>
</class>
<contracts number="001">
<count>
100
</count>
</contracts>
Werner Guttmann wrote:
>
> Not really. For a field mapping, you can only map the XML (whether in
> form of an element or an attribute or text) to an existing member within
> a Java class. And for that to work, you'll have to have a class mapping
> as well.
>
> Can you try the following field mapping (within a class mapping) and see
> whether it works (given that your RecordCount class has a property count):
>
> <field name="count" type="string">
> <bind-xml node="text" />
> </field>
>
> Please replace the type="string" with the right type definition for your
> case.
>
> I am not 100% sure, but maybe somebody else can help us here ?
>
> Regards
> Werner
>
> lingan wrote:
>> Hi ,
>>
>> Is it possible to map the below XML to a Class like Count.java with an
>> field
>> int count ?
>>
>> <count>
>> 100
>> </count>
>>
>> when I tried it threw an exception
>>
>> Caused by: org.xml.sax.SAXException: Illegal Text data found as child of:
>> count
>> value: "100"
>>
>> Mapping I used :
>> <field name = "count" type = "src.lesson3.RecordCount">
>> <bind-xml name="count"/>
>> </field>
>>
>> But if I wrap the value 100 within a tag like this it wraps
>> <count>
>> <val> 100 </val>
>> </count>
>>
>> I would like to know if a single text could be mapped ?
>>
>> any input is apprciated.
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
View this message in context:
http://www.nabble.com/Read-text-into-a-Class-attribute-tf4257914.html#a12132942
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email