users@jaxb.java.net

Re: Customization namespaces and "vendor extensions"

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 19 Jan 2005 08:07:05 -0800

Rune Peter Bjørnstad wrote:
> I'm currently interested in "triggering" some customized code generation
> when an element is annotated. Consider, for example, the following
> annotation:
>
> <xsd:element name="configFile" type="xsd:string">
> <xsd:annotation>
> <xsd:appinfo>
> <myns:file>
> <myns:validateExistence />
> </myns:file>
> </xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
> The 'configFile' element should be a java.util.File element, which is
> validated for existence when parsed. Again, I know this can be achieved
> using the jaxb:javaType annotation, but this is just an example.

Perhaps I wasn't clear.

Suppose we parse this sample. We call your extension with <myns:file>
and you give us back an object that represents the parsed annotation.
Maybe an instance of the MYNSFile class.

Internally, we first attach it to XSOM's XSElementDecl. Then our
compiler front-end runs, which creates a ClassItem for this element.
Because extensions can only run after we've finished the basic code
generation, we have to somehow attach your MYNSFile instance to one of
the model objects the front-end creates. But exactly which model object
we should attach your annotations isn't quite clear to me.

For example, in your MYNSFile case, you'd almost want it on FieldItem,
not on ClassItem. But how the JAXB RI, without knowing the semantics of
your annotations, can determine whether it should put yours on a
ClassItem or a FieldItem? If I more or less randomly pick which
annotation goes to where, does that work for you?

That was the question I meant to ask.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net