What Java xml framework can handle code generation with restrictions / extensions in schemas?

There is a set of XSD files with the following types described in them:

A is a complex type with various elements. B restricts A, retaining only some of its elements; C extends B by adding some elements.

So, this means that the Java class generated by the tool using type C from the XML schema should include only those elements from A that are stored by B, and new ones added by C

To make things even more difficult, B actually modifies the minOccurs attribute of some elements.

Are there any frameworks that can handle this? I tried EMF and the restrictions did not even reflect on the code.

+5
source share
3 answers

When using complex XSD, I had better results with XMLBeans .

  • It has full XML Schema support.
  • This was the only structure that could generate the correct code for the complex XML schemas that I had to use.

Another useful feature:

When unpacking an XML instance, the full XML file is saved and available to the developer. This is very important because of the subset of XML that is not easily represented in java. For example, the order of items or comments may be required in a particular application.

+2
source

antoher ( ): Axis2 DataBinding Framework (ADB) .

. . y , , ( ) StAX /.

Cons : the generated code may lead to too much detail, the exceptions to verify are too little explanatory, they should be "simple" (therefore, with complex type extensions or restrictions you may find some problems), and it includes some dependencies with the ADB library ( i.e., the generated beans implements the interface org.apache.axis2.databinding.ADBBean).

+2
source

All Articles