Hi All,
I am trying to use castor in my project for XML data
binding. I have generated the source code using
Castor's SourceGeneration utility.
First I tried with Descriptor classes and all seemed
to work fine. But I am more inclined towards using
mapping file instead and have less
classes compared to what castor generates.
So, I generated the mapping file using Castor's
Mapping File generation utility. But this doesn't seem
to work. Mapping file works with very simple
XML messages. But it does not work if you have nested
Choice, Sequence etc in your XSD.
I have searched internet many times but don't see any
example explaining how to deal with nested Choices,
Sequence or other Model groups. There is some blurb on
castor site but there is no example posted.
Does anyone have any working example which involves
Mapping file to deal with Choice, Sequence, or any
other nested Model groups ?
Following is one xsd file where I never got mapping
file to Work.
<xs:element name="EndPoint">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicationID"
type="xs:string"/>
<xs:choice>
<xs:element name="EndPointID"
type="xs:string"/>
<xs:element name="EndPointRef"
type="xs:int"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
The Mapping file I am using is :
<class
cst:name="com.blah.blah.cat5.castor.endpoint.EndPoint">
<description>Default mapping for class
com.blah.blah.cat5.castor.endpoint.EndPoint</description>
<map-to cst:xml="EndPoint"
cst:ns-uri="http://blahblah.com/namespace/admin/QueryEndPoint"/>
<field cst:name="applicationID"
cst:type="java.lang.String" cst:required="true">
<bind-xml name="ApplicationID"
node="element"/>
</field>
<field cst:name="endPointSequenceChoice"
cst:type="com.blah.blah.cat5.castor.endpoint.EndPointSequenceChoice"
cst:required="true">
<bind-xml name="-error-if-this-is-used-"
node="element"/>
</field>
</class>
<class
cst:name="com.blah.blah.cat5.castor.endpoint.EndPointSequenceChoice">
<description>Default mapping for class
com.blah.blah.cat5.castor.endpoint.EndPointSequenceChoice</description>
<map-to
cst:ns-uri="http://blahblah.com/namespace/admin/QueryEndPoint"/>
<field cst:name="endPointID"
cst:type="java.lang.String" cst:required="true">
<bind-xml name="EndPointID"
node="element"/>
</field>
<field cst:name="endPointRef" cst:type="int"
cst:required="true">
<bind-xml name="EndPointRef"
node="element"/>
</field>
</class>
Your help in this matter is greatly appreciated. I
just hope Castor had better documentation.
Thanks,
Manish
__________________________________
Do you Yahoo!?
Send a seasonal email greeting and help others. Do good.
http://celebrity.mail.yahoo.com
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user