users@jaxb.java.net

Re: Re: Problem generating Java classes from XSD's

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 16 Apr 2010 17:03:19 +0200

Different packages is a must. You can control this with a separate bindings
file or the xjc command line option -p <pkg>

Then, after creating the JAXBContext from one of the packages, you can
unmarshal a request OR a response.

-W

On Fri, Apr 16, 2010 at 2:45 PM, Nussbaum Daniel, Bedag <
Daniel.Nussbaum_at_bedag.ch> wrote:

> Firstly, thnx for the quick response.
>
>
>
> GetEvnByNumber is used as XML document tag and is not contained into some
> other parents.
>
>
>
> I just made some progress when compiling those two XSD’s in two steps
> (request first, response second), even into to the same package.
>
> The bad thing about this way is, that the ObjectFactory-class is created
> either for GetEvnByNumberRequest or GetEvnByNumberResponse, depending on the
> order on which the generator-tasks are started.
>
>
>
> So, it’s still not 100% nice, but a little bit better.
>
>
>
> *Von:* Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
> *Gesendet:* Freitag, 16. April 2010 14:36
> *An:* users_at_jaxb.dev.java.net
> *Betreff:* Re: Problem generating Java classes from XSD's
>
>
>
> I guess that you know in your application when to unmarshal a request, and
> when a response. So, I think that you'll have to compile the two schemas
> separately, putting the result into different packages. This does not mean
> that they can't share things that are indeed identical. But from the schema
> snippets I can't really say.
>
> For instance: is getEvnByNumber an XML document tag or an element that's
> always contained in some parent?
> -W
>
> On Fri, Apr 16, 2010 at 2:14 PM, Nussbaum Daniel, Bedag <
> Daniel.Nussbaum_at_bedag.ch> wrote:
>
> Hi @all
>
> I have following two XSD's:
>
> 1) Request:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="
> http://www.bedag.ch/evn/mofis" targetNamespace="
> http://www.bedag.ch/evn/mofis" elementFormDefault="qualified"
> attributeFormDefault="unqualified">
> <xs:element name="getEvnByNumber">.
> .
> .
>
>
> 2) Response:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="
> http://www.bedag.ch/evn/mofis" targetNamespace="
> http://www.bedag.ch/evn/mofis" elementFormDefault="qualified"
> attributeFormDefault="unqualified">
> <xs:include schemaLocation="mofis-datentypen.xsd"/>
> <xs:element name="getEvnByNumber">
> .
> .
>
> The element "getEvnByNumber" is defined in two different XSD's, using the
> same Namespace, but having a different structure.
>
> By using binding-files I try to create two different classes
> (GetEvnByNumberRequest and GetEvnByNumberResponse) inside the same package.
>
> Using the maven-jaxb2-plugin I get following error message during code
> generation:
> [ERROR] Error while parsing schema(s).Location [
> file:...../mofis-ws1-getEvnByNumber-request.xsd{60,14}].
> org.xml.sax.SAXParseException: 'getEvnByNumber' is already defined
> at
> com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:176)
> at
> com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:170)
> at
> com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:173)
> at
> com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.checkDoubleDefError(NGCCRuntimeEx.java:145)
>
>
> Btw, editing the XSD's and defining two different namespaces (or a
> different element name) is not an option, because these files are defined on
> the customer side and they won't change them.
>
> Is there a way to solve this problem?
>
> Regards,
>
> Daniel
>
>
>