Hello,
I've been unable to find out how to do the following,
if possible at all. Can someone please help?
In an unmarshalling operation, I need to map different
XML tags to the same class, and the resulting objets
be put in a collection-type attribute.
For example, in the following:
public class Document {
protected String title;
protected ArrayList textParts
....
}
public class TextPart {
protected String author;
protected String contents;
....
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<doc>
<title>......</title>
<introduction>
<author>Joe</author>
<contents>
This document shows ...
</contents>
</introduction>
<body>
<author>Janet</author>
<contents>
Let's start ...
</contents>
</body>
</doc>
Both <introduction> and <body> tags should map to
objects of the same "TextPart" class, and these
objects put in the "textParts" ArrayList in Document.
Where it not incorrect, it would be equivalent to
declaring:
....
<field name="textParts" type="TextPart"
collection="collection">
<bind-xml name="introduction" node="element"/>
<bind-xml name="body" node="element"/>
</field>
<class name="TextPart">
....
</class>
Of course I could replace the different tags with a
single one, i.e.
<textpart type=....>
and map this to the TextPart class, but in this case
we cannot change the XML.
Thanks for any tip of suggestion,
Guifre
__________________________________________________
Correo Yahoo! - 6 MB, antivirus y antispam �gratis!
Reg�strate ya - http://correo.yahoo.es
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user