users@jaxb.java.net

Re: JAXB multiple schemas with element reference

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 8 Mar 2011 08:57:30 +0100

On 8 March 2011 08:22, Alexander Broekhuis <a.broekhuis_at_gmail.com> wrote:

> Hi all,
>
> Is there someone who might know a fix to this problem? Is this a bug,
> or am I doing something wrong?
>

I'm not sure either way.

In exactly the same situation, I have simply called xjc repeatedly, always
including the common part. Either tolerate that the classes generated from
the common part are overwritten each time, or discard them. (For the latter,
consider generating into a temporary directory and running copy, compare or
both.) We were doing this in a (complex) production environment, and we
never had any problems.

-W



>
> Thanks in advance!
>
> On 3 March 2011 13:41, Alexander Broekhuis <a.broekhuis_at_gmail.com> wrote:
> > 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
> >
>
>
>
> --
> Met vriendelijke groet,
>
> Alexander Broekhuis
>