2

I'm using xjc via maven to generate sources. I'm using an XSD and a bindings file. I would like my generated classes to have the annotation @XmlType(name = ""). I can't see how to set the name to be blank.

I've tried (amongst other ideas) annotating using annox:annotate("http://annox.dev.java.net") with annox:class="javax.xml.bind.annotation.XmlType" but this adds another @XmlType annotation rather than replacing/overwriting the existing one.

Is there a way to set the @XmlType's name to be blank?

4

1 回答 1

0

如果 Type 是匿名类型,name则留空。在这里检查(“映射类”部分)。

为此,您需要在<element>标签内声明您的类型。以下架构显示了一个示例:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Container">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Item" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="Item">
        <xs:complexType >

        </xs:complexType>
    </xs:element>

</xs:schema>   

这里,元素Item是匿名类型,这是生成的类:

@XmlType(name = "")
@XmlRootElement(name = "Item")
public class Item {


}
于 2013-09-18T13:12:02.587 回答