users@jaxb.java.net

Re: JAXB multiple schemas with element reference

From: Alexander Broekhuis <a.broekhuis_at_gmail.com>
Date: Thu, 3 Mar 2011 13:41:33 +0100

Hi,

I've created an example. As can be seen, generating a model for B.xsd,
also generates a ObjectFactory for an element from A.xsd. The content
of this ObjectFactory is already in the generated files for A.xsd.

A.xsd:
---------
<?xml version="1.0" encoding="UTF-8"?>
<schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:a="http://www.example.org/A/"
        targetNamespace="http://www.example.org/A/">

    <element name="someType" type="a:SomeType"></element>

        <complexType name="SomeType">
                <sequence>
                        <element name="field" type="string"></element>
                </sequence>
                <attribute name="attr" type="string" />
        </complexType>

</schema>

--------
B.xsd
--------
<?xml version="1.0" encoding="UTF-8"?>
<schema elementFormDefault="qualified"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:b="http://www.example.org/B/"
    xmlns:a="http://www.example.org/A/"
    targetNamespace="http://www.example.org/B/">

    <import namespace="http://www.example.org/A/" />

    <complexType name="SomeTypeGroup">
            <sequence>
                    <element ref="a:someType" minOccurs="1" maxOccurs="unbounded" />
            </sequence>
    </complexType>


    <element name="root" type="b:RootType"></element>
    <complexType name="RootType">
            <sequence>
                    <element name="someTypes" type="b:SomeTypeGroup" />
            </sequence>
    </complexType>
</schema>

---------
catalog.xml
---------
<?xml version="1.0" encoding="UTF-8"?>
<catalog
  xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

  <public publicId="http://www.example.org/A/"
    uri="A.xsd"/>

</catalog>

--------
Shell commands
--------
mkdir srcgen
mkdir srcgen/a
mkdir srcgen/b
xjc -d srcgen/a -episode a.episode A.xsd
xjc -d srcgen/b B.xsd -b a.episode -catalog catalog.xml -extension
-classpath srcgen/a

--------


On 2 March 2011 21:08, Alexander Broekhuis <a.broekhuis_at_gmail.com> wrote:
> Hi,
>
> Thx for your reply.
>
> On 2 March 2011 18:32, Wolfgang Laun <wolfgang.laun_at_gmail.com> wrote:
>> There is no connection of the type/class names EventType and TypeType to the
>> schema snippets. Please clarify this. A complete working example reproducing
>> the effect would help.
>
> I "edited" my working example to something simpler, and forgot to
> rename that one EventType. I will create a small working example
> tomorrow.
>
>>
>> But is it really necessary to use an episode file? Ususally, compiling all
>> in one run is the way to go.
>
> The project I need this for is split into multiple parts. One scheme
> belongs to a basic module, and can be extended by other modules. So
> yes, unfortunately in this case it is needed.
>
>
> --
> Met vriendelijke groet,
>
> Alexander Broekhuis
>



-- 
Met vriendelijke groet,
Alexander Broekhuis