私は、JAXBとintellij webservicesプラグインを使用してXSDからJavaファイルを作成しています。私は同じオブジェクトを定義する2つのXSDを持っていますが、 "XMLスキーマからJavaコードを生成"を使用してそれらを作成すると、オブジェクトは自分のパッケージで2回作成されます。私はすでにimport xsdでref属性を使ってみましたが、同じ結果が得られます。ここで同じカスタムオブジェクトを使用するために2つのXSDを作成する方法
は一例です。
これは
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.msp-gs.com/workflow"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wc="http://www.example.com/workflow"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
jaxb:version="1.0">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings enableJavaNamingConventions="true">
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="WC">
<xs:complexType>
<xs:sequence>
<xs:element name="Example"
type="wc:Restriction"
minOccurs="1"
maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Restriction">
<xs:attribute type="xs:string"
name="authorizationTreeId"/>
</xs:complexType>
</xs:schema>
最初のXSDですこれは、私はその制限が同じオブジェクトになりたい二XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.msp-gs.com/workflow"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:fd="http://www.example.com/workflow"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
jaxb:version="1.0">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings enableJavaNamingConventions="true">
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="FD">
<xs:complexType>
<xs:sequence>
<xs:element name="Example"
type="fd:Restriction"
minOccurs="1"
maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Restriction">
<xs:attribute type="xs:string"
name="authorizationTreeId"/>
</xs:complexType>
</xs:schema>
です。
ありがとうございます。
チェックアウト次の記事:http://blog.bdoughan.com/2011/12/reusing-generated-jaxb- classes.html –
ありがとうございます、私はすぐにそれに取り組み、それが動作しているかどうかをお知らせします。ありがとうございました。 – Rotem
@Rotem:どちらの場合でも1つのXSDファイルを使用するのを止めるのはなぜですか? 2つのXSDの問題は、モデルオブジェクトを2回生成する必要がありますが、同じ出力ディレクトリを使用することができるため、2回目の実行で1が優先されます。または、スキーマの生成(コピー/クリーン)後にいくつかのトリックを実行できます。 –