users@jaxb.java.net

Mixing schema-derived and own annotation defined types in a JaxbContext

From: David J. M. Karlsen <david_at_davidkarlsen.com>
Date: Thu, 26 Nov 2009 01:40:41 +0100

Hi!

I have classes which were generated by XJC from and XSD, as well as a
few homebrew classes/types, which were defined with annotations, like this:

package jaxbPoc.client;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


@XmlRootElement( name="someElementName", namespace="" )
@XmlAccessorType( XmlAccessType.FIELD )
@XmlType
public class SomeHomeBrewStructure
{
    @XmlElement( name="TheElementName" )
    private String someVar = "theElementValue";

}

The generated ones are in jaxbCode.generated

This works:
jc = JAXBContext.newInstance("jaxbPoc.generatedCode");

and this works:
jc = JAXBContext.newInstance(jaxbPoc.client.SomeHomeBrewStructure.class);

but this will not work:
JAXBContext.newInstance("jaxbPoc.generatedCode:jaxbPoc.client");

which is very un-handy.

Is there no way to define them both in the one context together?

-- 
--
David J. M. Karlsen - +47 90 68 22 43
http://www.davidkarlsen.com
http://mp3.davidkarlsen.com
Sent from my bog-standard SMTP client