thanks Keith for your valuable input. i am going to
try the mix of mapping file and Descriptor classes. 

i wasn't aware that we can use mapping file and
Descriptor at the same time. I think it would be
really great if Castor website mentions about what is
possible with Mapping file and where it lacks some
streanghts compared to Descriptor files. I remember
reading somewhere where it says Mapping is better if
you want loose coupling between your classes and XML.,
which does makes sense. And that is why I am more
inclined to use mapping file. I don't think I have
seen anywhere, where it mentions that mapping file
does not work if you have Choices in your schema.


Anyways, I am going to play with combo of mapping file
and Descriptors.

Thanks,
Manish 


--- Keith Visco <[EMAIL PROTECTED]> wrote:

> 
> 
> 
> kumar manish wrote:
> > 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.
> 
> The SourceGenerator takes advantage of the ability
> to generate it's 
> descriptor classes, some of what castor generates in
> those descriptor 
> classes cannot easily be expressed in the mapping
> files.
> 
> The mapping files were intended to take existing
> object models and map 
> them into xml, but they are not yet expressive
> enough to express XML 
> schema constraints. So by not using the descriptors
> you're basically 
> throwing away a lot of what is done in them.
> 
> >  
> > 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.
> 
> That's because the mapping file doesn't have the
> ability to express a 
> choice. Basically with a mapping file you only get
> "all", support.
> 
> I recommend using the descriptors that were
> generated by Castor instead 
> of trying to do the mapping.
> 
> If you really want to reduce the number of classes
> you can try to use a 
> mix of descriptors and a mapping file. Use the
> descriptors for the 
> complex cases and use the mapping file to remove the
> need for the simple 
> descriptors.
> 
> --Keith
> 
> >  
> > 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
> > 
> 
> 
> 
>
-----------------------------------------------------------
> 
> If you wish to unsubscribe from this mailing, send
> mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
> 



                
__________________________________ 
Do you Yahoo!? 
Send holiday email and support a worthy cause. 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

Reply via email to