dev@jaxb.java.net

Re: JAXB plug-in question

From: Kohsuke Kawaguchi <kk_at_kohsuke.org>
Date: Tue, 06 Sep 2005 11:34:58 -0700

David Pirkle wrote:
> I'd like to build a GUI that allows elements from an XML hierarchy to be
> selected, but without requiring an XML document. My thought is to base
> the hierarchy on an XML schema that describes the document. I've been
> poking around to see if I can find some library that reads an XML schema
> and assembles a representation of the corresponding hierarchy of
> elements that one would expect in a conforming document. Since the JAXB
> compiler must be doing something of the sort in mapping an XML schema to
> a Java class hierarchy I thought to see what might be possible via JAXB.

We use a library called XSOM (http://xsom.dev.java.net/) to parse XML
Schema. You might consider using this directly.

>>>From there I stumbled on to your description of writing JAXB plug-ins.
> Since I don't want to actually write out Java classes, though, I'm not
> sure if this is the best approach to take. Your example shows how to
> use schema annotations to inject code into generated classes, which is
> supplementing the compilation process rather than entirely circumventing
> it the way I would need to do.

JAXB plug-ins are generally intended for doing additional work at the
schema compilation time. Sounds you like you are interested in adding
some runtime functionality. I can't say definitively because I don't
know for sure what you mean, but I suspect JAXB plug-ins aren't what you
are looking for.


> For the type of problem I want to solve, do you have any
> recommendations? Would plugging into JAXB be reasonable, or is there
> some other library that you are familiar with that might be more
> directly applicable to what I want to do?

Another thing that might be of interest to you is
http://jaxb2-reflection.dev.java.net/, which allows you to access JAXB
objects and its XML information at runtime. From what I can tell from
your message, I'd start from this.


-- 
Kohsuke Kawaguchi