質問

私は現在、JaxB(IBM Build 2.1.3)で同じパッケージにスキーマファイルをコンパイルしようとしています。それぞれが独自にコンパイルされますが、それらを一緒にコンパイルしようとすると、含まれるために競合の命名要素が得られます。私の質問は次のとおりです。命名衝突に解像度を外部バインドして指定する方法はありますか?

ファイルの例が続きます。例では、問題の要素は「共通」と呼ばれ、INCAとINCBの両方で定義されています。

inca.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://www.example.org/"
    xmlns:tns="http://www.example.org/" elementFormDefault="qualified">
    <complexType name="TypeA">
        <sequence>
            <element name="ElementA" type="string"></element>
        </sequence>
    </complexType>
    <!-- Conflicting element -->
    <element name="Common" type="tns:TypeA"></element>
</schema>

incb.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://www.example.org/"
    xmlns:tns="http://www.example.org/" elementFormDefault="qualified">
    <complexType name="TypeB">
        <sequence>
            <element name="ElementB" type="int"></element>
        </sequence>
    </complexType>
    <!-- Conflicting element -->
    <element name="Common" type="tns:TypeB"></element>
</schema>

a.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.example.org/"
    elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://www.example.org/">
    <include schemaLocation="incA.xsd"></include>
    <complexType name="A">
        <sequence>
            <element ref="tns:Common"></element>
        </sequence>
    </complexType>
</schema>

b.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.example.org/"
    elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://www.example.org/">
    <include schemaLocation="incB.xsd"></include>
    <complexType name="B">
        <sequence>
            <element ref="tns:Common"></element>
        </sequence>
    </complexType>
</schema>

コンパイラエラーは、両方がXJBの1つの喚起からコンパイルされている場合です。

[ERROR] 'Common' is already defined
 line 9 of file:/C:/temp/incB.xsd
[ERROR] (related to above error) the first definition appears here
 line 9 of file:/C:/temp/incA.xsd

(参照のために、これはOAGIS8 SP3パッケージのコンパイルに関する問題を解決するための一般化です)

役に立ちましたか?

解決

私は、名前空間の衝突のために、これらすべてのフラグメントを一度にコンパイルしようとすることは不可能であるとさらに調査しました。私が決めた回避策は、各セットのセットのセットを独自のパッケージにコンパイルし、それを外傷しようとする前に、着信XMLでヒューリスティックテストを実行することでした。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top