users@jaxb.java.net

Handling xs:any differently

From: Voß, Marko <Marko.Voss_at_fiz-Karlsruhe.de>
Date: Wed, 14 Mar 2012 11:25:36 +0000

Hello,

We have to support very huge XML files and because of that, we have implemented a Stream class, which handles such huge content. In our schemas such content is defined by xs:any. We are using a Listener on marshalling and unmarshalling to map such content into the Stream class. However JAXB code generation will still generate the any-property into the generated classes. So we have the content twice and - to make things worse - as DOM in our generated classes by default.

How to define in the binding that xs:any should not occur in the generated class? Could an adapter be helpful here and if so how could this adapter look like?

Also: Is there any possibility to put our Stream class into the generated class? Currently we define a class, which extends the generated class but JAXB is not changing the signatures of the getter and setter methods for those classes, where we are using the implClass-binding. Example:

<binding name="/xs:schema//xs:element[@name='foo']">
  <class implClass="my.impl.ExtendedFoo"/>
</binding>

Because of not changing the signatures to ExtendedFoo, the developer has to know, that there is an extended class and has to perform a cast in order to be able to work with the Stream class.

Example for the goal here:

public class Foo {
  @XmlAnyElement
  private Element any;
}

OR

public class Foo {
  @XmlAnyElement
  private List<Object> any;
}

Should look like:

public class Foo {
  @?
  private Stream any;
}

Best regards



-------------------------------------------------------

Fachinformationszentrum Karlsruhe, Gesellschaft für wissenschaftlich-technische Information mbH.
Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB 101892.
Geschäftsführerin: Sabine Brünger-Weilandt.
Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.