4

我使用 xjc 2.2.4-2 生成 java 类。我有2个xsd文件,message.xsd和typeDef.xsd,绑定文件是schema.xjb但是当我执行下面的命令时,只生成了message.xsd。

bash-3.2$ xjc -d jaxb -b schemas/ schemas/*.xsd -verbose
解析模式...
编译模式...

[INFO] 生成代码
未知位置
org/openuri/ChangeOfferingStateType.java
org/openuri/ObjectFactory.java
org/openuri/package-info.java

为什么没有生成 typeDef.xsd?

这是我的 xsd 和 xjb 文件。

bash-3.2$ cat schemas/message.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:gsta="http://gsta.com/neva2/externalService" 
    targetNamespace="http://www.openuri.org/"
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified">
    <xs:import namespace="http://gsta.com/neva2/externalService" schemaLocation="typeDef.xsd" />
    <xs:complexType name="ChangeOfferingStateType">
        <xs:sequence>
            <xs:element name="workFlowNo" type="xs:string" minOccurs="0" />
            <xs:element name="externalNumber" type="gsta:ExternalNumberType" />
            <xs:choice>
                <xs:element name="offeringSpecId" type="gsta:SpecIdType" />
                <xs:element name="productSpecId" type="gsta:SpecIdType" />
            </xs:choice>
            <xs:element name="state" type="gsta:SetStateCode" />
            <xs:element name="openTime" type="xs:date" minOccurs="0" />
            <xs:element name="recentModifyReason" type="gsta:RecentModifyReasonType" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

bash-3.2$ cat schemas/typeDef.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:gsta="http://gsta.com/neva2/externalService" 
    targetNamespace="http://gsta.com/neva2/externalService"
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified">

    <xs:simpleType name="ExternalNumberType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="20"></xs:maxLength>
            <xs:minLength value="1"></xs:minLength>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="SpecIdType">
        <xs:restriction base="xs:long">
            <xs:minInclusive value="0"></xs:minInclusive>
            <xs:maxInclusive value="999999"></xs:maxInclusive>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="SetStateCode">
        <xs:restriction base="xs:int">
            <xs:enumeration value="0" />
            <xs:enumeration value="1" />
            <xs:enumeration value="2" />
            <xs:enumeration value="3" />
            <xs:enumeration value="4" />
            <xs:enumeration value="5" />
            <xs:enumeration value="7" />
            <xs:enumeration value="8" />
            <xs:enumeration value="11"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="RecentModifyReasonType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="64"></xs:maxLength>
            <xs:minLength value="1"></xs:minLength>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

bash-3.2$ cat schemas/schemas.xjb

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" jaxb:version="2.0">
    <jaxb:bindings schemaLocation="message.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="org.openuri"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="typeDef.xsd" node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.gsta.neva2.externalservice"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>
</jaxb:bindings>
4

0 回答 0