I have a project where I'm using RelaxNG (jing) to validate xml. I like the syntax for RelaxNG, but most of the tools that I have work with XML schema (actually, I don't think I have a tool that does, other than jing). Am I making a design and future support mistake by using RelaxNG when most of the support seems to be around XML schema? Should I just stick with RelaxNG and make everyone else learn it (kicking and screaming if necessary, j/k)? Should I switch to xml schema because of tool support?


Answer 1:

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.

Answer 2:

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.

Answer 3:

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.

Answer 4:

It all depends on who you have to convince. Your analysis is quite correct: RelaxNG is a better language for validation but it has far less tool support. So what tools do you actually need?

Answer 5:

schematron is also another reasonable option, with powerful xpath based validation...

however, my team generally builds everything in Relax/NG compact (for beautiful readability) and convert as necessary to XSD (e.g. for lib based validation), and ignore the XSD otherwise.


this just works.


码神部落- 版权声明 1、本主题所有言论和图片纯属会员个人意见,与码神部落立场无关。

最新回复 (0)
    • 码神部落
        立即登录 立即注册 GitHub登录