xjc错误 - 已使用多个模式文件定义

时间:2013-07-29 14:18:21

标签: java xjc

我们有一些我们无法控制的其他源创建的xsd架构文件。当我们尝试使用xjc生成java类时,我们得到错误抱怨类型在编译时已定义。我们使用绑定文件查看了自定义,但找不到与我们的案例有关的任何内容。使用附加的xsd文件,我们希望看到单个TESTBody.java类生成如下:

public class TESTBody {
    protected MsgType1 msgType1;
    protected MsgType2 msgType2;
    protected MsgType3 msgType3;
    ...
}

有人可以提供一些帮助或提示吗?

提前致谢。

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:complexType name="TEST_Header">
        <xs:sequence>
            <xs:element name="sender" type="xs:string" />
            <xs:element name="receiver" type="xs:string" />
            <xs:element name="version" type="xs:integer" />
            <xs:element name="sequenceNo" type="xs:string" minOccurs="0" />
        </xs:sequence>
    </xs:complexType>


</xs:schema>

================================

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation="TEST_HeaderType.xsd" />

    <xs:element name="TEST_Message">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="TEST_Header" type="TEST_Header" />
                <xs:element name="TEST_Body" type="TEST_Body" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!--#DOCUMENTATION:Second child element; contains the message payload-->
    <xs:complexType name="TEST_Body">
        <xs:sequence>
            <xs:element name="msgType1" type="msgType1" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="msgType1">
        <xs:sequence>
            <xs:element name="firstName" type="xs:string" />
            <xs:element name="lastName" type="xs:string" />
            <xs:element name="addressLine1" type="xs:string" />
            <xs:element name="addressLine2" type="xs:string" />
            <xs:element name="age" type="xs:integer" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>    

================================

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation="TEST_HeaderType.xsd" />

    <xs:element name="TEST_Message">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="TEST_Header" type="TEST_Header" />
                <xs:element name="TEST_Body" type="TEST_Body" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!--#DOCUMENTATION:Second child element; contains the message payload-->
    <xs:complexType name="TEST_Body">
        <xs:sequence>
            <xs:element name="msgType2" type="msgType2" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="msgType2">
        <xs:sequence>
            <xs:element name="className" type="xs:string" />
            <xs:element name="teacherName" type="xs:string" />
            <xs:element name="textBook" type="xs:string" />
            <xs:element name="classRoom" type="xs:integer" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

================================

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation="TEST_HeaderType.xsd" />

    <xs:element name="TEST_Message">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="TEST_Header" type="TEST_Header" />
                <xs:element name="TEST_Body" type="TEST_Body" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!--#DOCUMENTATION:Second child element; contains the message payload-->
    <xs:complexType name="TEST_Body">
        <xs:sequence>
            <xs:element name="msgType3" type="msgType3" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="msgType3">
        <xs:sequence>
            <xs:element name="eventName" type="xs:string" />
            <xs:element name="eventDescription" type="xs:string" />
            <xs:element name="eventLocation" type="xs:string" />
            <xs:element name="eventTime" type="xs:date" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

======================

0 个答案:

没有答案