users@jaxb.java.net

Using annox to generate annotations: works for me in only limited case

From: Roger Parkinson <roger_at_senanque.co.nz>
Date: Fri, 18 Sep 2009 16:42:31 +1200
I'm using annox to add annotations to my classes generated by XJC.
This works:
-----------------------------------------------------------------------------------
 ...
           <element name="name">
                <xsd:annotation>
                    <xsd:appinfo>
                        <annox:annotate>
                           <MyAnnotation myName="xxx" xmlns="http://annox.dev.java.net/nz.co.senanque"/>
                        </annox:annotate>
                    </xsd:appinfo>
                </xsd:annotation>
                <simpleType>
                    <restriction base="string">
                        <maxLength value="30"></maxLength>
                    </restriction>
                </simpleType>
            </element>
...
-----------------------------------------------------------------------------------
Where the annotation class looks like this:
-----------------------------------------------------------------------------------
package nz.co.senanque;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)

public @interface MyAnnotation {
    public String myName();

}
-----------------------------------------------------------------------------------
I have two questions on this:

If I add a second parameter to MyAnnotation XJC refuses to parse it.
This is a problem because I really do want to have multiple arguments on that annotation.
Second question is curiosity. XJC fails to parse unless I add 'public' to 'myName' I notice the examples don't have this.

Why not?

With luck the questions are related and I've missed something important.

Thanks for the help
Roger

--