tags:

views:

248

answers:

2

Hi,

I can't get my generated classes to implements any interface.

This is my xml schema file: xmlns:jxb="http://java.sun.com/xml/ns/jaxb/" xmlns:ai="http://jaxb.dev.java.net/plugin/if_insertion" jxb:extensionBindingPrefixes="ai" >

<xs:element name="header">
    <xs:annotation>
        <xs:appinfo>
            <ai:interfaces check="1">
              utility.RuleInterface
            </ai:interfaces>
        </xs:appinfo>
    </xs:annotation>

    <xs:complexType>
        bla bla bla
    </xs:complexType>

I checked the "Extension" option in the JAXB options and I hav added the xjc-if-ins.jar to the "Libraries" section of my project Properties.

But the generated Header class doesn't implements the utility.RuleInterface.

I can figure out what am I doing wrong... Is it something missing?

Any idea?

regards, Segolas

A: 

Have you actually activated the plugin? With an option like -Xinheritance?

Here's another plugin you may use:

http://confluence.highsource.org/display/J2B/Inheritance+plugin

Here's a sample project (Ant and Maven):

http://download.java.net/maven/2/org/jvnet/jaxb2_commons/jaxb2-basics-sample-po/0.5.2/

lexicore
Here https://jaxb2-commons.dev.java.net/interface-insertion/ it says I have to use the -extension option, which I think is what I do checking the "Extension" option on NetBeans.Only now I see the -Xifins option... I think now it's going to work, too bad is not possible to use theese xjc options from netbeans
Segolas
You also need to turn on this specific plugin using the option like one I specified. -extension is not enough.
lexicore
Yes, I figure it out roght now. (I've edited my first comment).Thanks for your answer!
Segolas
Now I got another problem, doing xjc -cp $JAXB_HOME/share/lib/xjc-if-ins.jar -extension -Xifins schema.xsd always returns with "unrecognized parameter -Xifins" error.
Segolas
A: 

Just another note for others with the same problem. The elements inside the xml schema file should be written in this way:

<xs:complexType name="header">
   <xs:annotation>
        <xs:appinfo>
            <ai:interfaces check="0">
              utility.RuleInterface
            </ai:interfaces>
        </xs:appinfo>
    </xs:annotation>          
</xs:complexType>

and the you can refer to them:

<xs:element name="rule">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="header"  type="header" maxOccurs="unbounded" />
                ...
            </xs:sequence>
        <xs:complexType>

My problem was that I had declared the header as <xs:element name="header"> and than I was referring to the element with <xs:element ref="header" maxOccurs="unbounded" /> and this approach doesn't seems to work...

Segolas