开发者

JAXB, Netbeans and Interface Insertion Plugin

开发者 https://www.devze.com 2022-12-27 08:08 出处:网络
I can\'t get my generated classes to implement any interfaces. This is my xml schema file: <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"

I can't get my generated classes to implement any interfaces.

This is my xml schema file:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"            
        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:inter开发者_StackOverflow中文版faces>
            </xs:appinfo>
        </xs:annotation>

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

    ....

I checked the "Extension" option in the JAXB options and I have 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?


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/


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

0

精彩评论

暂无评论...
验证码 换一张
取 消