By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Motivation for using either Relax NG or W3C XML Schema

P: n/a
I've read a lot of posts on "why relax ng is so very good" and on "why
w3c xml schema should be the only schema language". I'm, however,
still not clear on why I should prefer one over the other.

I've made a small list of some good and bad points of both. These
points don't really go into the grammar aspects of these languages,
but are more about secondary aspects. The grammar aspects are
different, but both are suitable for validating an XML document. Both
schema languages have good and bad points in them. Any comments on the
languages themselves will therefore (at least in my opinion) not help
to make a choice. However, points like support by tools and how widely
spread the use is (are they both widely used? I don't know this and
haven't been able to find much on it), do make a difference.
W3C XMl Schema
+ versatile: not only useful for validation, but also for
classification of elements and attributes, identifying their
semantics. It can send documentation and application information to
the processor.
+ it employs oop aspects
+ w3c recommendation
+ tools support
- complex
- documentation is hard to understand

Relax NG
+ especially the compact syntax is very clear and intuitive
+ was designed to be able to incorporate elements of other schema
languages (e.g. the data types of w3c schema), which makes it easy to
adapt the language to your needs
+ tool support is slowly expanding
+ draft standard of the Document Description and Processing Languages
subcommittee of the ISO/IEC Joint Technical Committee
- only suitable for validation
- documentation and application information are not supported
- xslt 2.0 is designed to use schemas. From the working draft it seems
that, although every schema language should be supported, w3c xml
schema will be more supported than other schema languages

I don't believe this list is exhaustive or even entirely correct.
However, I hope people on this list can help me make a choice. I
suppose it therefore is useful to explain what the XML Schema will be
used for.
I'm working on a program that generates an XML document which contains
a Java-like programming language. This document should be validated
and then, with the help of XSLT, translated into XMI, which can then,
for instance, be imported into rational rose in order to create class
diagrams.
I suppose that for the validation part both Relax NG and WXS could be
used. However, for the transformation part, they might not be equally
suited. Maybe this is not true, but I just do not know and hope people
on this list can help me.
Some demands for the choice of the schema are that is should be easy
to read and understand, easy to change and easy to maintain.
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I personally do not prefer RelaxNG over XML Schema nor the other way around.
To me they are both Schema languages that can sort of handle the same
things.

However here are some remarks ...
[*] RelaxNG has a huge XML-Guru support, this should not be
confused with usage.

Here is an indication, we currently advertise on Google and find
that for every hundred searches for 'XML Schema' there is only
one search for RelaxNG.

RelaxNG seems to be (for the moment) the Linux of the XML Schema
languages.
[*] XML Schema/RelaxNG Compact Syntax

What will be next 'XML Compact Syntax'?
[*] 'W3C XML Schema' Validators

There is a 'little' bit of inconsistency in XML Schema Validators
at the moment, however using good coding techniques and a
combination of Xerces and XSV to validate your XML Schema might do
the trick.
[*] Data vs Document ???

One trend seems to be that W3C XML Schema is being used more for data
based applications and RelaxNG more for document based applications.
[*] Conversion

It seems to be possible at the moment to convert (without loss?) from
RelaxNG to XML Schema however not the other way around.

Good luck,
Edwin Dankert
Cladonia Ltd.
http://www.cladonia.com/
Jul 20 '05 #2

P: n/a
I wrote a short comparison a few weeks (or so) back. If there's an archive
for this list you should be able to find it.

Off the top of my head, the Pro list for RELAX NG should contain:

- Can describe ambiguous grammars.
- Can describe content dependencies (e.g., attributes/elements that are
valid based on value of an attribute).
- Grammars are closed under union.
- Trang (the fastest way to write XML Schema is to write it in RNG compact
syntax and convert it).

The Pro list for XML Schema should contain:

- Can describe identity constraints (key, keyRef).
- Great book by Priscilla Walmsley.

(The "closed under union" attribute is a bit obscure. Maybe an example will
help explain it. Using RELAX NG, I was able to combine James Clark's schema
for XSLT 1.0 with my own schema for XSLT 2.0, using yet a third schema that
included them both as choices, and validate either kind of document with the
union of the schemas, based on the version number specified on the root
element.)

Bob

"Pieter" <pi****@west.nl> wrote in message
news:cf**************************@posting.google.c om...
I've read a lot of posts on "why relax ng is so very good" and on "why
w3c xml schema should be the only schema language". I'm, however,
still not clear on why I should prefer one over the other.

I've made a small list of some good and bad points of both. These
points don't really go into the grammar aspects of these languages,
but are more about secondary aspects. The grammar aspects are
different, but both are suitable for validating an XML document. Both
schema languages have good and bad points in them. Any comments on the
languages themselves will therefore (at least in my opinion) not help
to make a choice. However, points like support by tools and how widely
spread the use is (are they both widely used? I don't know this and
haven't been able to find much on it), do make a difference.
W3C XMl Schema
+ versatile: not only useful for validation, but also for
classification of elements and attributes, identifying their
semantics. It can send documentation and application information to
the processor.
+ it employs oop aspects
+ w3c recommendation
+ tools support
- complex
- documentation is hard to understand

Relax NG
+ especially the compact syntax is very clear and intuitive
+ was designed to be able to incorporate elements of other schema
languages (e.g. the data types of w3c schema), which makes it easy to
adapt the language to your needs
+ tool support is slowly expanding
+ draft standard of the Document Description and Processing Languages
subcommittee of the ISO/IEC Joint Technical Committee
- only suitable for validation
- documentation and application information are not supported
- xslt 2.0 is designed to use schemas. From the working draft it seems
that, although every schema language should be supported, w3c xml
schema will be more supported than other schema languages

I don't believe this list is exhaustive or even entirely correct.
However, I hope people on this list can help me make a choice. I
suppose it therefore is useful to explain what the XML Schema will be
used for.
I'm working on a program that generates an XML document which contains
a Java-like programming language. This document should be validated
and then, with the help of XSLT, translated into XMI, which can then,
for instance, be imported into rational rose in order to create class
diagrams.
I suppose that for the validation part both Relax NG and WXS could be
used. However, for the transformation part, they might not be equally
suited. Maybe this is not true, but I just do not know and hope people
on this list can help me.
Some demands for the choice of the schema are that is should be easy
to read and understand, easy to change and easy to maintain.

Jul 20 '05 #3

P: n/a
"Edwin Dankert" <ed******@cladonia.com> wrote in message
news:l1******************@news.indigo.ie...
[*] Conversion

It seems to be possible at the moment to convert (without loss?) from
RelaxNG to XML Schema however not the other way around.


Not without loss, because XML Schema can't describe all the grammars that
RELAX NG can. Much of the time, however, Trang will convert RELAX NG to the
nearest correct XML Schema, i.e., to one that will accept every document
that the original will accept, even if it accepts some documents the
original won't.

Bob Foster
Jul 20 '05 #4

P: n/a
"Bob Foster" <bo********@comcast.net> wrote in message news:<8A3xb.313833$Fm2.329327@attbi_s04>...
"Edwin Dankert" <ed******@cladonia.com> wrote in message
news:l1******************@news.indigo.ie...
[*] Conversion

It seems to be possible at the moment to convert (without loss?) from
RelaxNG to XML Schema however not the other way around.


Not without loss, because XML Schema can't describe all the grammars that
RELAX NG can. Much of the time, however, Trang will convert RELAX NG to the
nearest correct XML Schema, i.e., to one that will accept every document
that the original will accept, even if it accepts some documents the
original won't.

Bob Foster

That's true. Lossless conversion is not always possible.

Thanks for the points you have given me so far. They are very useful
to me. However, for the validation part I'm convinced both are equally
usefull.
But, more important, can they both be used for the transformation part
? That is, does XSLT 2.0 handles both schema languages equally well.
Related to this is off course if this is important at all. Is the
support for schemas in XSLT 2.0 in any way useful ?
Jul 20 '05 #5

P: n/a
> But, more important, can they both be used for the transformation part
? That is, does XSLT 2.0 handles both schema languages equally well.
Related to this is off course if this is important at all. Is the
support for schemas in XSLT 2.0 in any way useful ?


I am not a XSLT expert (not even a beginner) but I thought that XSLT 2.0 has
only support for 'XML Schema Datatypes'? (please correct me if I'm wrong)

The 'XML Schema Datatypes' (part 2) should not be confused with the 'XML
Schema Structures' (part 1). There seems to be a consensus at the moment
(even in the RelaxNG world) that the 'XML Schema Datatypes' specification is
not that bad.

You can even use 'XML Schema Datatypes' in RelaxNG and some other languages
(WSDL, SOAP, RDF), I don't see this as a reason to discard either RelaxNG or
XML Schema, however it might be a good idea (if there is a need to use
types) to define your data using 'XML Schema Datatypes'.

Regards,
Edwin Dankert
Cladonia Ltd.
http://www.cladonia.com/
Jul 20 '05 #6

P: n/a
For future reference I want to conclude this discussion with my choice
and the reasons I have for it.
First I'm going for W3C XML Schema (WXS). Well, now that is out there
I will state my reasons.

- with the coming of XSLT 2.0 (which support schemas and not just data
types !) I think WXS has a juge advantage. Even though XSLT 2 should
support other languages too, in a short email discussion Michael Kay
(the author of the document on XSLT 2 on w3.org) stated that XSLT 2
has only been tested with WXS and he did not know if other languages
will be tested too. Even though I do not know if I will need to
combine XSLT 2 and XML Schema (XSLT 2 can function without schemas), I
do not want to restrict myself.
- user and vendor support is much larger for WXS than for Relax.
Because other people will be using what I'm making, it is most likely
that they know WXS. It will therefore probably be easier for them to
understand and maintain a WXS schema than a Relax schema.
- I have no need for the better support of Relax for specifying the
root-element of a document, because the XML document will be
auto-generated, which gives me, as the programmer of both the schema
as the program that will generate the XML the power to make sure this
will never go wrong.
- I have no need for the better handling of attributes of Relax,
because attributes will not play an important role in my XML document.
- I need the constraints mechanism (i.e. minOccurs and maxOccurs) of
WXS. Relax has nothing like that.

These are the most important points for me to choose WXS.
I hope it helps others to make a well-motivated choice.
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.