RelaxNG vs XML Schema RelaxNG vs XML Schema xml xml

RelaxNG vs XML Schema


The answers is a bit cliche: it depends.

On what, you might ask? On tools that your users will probably be using. And if you depend on your users, you might lose them if lack of good tools will drive them away. Since XML schema is, from my experience, very widely used, you might want to reconsider your decision on going forward with Relax NG. It is nicer and more easily understood than XML schema, but that doesn't mean it will make your project successful.

If you want to risk a bit, go ahead using Relax NG. And during every step of your development, try converting Relax NG to XML schema using a tool like Trang. Just in case you decide one day that Relax NG isn't worth it and you know you have a reasonable backup.


Writing slightly limited flavors of RELAX NG and then using Trang to automatically convert to XSD (which we never touch or look at) works very well for us.


I agree in that it depends on exactly what you need to use schemas for.Here is one more point: if all you need is validation, yes, just go with RelaxNG: it is good for that purpose.

But if you plan on doing data binding (like JAXB), or other kinds of code generation tasks, XML Schema is (unfortunately...) much better choice, since it is more designed towards object-to/from-xml approach than RelaxNG. And conversely not all that good for XML validation; especially considering added complexity. In fact one could call XML Schema a type system more than schema for XML.