Question


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?

Thanks.


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.



来源:https://stackoverflow.com/questions/4994875/relaxng-vs-xml-schema


码神部落- 版权声明 1、本主题所有言论和图片纯属会员个人意见,与码神部落立场无关。
2、本站所有主题由该帖子作者发表,该帖子作者爷万人跪拜码神部落享有帖子相关版权。
3、码神部落管理员和版主有权不事先通知发贴者而删除本文。
4、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者爷万人跪拜码神部落的同意。
5、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任。
6、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责。
7、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意。

最新回复 (0)
    • 码神部落
      2
        立即登录 立即注册 GitHub登录
返回
发新帖
作者最近主题: