Hi again
Sarathi Balasundaram wrote:
> Hi
>
> This is my first stab at using Castor...It has been good learning
> curve so
> far. I am presently stuck with something and would need your help
> in
> resolving it.
>
>
>
> The output xml that I am looking for should be as below
>
> <my-response>
> <employee-wrapper>
> <manager/>
> </employee-wrapper>
>
> <employee-wrapper>
> <manager/>
> </employee-wrapper>
>
> </my-response>
>
>
>
> My mapping looks as below
>
> <class name="MyResponse" auto-complete=
> "true">
> <map-to xml="my-response"/>
> <field name="employees" type="Employee"
> collection="array">
> <bind-xml auto-naming="deriveByClass" location=
> "employee-wrapper" node="element"/>
> </field>
> </class>
>
>
> Employee is an abstract class. Manager and Worker are concrete
> classes that extend Employee class.
>
> The WSDL definition for employee-wrapper is
>
> <xs:element name="employeeWrapper">
> <xs:complexType>
> <xs:choice>
> <xs:element name="manager" type="Manager"/>
> <xs:element name="worker" type="Worker"/>
> </xs:choice>
> </xs:complexType>
> </xs:element>
The problem with your approach is that the XML schema (fragment) given
here defines something somepletely different from the mapping you have
defined above. In the XML schema, you are using a <xs:choice> to signal
that you want either a manager or a Worker, but definitely not both of them.
>
> So, the employeeWrapper can have either manager or worker or both
>
>
> But the problem that I am facing are of 2 kinds
>
>
> 1. When 2 managers are a part of the employeeWrapper , it fails
> with
> org.exolab.castor.xml.MarshalException: element "manager" occurs
> more than
> once.
> 2. If there is manager and worker, the output is as below which
> is different from what I expect.
>
> <my-response>
> <employee-wrapper>
> <manager/>
> <worker/>
> </employee-wrapper>
> </my-response>
>
>
> Any help would be appreciated.
>
> thanks
>
> Kind Regards
> Sarathi Balasundaram
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email