Skip to main content

Many classes for the same general schema

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2012-05-29


I'm going to work with a web service that has the same schema for all types. Each type looks like this:

<Entity type="Type name">
  <Field name="Name of the field">
    <Value>Value of the field as string</Value>
  <Field name="another field">

There are various types that I would like to use in java as regular object, e.g.

class A {
  Integer number;
  String string;

How could I use JAXB to create specific object from XML depending on Entity type attribute and create XML from specific objects?

Best regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-05-31

Hi Michal

I'm not 100% on your case here however I have a feeling your looking for a similar thing to me which is JAXBsupport for XML Schemas with conditional properties. This exists in XML Schema 1.1 however whether JAXB supports at any version (or if planned) this I don't know. I created a question for this recently and it may be worth following this thread as well in case any responses occur.


Link to post: