構成によって 3 番目のクラスを共有する 2 つのトップレベル クラスがあります。例:
@XmlRootElement
@XmlType(namespace = "http://example.com/foo")
public class Foo {
public Shared shared;
}
@XmlRootElement
@XmlType(namespace = "http://example.com/bar")
public class Bar {
public Shared shared;
}
public class Shared {
public String string;
}
これらの各クラスは、異なるコンパイル ユニット (モジュール) の異なるパッケージに割り当てられます。各最上位クラスで schemagen を使用する場合、Shared クラスに最上位クラスと同じ名前空間を持たせたいと考えています。したがって、Foo の出力は次のようになります。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo" type="Foo"/>
<xs:complexType name="Foo">
<xs:sequence>
<xs:element name="shared" type="Shared" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Shared">
<xs:sequence>
<xs:element name="string" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
ただし、このようには機能しません。代わりに、Shared クラスにはデフォルトの名前空間があるため、2 つのスキーマ ファイルを取得します。1 つは Foo の名前空間用で、もう 1 つは Shared の名前空間用です。
Shared クラスを複製して共有しないという明らかな解決策なしに、これを修正する方法はありますか?