Export to GitHub

jdas - schemaToJavaClasses.wiki


DAS schema to Java Classes

Objective

Build Java classes from the DAS schema

Introduction

All DAS command responses are described in the 1.6 specification by RNG (RELAX NG) schemas. The tool "XJC" (JAXB Binding Compiler) can be used to convert XML Schema and other schema file types to class representations. RNG support is experimental in XCJ and not working very well with DAS schemas. As alternative "Trang" can be use to covert DAS RNG to XSD and XJC to generate Java classes.


Exercise

1.- Use Trang in the command line to covert RNG to XSD

2.- Use XJC in the command line to create the JAVA classes from XSD

  • Download XJC included in JAXB RI: http://jaxb.java.net/2.2.3/ wget http://jaxb.java.net/2.2.3/JAXB2_20101209.jar java -jar JAXB2_20101209.jar
  • Copy the generated "sequence.xsd" file into "jaxb-ri-20101209/bin/"
  • Create Java classes: chmod 744 xjc.sh ./xjc.sh sequence.xsd
  • AS a result you should get three DAS sequence Java classes. [training@trpcec61 bin]$ ./xjc.sh sequence.xsd parsing a schema... compiling a schema... generated/DASSEQUENCE.java generated/ObjectFactory.java generated/SEQUENCE.java


Continue the tutorial ...

  • Create Java objects from DAS XML using autogenerated Java classes


References

DAS schemas

RNG
* http://www.dasregistry.org/validation1.6/sources.rng
* http://www.dasregistry.org/validation1.6/features.rng
* http://www.dasregistry.org/validation1.6/sequence.rng
* http://www.dasregistry.org/validation1.6/types.rng
* http://www.dasregistry.org/validation1.6/entry_points.rng
XSD (created with Trang)
* http://www.dasregistry.org/validation1.6/xsd/sources.xsd
* http://www.dasregistry.org/validation1.6/xsd/features.xsd
* http://www.dasregistry.org/validation1.6/xsd/sequence.xsd
* http://www.dasregistry.org/validation1.6/xsd/types.xsd
* http://www.dasregistry.org/validation1.6/xsd/entry_points.xsd

JAXB

* http://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding
* http://www.oracle.com/technetwork/articles/javase/index-140168.html

XJC

* http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.6/jaxb/xjc.html

Trang

* http://www.thaiopensource.com/relaxng/trang.html