Yes. You are right. Looks like this is an issue with mutivalued fields used with location attribute.

So, I was able to make things work by declaring a dedicated class for each element type node. That is, in the above example, declaring a class Category for the <category> element.

So the earlier XML changed to:


---snippet---
<field name="categories" collection="arraylist" type="mypackage.Category">
        <bind-xml name="category" location="categories"/>
</field>

<class name="mypackage.Category">
  <field name="label" type="string">
      <bind-xml name="label" node="attribute"/>
  </field>
</class>
----snippet---

--Mihir


On Jun 3, 2009, at 11:36 PM, Werner Guttmann wrote:

Hi,

I am not actually convinced that this is an issue related to whitespace
handling at all. I think that this is an issue in the context of
multi-valued fields when used together with locations.

Anyhow, to be able to look into this, can I please ask you create a new
Jira issue at

http://jira.codehaus.org/browse/CASTOR

and attach a (minimal) working test case.

Regards
Werner

Mihir Mathuria wrote:

Hello Gurus,

Need your help regarding unmarshalling and whitespaces.

I spent quite some time on this issue and tried following advices in
earlier posts, but in vain.

I have the following xml:

<categories>
   <category label='Male Female'/>
   <category label='Sports'/>
</categories>


I try to unmarshal that using the following mappings:

<field name="columnHeaders" collection="arraylist" type="string">
   <bind-xml name="label" location="categories/category"
node="attribute"/>
</field>

However the columnHeaders arrayList comes up with 3 elements ['Male',
'Female', 'Sports'] instead of just two ['Male Female','Sports']


After the creating the Unmarshaller I do make sure preserveWhitespace
is set to 'true'
   unmarshaller = context.createUnmarshaller();
   unmarshaller.setWhitespacePreserve(true);

But this does not help.

I also tried adding "xml:space='preserve'" in the <category> node above.
No luck.

I am running out of ideas. Some one please guide.

I am using castor 1.3

Thanks.
Mihir.


---------------------------------------------------------------------
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




--
Mihir Mathuria
Senior Java Developer

E-Poll Market Research
16133 Ventura Blvd. Ste. 905
Encino, CA 91436
P  818.995.4960 ext. 40
F  818.995.4970
[email protected]

==================================================
Stay on top of the latest trends and opportunities
with our free monthly newsletter:  "Anticipate"
Sign up at:  www.epollresearch.com

This email message and any and all files transmitted
with it contain the confidential and proprietary
information of E-Poll Market Research. It is directed
only to the person(s) to whom this email is addressed
for the limited use and purposes as intended by E-Poll.
If you have received this email in error please notify
the sender immediately by phone at (818) 995-4960 or
email, and please destroy the original message without
making a copy.




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to