1

Is there an XML serialization framework for Java that does not use reflection, but instead generates static serialization code (Java source) from XSD ?

3
  • 2
    I'm curious to know what the reason is if you don't mind sharing? Commented Jan 23, 2012 at 9:52
  • @laixer, sometimes reflection doesn't work, either by design or point in time limitations of the environment where one needs to run its code. Please take a look at this link, read all the way through, and you might get an idea. code.google.com/p/googleappengine/issues/detail?id=1267 Commented Jan 24, 2012 at 0:35
  • @laixer Another use case might be Java ME, where Class.forName and Object.getClass() are all the reflection you've got. Commented Jan 24, 2012 at 10:48

1 Answer 1

1

I've never seen anything that does exactly what you are asking for: generating serialization code from XSD. However, if you're not stuck with an existing XSD schema, Modello may satisfy your requirements.

Modello is used by Maven for parsing pom.xml and settings.xml files. It reads a .mdo file (like this description of the Maven project model), and can generate a Java object model; an XML Schema (XSD) file; and serialisation/de-serialisation code. The serialisation/deserialisation code can use one of a number of XML parser APIs (e.g. JDOM, StAX, etc.). The XML parser API used by Maven itself is xpp3.

Modello can also generate code to convert one version of the model to another. It can generate HTML documentation about your XML format.

If you have an existing XSD, it might be too much work to use modello. But, if you're creating your own XML format, it could be worth starting with modello and generating the XSD.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.