users@jaxb.java.net

Re: JAXB generated Java Model + JXPath

From: Prashant <prashant_at_pramati.com>
Date: Tue, 09 Aug 2005 18:53:39 +0530

Hello:

Seem to have run into some rought weather with RTFS on JAXB RI 1.0.

Well I did get my CodeAugmenter to be picked up by XJC task.


> 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.

So if I understand this correctly, from the AnnotatedGrammer you can get
list of JavaItem. Each JavaItem contains information on
GeneratedCodeModel. But How can one access the corresponding
JavaItemVisitor that has the information on the Schema that was
responsible for this JavaItem ?

> 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

Any help is appreciated.
Thank you
-Prashant