users@jaxb.java.net

Re: JAXB generated Java Model + JXPath

From: Prashant <prashant_at_pramati.com>
Date: Wed, 03 Aug 2005 17:55:54 +0530

Hi.

>Here's a small roadmap for you.
>
>
Thanks, I was thinking of a kludge with
com.sun.tools.xjc.reader.NameConverter ;)
But your suggestion looks more beautiful.. Will pursue

>The information about mapping between elements/attributes and
>classes/properties is almost unavailable after the schema is compiled.
>Therefore you'll have to write an add-on (a CodeAugmenter, actually) to
>generate your very custom NodePointer, NodeIterator and
>NodePointerFactory implementations alongside with classes generated by JAXB.
>
>CodeAugmenters are provided with AnnotatedGrammar object instance, which
>is richly filled with information on what is what. JAXB organizes the
>processed schema as a tree of expressions and the easiest way to
>traverse the tree (while generating Node** things you need) is to use
>visitors, for instance ExpressionVisitor and JavaItemVisitor. They have
>methods like onElement(ElementExp exp), where ElementExp will carry the
>information you actually need to understand how was this element
>actually called in the schema. From the other side, you have also
>onClass/onField where you get ClassItem and FieldItem. Having these
>objects you may determine how is this schema construct represented with
>classes or properties.
>
>Finally, you'll have to generate the code. For this purpose, JAXB uses
>so-called "code model" which is a beatiful set of classes that represent
>the syntax of Java code.
>
>Needless to say, your task is uneasy, but very interesting. I would do
>this myself if I had little more time.
>
>I also recommend that you take a look at jaxbcommons and jaxbvalidation
>projects on dev.java.net. They both have several add-on implemented.
>jaxbvalidation might be especially interesting for you. It generates
>"validator" classes that perform object-level validation against the
>initial schema. You task is in many places similar.
>
>Bye.
>/lexi
>