Motivation for using either Relax NG or W3C XML Schema

Discussion in 'XML' started by Pieter, Nov 26, 2003.

  1. Pieter

    Pieter Guest

    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.
    Pieter, Nov 26, 2003
    #1
    1. Advertising

  2. 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/
    Edwin Dankert, Nov 26, 2003
    #2
    1. Advertising

  3. Pieter

    Bob Foster Guest

    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" <> wrote in message
    news:...
    > 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.
    Bob Foster, Nov 26, 2003
    #3
  4. Pieter

    Bob Foster Guest

    "Edwin Dankert" <> wrote in message
    news:l12xb.2076$...
    > [*] 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
    Bob Foster, Nov 26, 2003
    #4
  5. Pieter

    Pieter Guest

    "Bob Foster" <> wrote in message news:<8A3xb.313833$Fm2.329327@attbi_s04>...
    > "Edwin Dankert" <> wrote in message
    > news:l12xb.2076$...
    > > [*] 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 ?
    Pieter, Nov 27, 2003
    #5
  6. > 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/
    Edwin Dankert, Nov 27, 2003
    #6
  7. Pieter

    Pieter Guest

    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.
    Pieter, Nov 28, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    601
    Steve Jorgensen
    Aug 2, 2005
  2. Steve Jorgensen
    Replies:
    0
    Views:
    557
    Steve Jorgensen
    Aug 9, 2005
  3. Replies:
    1
    Views:
    372
  4. The xmlBlueprint Team
    Replies:
    0
    Views:
    381
    The xmlBlueprint Team
    Sep 1, 2006
  5. McSwell
    Replies:
    2
    Views:
    719
    McSwell
    May 22, 2008
Loading...

Share This Page