We convert our relaxngs to xsd using trang and then use xjc to create java objects.
locate trang, you will likely have this already if you have spring or eclipse
run trang like this:
java -jar /Users/jw12/trang-20091111/trang.jar sources.rng sources.xsd
find xjc on your system, if you use java you are likely to have xjc already: locate xjc
the one I’m using came with netbeans /Applications/NetBeans/glassfish-3.0.1/glassfish/bin/xjc
use xjc on the xsd file just generated specifying the package with -p:
sh /Applications/NetBeans/glassfish-3.0.1/glassfish/bin/xjc sources.xsd -p org.biodas.jdas.schema.sources
Note that because relaxng is much more descriptive than xsd conflicts and approximations may occur. We removed interleave elements from the rng schemas for generating our java classes so that we didn’t have to test for different types when using the generated java classes. this is because interleave means the classes don’t know if the list of child elements is going to contain a specific type of object as the objects can occur in any order – thus generating a for example getMaintanerOrCoodinate() method. We want seperat getMaintainer() and getCoordinate() methods and removing interleave does that. In the DAS specification it doesn’t specify whether the child elements should be returned in order, however the official W3C xml core data model characterizes element children as:
An ordered list of child information items, in document order. This list contains element….
WE also believe the vast majority of xml writers will produce the elements in order…