Walden,

Castor documents the binding, take a look at the web site: castor.exolab.org.
The tool is not perfect but most of the cases can be achieved. The force of this tool (like other tools you can pay for), is that if you change the schema,
you just need to regenerate the java framework, and there is only one language to learn: XML Schemas.
JAXB comes with multiple files: DTD, descriptors for the mapping, ...
I think that Schemas give you the advantage to add very strong data constraints on elements, attributes. The Castor framework follows the same concept than JAXB:
- Marshalling/Unmarshalling framework
- Validation framework

I wrote a pattern on theserverside.com web site discussing about the use of such frameworks in a J2EE (EJB) environment using well known patterns (delegates, value objects, ...). The power of Schema (XSD) and Java allow you to take out all validation code and add stronger constraints that the Java language (or any other) cannot give you. You have to weight the tradeoffs (speed, ...) in your design though.

If you want to see some examples, just take the PO schema from the W3c site and run the sourceGen from Castor on it.
One improvement that Exolab could make though: using Collection rather than Enumeration....

http://www.theserverside.com/patterns/thread.jsp?thread_id=8675

Olivier

Walden Mathews wrote:
[EMAIL PROTECTED]">
JAXB gets incrementally more complex the more you have to override default translation,
but if you're willing to accept the default, it's only as complex as three lines of descriptor
per XML schema.  Does Castor give you any control over the binding to java classes at all?
If so, how does it avoid the complexity of JAXB?  If not, how does it differ from JAXB in
default mode?
 
Thanks,
Walden
-----Original Message-----
From: obrand [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 16, 2002 2:11 PM
To: [EMAIL PROTECTED]
Subject: Re: XML to XSD

I would recommend using Castor from Exolab to deal with XML and Schemas. JAXB is too complex since it tries to redefine what Schema already defines (constraints, type, ....). Using Castor, you will be able to generate the java framework starting from one file: your schema !
A tool creating Schema from XML is nearly impossible due to the semantic information which does not show in an XML document. For this reason using DTD is useless, and JAXB once again is too complex.
I would recommend XML Spy which helps you creating a Schema from an existing XML, then you can tweak it to refine your rules.
Once finished, you just take the schema, call sourceGen from the exolab distribution and.... Voila !
Just to add to the polemic, it seems that SUN's future on JAXB is unclear. I have heard from other SUN engineers that the project might be re-architected. Anyway SUN's direction for J2EE 1.4 is to move to Schemas, allowing standard checking from the parser and be able for some vendors to extend some configurations (I am sure that iPlanet is going to like it......).

Olivier

Adam Greene wrote:
000d01c1e56d$6dcd4690$688fb3cf@adam" type="cite">
Thanks.  I will look into JAXB (I can get DTDs without any problems from Forte (it creates them from the XML)).
----- Original Message -----
Sent: Tuesday, April 16, 2002 10:42 AM
Subject: RE: XML to XSD

Note the difference between "XML schema" and "XML Schema". The former includes DTDs and XML Schemas. I don't believe JAXB currently works with XML Schemas, only DTDs.
-----Original Message-----
From: Walden Mathews [mailto:[EMAIL PROTECTED] ]
Sent: Tuesday, April 16, 2002 8:32 AM
To:'[EMAIL PROTECTED]'
Subject: RE: XML to XSD

Sun has JAXB (Java Architecture for XML Binding) that compiles an XML schema into
java classes.  It's in early release form, and it only supports DTD schema now, although
their docs say they intend to support W3C schema sometime soon.
 
JAXB is interesting in that you can control the way java classes are generated by writing
a binding descriptor that overrides the compiler's assumptions, pay as you go.  Don't know
if this product has a future, though.
-----Original Message-----
From: Adam Greene [ mailto:[EMAIL PROTECTED] ]
Sent: Tuesday, April 16, 2002 8:43 AM
To: [EMAIL PROTECTED]
Subject: XML to XSD

Does anyone know of a good (and free) program that would help one create an XML Schema from an XML file.  I'm still kind of new to all these different XML formats (DTD, XML, XSD, WSDL, and the list goes on), but I want to use Castor to create classes for loading and saving XML and it wants to start with an XSD.  Or as a another possibility an XML to Java maker / compiler.  Does Xerces have one (like Xalan has the XSLT compiler)??


***************************************************************************************
WARNING: All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.
***************************************************************************************


Reply via email to