문제

I have two schema(Progect,system) but all this schema have one class shared(Image), I have problem when I generation JAXB in java for each this schema I have one class for each this schema(image in progect and image in system),but I need one image for project schema and system schema. project schema:

         <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/ProjectDataBase"
            xmlns:tns="http://www.example.org/ProjectDataBase" elementFormDefault="qualified">

            <element name="Project">
                <complexType>
                    <sequence>
                        <element name="Layer" type="tns:Layer" minOccurs="0"
                            maxOccurs="unbounded">
                        </element>
                    </sequence>
                    <attribute name="name" type="string" />
                </complexType>
            </element>

    <complexType name="Layer">
            <sequence>
                <element name="LayerName" type="string" maxOccurs="1"
                    minOccurs="1">
                </element>
                <element name="Visible" type="boolean" maxOccurs="1"
                    minOccurs="1"></element>
                <element name="Image" type="tns:Image" minOccurs="0"
                    maxOccurs="unbounded">
                </element>
            </sequence>
            <attribute name="idLayer" type="int"></attribute>
        </complexType>

<complexType name="Image">
        <sequence>
            <element name="name" type="string" maxOccurs="1"
                minOccurs="1">
            </element>
            <element name="path" type="string" maxOccurs="1"
                minOccurs="1"/>
            </sequence>
</complexType>

System schemal:

<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/systemDataBase"
    xmlns:tns="http://www.example.org/systemDataBase" elementFormDefault="qualified">
<element name="SystemDataBase">
        <complexType>
            <sequence>
                <element name="Classification" type="tns:Classification"
                    minOccurs="0" maxOccurs="unbounded">
                </element>
            </sequence>
        </complexType>
    </element>

    <complexType name="Classification">
        <sequence>
            <element name="Image" type="tns:Image" maxOccurs="unbounded"
                minOccurs="0"></element>
        </sequence>
        <attribute name="id" type="int"></attribute>
    </complexType>

    <complexType name="Image">
        <sequence>
            <element name="name" type="string" maxOccurs="1" minOccurs="1">
            </element>
            <element name="path" type="string" maxOccurs="1" minOccurs="1">
            </element>
        </sequence>
    </complexType>
</schema>
도움이 되었습니까?

해결책

You define the complex type "Image" in one of the schemas (say 'System') and reference it from the other ('Project') by importing the defining schema ('System') into the client schema ('Project') and declaring the foreign namespace ('System') in the local schema element ( 'Project>schema'). During generation, you probably have to generate episode files in order to prevent model artifact duplication.

This article contains examples on how the resulting schemas need to look with respect to namespace imports. And the selected answer to this question contains good infos about episode files.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top