Please see inline.

Werner 

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Montag, 26. Februar 2007 21:32
> To: [email protected]
> Subject: [castor-user] Help generating java classes bound to xsd
> 
> Hello,
> 
> it is the first time I use Castor. What I would like to do is 
> to create some Java classes bound to some XML files. 
Which is what Castor has exactly been designed for. It looks like you've got 
two options here. 

A) If you do not have XML schemas yet, simply create the Java classes manually 
and provide a mapping file that bings your Java classes to the already existing 
documents. I do acknowledge that this task might get tedious if thereƤs a high 
number of Java classes involved, and would thus recommend approach B).

B) Derive XML schema(s) from your XML instance documents, and use these XML 
schema(s) to have Java classes generated for you, using Castor's XML code 
generator (aka source generator). Whilst this implies that you will have to 
create XML schema documents somehow, Java class generation is for free, and in 
addition the code generator will create the so-called descriptor classes that 
represent an internal form of the mapping file from task A).

> I would 
> then use these Java classes in a Servlet for example.
Yes.

> I think i could do it this way: I would generate from the XML 
> I already have some XSD schemas, then using Castor I would 
> generate those Java classes. Is this the right way and a 
> sensible thing to do?
Yes, and you've got various options here. Use the 'SourceGenerator' manually 
(from within java or command line), use an Ant task definition or a Maven 
plugin. It's all down to your needs.
> 
> Btw, the generated classes does depend on Xerces still? Or 
> just on some Castor only related Jar file?
Yes and no. It depends. The generated class files do not depend on Xerces 
directly. The only dependency is the main Castor XML Jar file. But when using 
the Marshaller for marshalling object instances to XML, *and* you enable pretty 
printing in the castor.properties file, you'll need to have Xerces on your 
classpath.

> 
> Regards,
> Luca
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to