Hi Stephan,
I`m using the mapping file as this appears to be the most flexible
option for our needs.
What I`m actually trying to do is map 2 elements to a single method
,which is a collection, in a class.
So my XML looks like:-
--------->ElementB
ElementA---|
--------->ElementC
In my Java code I would like to add both Elements B and C to the same
collection as ElementB and C Map to classes that derive from the same
interface. So in my mapping I tried to do something like:-
<field name="items" type="itemInterface" required="false" direct="false"
transient="false" collection="arraylist">
<bind-xml name="itemB" node="elementB"
reference="false" />
<bind-xml name="itemC" node="elementC"
reference="false" />
</field>
But this is invalid as there can be only one <bind-xml> tag within a
field.
I also tried to add 2 fields to the mapping file referencing the same
"items method" like:-
<field name="items" type="itemInterface" required="false" direct="false"
transient="false" collection="arraylist">
<bind-xml name="itemB" node="elementB"
reference="false" />
</field>
<field name="items" type="itemInterface" required="false" direct="false"
transient="false" collection="arraylist">
<bind-xml name="itemC" node="elementC"
reference="false" />
</field>
But when I tried to Marshall an Exception was thrown stating that there
was duplicate method names in the mapping file.
So is it possible to map 2 XML Elements to one method in a Java class???
Thanks for your help.
Darran
-----Original Message-----
From: Stephen Bash [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 12, 2006 8:49 PM
To: [email protected]
Subject: Re: [castor-user] Castor inheritence from existing domain model
Darran-
Just to clarify, are you attempting to use a binding file to generate
classes from your schema? Or are you using a mapping file to generate
the XML using the existing java classes?
In the later case, it should be pretty easy to get it set up using the
InterfaceA, at which point Castor doesn't need to know much about ClassA
or ClassB. If you're attempting to use the binding file, I
unfortunately don't know much about that.
Thanks,
Stephen
On 4/12/06, White, Darran <[EMAIL PROTECTED]> wrote:
>
>
>
> Hi,
> I have 2 classes (class ChildA, class ChildB) that both implement an
> interface (InterfaceA). A third class (class C) contains a list of
> interfaceA.
>
> Now my XML schema has a element that maps to class C which has a
> sequence of elements that map to ChildA and ChildB. I would like these
> to be added to the list in C but I`m only able to add one <xml-bind>
> tag to the class mapping for class C. Does anyone know if this kind of
> behaviour is possible and if so how is it done??????? I`ve checked the
> docs on the Castor site and can`t see any way of doing this except by
> using the <extends> tag but I`m not sure how this works as its not
that well documented.
>
> A second question is if the source generator is used to generate the
> source files from a schema can these be annotated somehow so extra
> functionality can be added to these source files which won`t be over
> written if the generator is run again.
>
> Many Thanks
>
> Darran
>
> This message may contain privileged and/or confidential
information.
> If you have received this e-mail in error or are not the intended
> recipient, you may not use, copy, disseminate or distribute it; do not
> open any attachments, delete it immediately from your system and
> notify the sender promptly by e-mail that you have done so. Thank
you.
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------