Skip to main content

Many classes for the same general schema

1 reply [Last post]
michaljp
Offline
Joined: 2012-05-29
Points: 0

Hi,

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>
  <Field name="another field">
   (...)
</Entity>

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
Michal

Reply viewing options

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

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.

Whippy

Link to post:
http://www.java.net/forum/topic/glassfish/metro-and-jaxb/xml-schema-11-jaxb