users@jaxb.java.net

Re: Binding arbitrary Java objects

From: Robert Lowe <rmlowe_at_rmlowe.com>
Date: Tue, 13 May 2003 22:44:03 +0800

> > In my opinion, this possibility can also be stated as: the possibility
of
> > generating an XML Shema from an instance XML document (and then compile
it
> > with JAXB).

Here's a neat Web-based tool that infers a DTD or Schema from an XML file:

http://www.hitsw.com/xml_utilites/

Of course, the schema you get is highly dependent on the "completeness" of
the instance, and certainly won't give you all the constraints you might
want--enumerations are one example as Brandon mentions. But it's a nice way
to get a first-cut schema if you don't have one. It certainly presents some
interesting possibilities to use this in combination with JAXB, to generate
binding classes when you don't have a Schema.

>
> > Instead of it, I was thinking about another functionality which could be
> > interesting, to be included in JAXB or in a separate tool. It's the
> > possibility of generating an XMLSchema suitable to represent the content
> of
> > arbitrary java classes. In fact, JAXB spec says, if I remember well,
that
> a
> > marshaller may (but is not required to) be able to marshal any object,
> > doesn't matter if it's been generated by JAXB compiler or not. This is
an
> > interesting feature to ease the adoption of JAXB in a previously
existing
> > application.
> > What do you think about it?

I believe .NET does something similar. It would certainly be useful if you
wanted to implement a service in Java and then publish it as a
document-oriented Web service--you could use JAX-RPC to generate the WSDL,
and JAXB to generate the XML Schema.