HiberObjects

Download

Forum

Vote for this plugin
at Eclipse Plugin Central

Generate XML Schema

Enable Schema Generation

An XML schema can be generated for all the classes in a package.

To enable this functionality, right-click on a package in the Project Explorer and select Generate XML Schema. This will generate an xsd file with the classes in the package when the project is saved.

The xsd file will be placed in the source directory for the package, and the name of the file will be the last element of the package name.

Generated Schema

An element and a complex type is generated for every class in the package:

<element name='customer' type='tns:Customer'/> <complexType name='Customer'/>

The complex type will have a sequence with elements for the variables. The multiplicity of the variable will determine the minOccurs and maxOccurs of the element.

If the variable is an aggregation , the element will have the type of the refered element:

<element name='currency' type='tns:Currency'/>
If the variable is another association , the element will be referenced by its id:
<element name='currency' type='string'/>
If the refered class has a natural id, the natural id is used instead of the id.

You change associations to aggregations and vice versa with the Aggregate in class diagrams and in the Project Explorer.

Configure XML Schema Generation

The xsd file is generated by a Groovy template xsd.template that is created in the project. This template can be modified to alter rules of the file generation. For example, a project may use a dedicated tag on classes to determine wheter they are part of the XML schema.

Read more about Groovy templates here.