August 19, 2012 by huionn
Nuxeo platform such as document schema is very flexible. However, like loose typing language, the flexibility has a drawback. The compiler cannot detect the typos in properties names. Changing the a xsd file without changing all related Java classes will cause unforeseeable runtime exception. In addition, for client-server application like my legal case management system, this is more error-prone as the client application is in another project. My client application uses JAX-RS with JSON and CMIS to communicate with server.
Because of this drawback, I decide to generate a interface for each xsd file that can be shared by client and server (as jar). Unfortunately, I am unable to find any existing tool in Nuxeo that can do generate interfaces from xsd files.
So, I tried other project that can generate Java class from xml schema (xsd), such as JAXB and XMLBean. Both generate Java class for binding, but the generated classes are too complicated for my use case.
Finally I decide to code my own naive XSD parser with XSOM. It is definitely not robust and requires tweaking from time to time. But at the moment, it serves my requirement well.