Loading ...
Sorry, an error occurred while loading the content.

RNG or XML Schema, which one to choose?

Expand Messages
  • r.khondoker
    Hi all, I have a question regarding pros and cons of RNG and XML schema. I have found the comparison in the following website http://www.xml.com/lpt/a/884 I
    Message 1 of 7 , Aug 22, 2011
    • 0 Attachment
      Hi all,
      I have a question regarding pros and cons of RNG and XML schema. I have found the comparison in the following website

      http://www.xml.com/lpt/a/884

      I found that

      1. Rules: Both XML schema (XML-S) and RNG dont support rules.
      2. Post Schema Validation Infoset (PSVI): XML-S supports, RNG dont
      3. Structures: Both supports
      4. Data types: XML-S supports, RNG supports partially
      5. Integrity: XML-S supports, RNG dont

      So far as I understand, the pros and cons of RNG and XML-S are as follows. Please correct me if I am wrong


      PROS

      1. RNG is easy to understand and use. XML-S is comparatively difficult
      2. Using RNG, you can define grammar. XML-S does not offer this

      CONS

      1. RNG does not provide the possibility to define an attribute or an element as mandatory or required. Using XML-S, you can define that explicitly using use="required"
      2. Using RNG, you cannot define the boundary (min and max). Using XML-S, you can define that explicitly using minOccurs and maxOccurs
      3. Using RNG, if you dont define optional explicitly, the attribute or element is required.

      I found the pros and cons in the wiki as well

      http://en.wikipedia.org/wiki/XML_Schema_Language_comparison


      Could you please let me know if there is any literature which describes the pros and cons of these two schemas with examples.

      Thanking you,
      Ratul
    • G. Ken Holman
      ... RNG has richer structure options than XSD, two examples of which are co-occurrence constraints and interleave. In fact RNG is so much more expressive than
      Message 2 of 7 , Nov 4, 2011
      • 0 Attachment
        At 2011-08-22 16:09 +0000, r.khondoker wrote:
        >Hi all,
        >I have a question regarding pros and cons of RNG and XML schema. I
        >have found the comparison in the following website
        >
        >http://www.xml.com/lpt/a/884
        >
        >I found that
        >
        >1. Rules: Both XML schema (XML-S) and RNG dont support rules.
        >2. Post Schema Validation Infoset (PSVI): XML-S supports, RNG dont
        >3. Structures: Both supports

        RNG has richer structure options than XSD, two examples of which are
        co-occurrence constraints and interleave.

        In fact RNG is so much more expressive than XSD that one cannot write
        a complete XSD for XHTML but one can write an RNG for XHTML.

        >4. Data types: XML-S supports, RNG supports partially

        RNG supports far more data types than XSD, including *all* of XSD,
        because of its separate data type library facility. One can include
        the XSD data type library when writing RNG ... or one can include
        anyone else's data type library (I stick with the XSD data types myself).

        >5. Integrity: XML-S supports, RNG dont

        Many view such constraints as layered on top, addressed by
        specifications such as Schematron. It is an example of a value
        constraint. Different users might have different perspectives of
        constraints on values, thus layering on different expressions of
        those constraints.

        At the least you can engage ID/IDREF processing assuming DTD constraints.

        >So far as I understand, the pros and cons of RNG and XML-S are as
        >follows. Please correct me if I am wrong
        >
        >
        >PROS
        >
        >1. RNG is easy to understand and use. XML-S is comparatively difficult
        >2. Using RNG, you can define grammar. XML-S does not offer this
        >
        >CONS
        >
        >1. RNG does not provide the possibility to define an attribute or an
        >element as mandatory or required. Using XML-S, you can define that
        >explicitly using use="required"

        False.

        Using RNC for brevity, this is a declaration of an optional attribute:

        element x { attribute a { text }?, text }

        ... this is a declaration of a mandatory attribute:

        element x { attribute a { text }, text }

        ... while this is a co-occurrence constraint that attribute one= can
        only be specified if attribute two= is specified, otherwise it is optional:

        element x
        {
        (
        attribute two { text },
        attribute one { text }?
        ),
        text
        }

        ... and you cannot say that in XSD.

        >2. Using RNG, you cannot define the boundary (min and max). Using
        >XML-S, you can define that explicitly using minOccurs and maxOccurs

        False. It may not be concise, but it is possible in RNG. In RNC I can say:

        x = element x { text }
        y = element y { x, x, x?, x?, x? } # minOccurs=2 maxOccurs=5

        This is not onerous.

        Plus you can use interleave to say that "y is a sequence of between
        two and five (inclusive) x's and a z, without regard for the position
        of the z" anywhere within the x's:

        x = element x { text }
        z = element z { text }
        y = element y { z & ( x, x, x?, x?, x? ) } # x: minOccurs=2 maxOccurs=5

        ... and you cannot say that in XSD.

        >3. Using RNG, if you dont define optional explicitly, the attribute
        >or element is required.

        Sure ... but that isn't a burden.

        All in all I find RNC/RNG far more expressive and able to match my
        document constraints.

        I hope the above helps. I choose RNC/RNG long before I ever choose
        XSD for document modeling.

        . . . . . . . . . . . Ken

        --
        Contact us for world-wide XML consulting and instructor-led training
        Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/r/
        G. Ken Holman mailto:gkholman@...
        Google+ profile: https://plus.google.com/116832879756988317389/about
        Legal business disclaimers: http://www.CraneSoftwrights.com/legal
      • Syd Bauman
        There are some interesting issues and an occasional serious confusion, here, but I have to type pretty quickly ... 1. Correct, neither XSD nor RNG support
        Message 3 of 7 , Nov 4, 2011
        • 0 Attachment
          There are some interesting issues and an occasional serious
          confusion, here, but I have to type pretty quickly ...

          1. Correct, neither XSD nor RNG support rules; however, if you embed
          ISO Schematron rules in your RNG file, some processors will handle
          both simultaneously (e.g., oXygen). I don't know if this works for
          XSD or not.

          2. PSVI: Correct, XSD has a PSVI, RNG does not.

          3. I don't know what "structures" means, but you're probably right.

          4. RNG supports data types much more flexibly than XSD. I'd say XSD
          has partial support, in that you're stuck with one datatype
          system.

          5. I don't know what "integrity" means, here.


          PRO-1. Yes, RNG is *far* easier, and that makes it lightweight, as
          well. XSD is a behemoth.

          PRO-2. In the technical sense that RNG uses a pattern this may be
          true, but in both languages you are defining a document
          grammar writ large.

          CON-1. This is blatantly false (see CON-3). In RNG, by default every
          element or attribute referenced is required. If you want it to
          be optional you have to say so.

          CON-2. This is true, XSD gives you a little more flexibility where
          cardinality is concerned. I have rarely found this to be a
          problem with RNG, though.

          CON-3. While this is true, it's not a con, it's a pro!


          To put it simply, unless your application requires features that XSD
          supports and RNG does not (like PSVI), use RELAX NG. Period. And even
          if your application does require such a feature, try really hard to
          figure out how to change things so that you can use RELAX NG. It's
          simply a better language.


          Not enough time for examples, I'm afraid ...

          > I have a question regarding pros and cons of RNG and XML schema. I
          > have found the comparison in the following website
          >
          > http://www.xml.com/lpt/a/884
          >
          > I found that
          >
          > 1. Rules: Both XML schema (XML-S) and RNG dont support rules.
          > 2. Post Schema Validation Infoset (PSVI): XML-S supports, RNG dont
          > 3. Structures: Both supports
          > 4. Data types: XML-S supports, RNG supports partially
          > 5. Integrity: XML-S supports, RNG dont
          >
          > So far as I understand, the pros and cons of RNG and XML-S are as
          > follows. Please correct me if I am wrong
          >
          >
          > PROS
          >
          > 1. RNG is easy to understand and use. XML-S is comparatively difficult
          > 2. Using RNG, you can define grammar. XML-S does not offer this
          >
          > CONS
          >
          > 1. RNG does not provide the possibility to define an attribute or an element as mandatory or required. Using XML-S, you can define that explicitly using use="required"
          > 2. Using RNG, you cannot define the boundary (min and max). Using XML-S, you can define that explicitly using minOccurs and maxOccurs
          > 3. Using RNG, if you dont define optional explicitly, the attribute or element is required.
          >
          > I found the pros and cons in the wiki as well
          >
          > http://en.wikipedia.org/wiki/XML_Schema_Language_comparison
          >
          > Could you please let me know if there is any literature which
          > describes the pros and cons of these two schemas with examples.
        • Norm Birkett
          I m new to all of these languages, but in my brief explorations of how I can validate a particular family of fairly complex XML languages, I have found that:
          Message 4 of 7 , Nov 4, 2011
          • 0 Attachment
            I'm new to all of these languages, but in my brief explorations
            of how I can validate a particular family of fairly complex XML
            languages, I have found that:

            (a) I very frequently have the experience where I can immediately
            see how to write a validation constraint in RNG/RNC, while I have
            to think and play around a while before I see how to express it
            in XML-S.

            (b) I regularly have the experience that is like (a) except that
            I never do figure out how to express the constraint in XML-S.
            It seems that everything I try is either too restrictive or too
            Unrestrictive, and I never do succeed in getting it "just right."

            I have also found that whichever of these languages I use, I
            also need to use Schematron to represent further validations that
            are more easily coded as rules, and as far as I can tell,
            Schematron is a bit easier to mesh with RNG/RNC than with XML-S.
            (However, I would not say that is a decisive consideration.)

            Based on the many occurrences of (a) and (b) that I've
            encountered during a pilot project, I would have to second what
            Syd wrote:

            " To put it simply, unless your application requires features
            that XSD supports and RNG does not (like PSVI), use RELAX NG.
            Period. And even if your application does require such a feature,
            try really hard to figure out how to change things so that you
            can use RELAX NG. It's simply a better language."

            I hope my little bit of experience with these things will be
            helpful to you.

            Norm Birkett


            > -----Original Message-----
            > From: rng-users@yahoogroups.com [mailto:rng-users@yahoogroups.com] On
            > Behalf Of r.khondoker
            > Sent: Monday, August 22, 2011 12:10 PM
            > To: rng-users@yahoogroups.com
            > Subject: [rng-users] RNG or XML Schema, which one to choose?
            >
            > Hi all,
            > I have a question regarding pros and cons of RNG and XML schema. I
            have
            > found the comparison in the following website
            >
            > http://www.xml.com/lpt/a/884
            >
            > I found that
            >
            > 1. Rules: Both XML schema (XML-S) and RNG dont support rules.
            > 2. Post Schema Validation Infoset (PSVI): XML-S supports, RNG dont
            > 3. Structures: Both supports
            > 4. Data types: XML-S supports, RNG supports partially
            > 5. Integrity: XML-S supports, RNG dont
            >
            > So far as I understand, the pros and cons of RNG and XML-S are as
            > follows. Please correct me if I am wrong
            >
            >
            > PROS
            >
            > 1. RNG is easy to understand and use. XML-S is comparatively difficult
            > 2. Using RNG, you can define grammar. XML-S does not offer this
            >
            > CONS
            >
            > 1. RNG does not provide the possibility to define an attribute or an
            > element as mandatory or required. Using XML-S, you can define that
            > explicitly using use="required"
            > 2. Using RNG, you cannot define the boundary (min and max). Using XML-
            > S, you can define that explicitly using minOccurs and maxOccurs
            > 3. Using RNG, if you dont define optional explicitly, the attribute or
            > element is required.
            >
            > I found the pros and cons in the wiki as well
            >
            > http://en.wikipedia.org/wiki/XML_Schema_Language_comparison
            >
            >
            > Could you please let me know if there is any literature which
            describes
            > the pros and cons of these two schemas with examples.
            >
            > Thanking you,
            > Ratul
            >
            >
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
          • John Madden
            Another area where RNG excels, compared with XSD, is in support for modular and extensible schema development. XSD has complex namespace-handling that (to me)
            Message 5 of 7 , Nov 4, 2011
            • 0 Attachment
              Another area where RNG excels, compared with XSD, is in support for modular and extensible schema development.

              XSD has complex namespace-handling that (to me) is full of gotchas, and makes layered imports very hard to create and maintain.
              RNG has a simpler and more flexible approach to namespaces that rarely cause problems, even when there are multiple layers of imports (which can happen when you employ a style with reusable schema fragments.)

              Type extension in XML schema has all kinds of limitations and special cases, whereas in RNG extending patterns works in a way that is very clean and natural. XML schema tends to force you into a style where you specialize types by restriction rather than extension; this is very unnatural if you have an OO background, and in my experience creates clumsy and brittle type hierarchies.

              On the other hand, XML schema continues to have far broader uptake in the community, and it's harder to communicate your product to a broad audience of developers with schemas in RNG. 



              On Nov 4, 2011, at 10:01 AM, Norm Birkett wrote:

               

              I'm new to all of these languages, but in my brief explorations
              of how I can validate a particular family of fairly complex XML
              languages, I have found that:

              (a) I very frequently have the experience where I can immediately
              see how to write a validation constraint in RNG/RNC, while I have
              to think and play around a while before I see how to express it
              in XML-S.

              (b) I regularly have the experience that is like (a) except that
              I never do figure out how to express the constraint in XML-S.
              It seems that everything I try is either too restrictive or too
              Unrestrictive, and I never do succeed in getting it "just right."

              I have also found that whichever of these languages I use, I
              also need to use Schematron to represent further validations that
              are more easily coded as rules, and as far as I can tell,
              Schematron is a bit easier to mesh with RNG/RNC than with XML-S.
              (However, I would not say that is a decisive consideration.)

              Based on the many occurrences of (a) and (b) that I've
              encountered during a pilot project, I would have to second what
              Syd wrote:

              " To put it simply, unless your application requires features
              that XSD supports and RNG does not (like PSVI), use RELAX NG.
              Period. And even if your application does require such a feature,
              try really hard to figure out how to change things so that you
              can use RELAX NG. It's simply a better language."

              I hope my little bit of experience with these things will be
              helpful to you.

              Norm Birkett

              > -----Original Message-----
              > From: rng-users@yahoogroups.com [mailto:rng-users@yahoogroups.com] On
              > Behalf Of r.khondoker
              > Sent: Monday, August 22, 2011 12:10 PM
              > To: rng-users@yahoogroups.com
              > Subject: [rng-users] RNG or XML Schema, which one to choose?
              >
              > Hi all,
              > I have a question regarding pros and cons of RNG and XML schema. I
              have
              > found the comparison in the following website
              >
              > http://www.xml.com/lpt/a/884
              >
              > I found that
              >
              > 1. Rules: Both XML schema (XML-S) and RNG dont support rules.
              > 2. Post Schema Validation Infoset (PSVI): XML-S supports, RNG dont
              > 3. Structures: Both supports
              > 4. Data types: XML-S supports, RNG supports partially
              > 5. Integrity: XML-S supports, RNG dont
              >
              > So far as I understand, the pros and cons of RNG and XML-S are as
              > follows. Please correct me if I am wrong
              >
              >
              > PROS
              >
              > 1. RNG is easy to understand and use. XML-S is comparatively difficult
              > 2. Using RNG, you can define grammar. XML-S does not offer this
              >
              > CONS
              >
              > 1. RNG does not provide the possibility to define an attribute or an
              > element as mandatory or required. Using XML-S, you can define that
              > explicitly using use="required"
              > 2. Using RNG, you cannot define the boundary (min and max). Using XML-
              > S, you can define that explicitly using minOccurs and maxOccurs
              > 3. Using RNG, if you dont define optional explicitly, the attribute or
              > element is required.
              >
              > I found the pros and cons in the wiki as well
              >
              > http://en.wikipedia.org/wiki/XML_Schema_Language_comparison
              >
              >
              > Could you please let me know if there is any literature which
              describes
              > the pros and cons of these two schemas with examples.
              >
              > Thanking you,
              > Ratul
              >
              >
              >
              > ------------------------------------
              >
              > Yahoo! Groups Links
              >
              >
              >


            • Sebastian Rahtz
              ... +1 getting multiple XML schemas is a real pain, having to keep an xml.xsd around just to provide xml:id drives me crazy.... -- Stormageddon Rahtz Head of
              Message 6 of 7 , Nov 4, 2011
              • 0 Attachment
                On 4 Nov 2011, at 17:34, John Madden wrote:

                >
                >
                > Another area where RNG excels, compared with XSD, is in support for modular and extensible schema development.
                >
                > XSD has complex namespace-handling that (to me) is full of gotchas, and makes layered imports very hard to create and maintain.

                +1

                getting multiple XML schemas is a real pain, having to keep an xml.xsd around just to provide xml:id drives me crazy....


                --
                Stormageddon Rahtz
                Head of Information and Support Group, Oxford University Computing Services
                13 Banbury Road, Oxford OX2 6NN. Phone +44 1865 283431

                Sólo le pido a Dios
                que el futuro no me sea indiferente
              • John Cowan
                ... Indeed, which is why $EMPLOYER s schema development group (to which I belong, although I am currently working on ontologies) develops in RNG and delivers
                Message 7 of 7 , Nov 4, 2011
                • 0 Attachment
                  John Madden scripsit:

                  > On the other hand, XML schema continues to have far broader uptake in
                  > the community, and it's harder to communicate your product to a broad
                  > audience of developers with schemas in RNG.

                  Indeed, which is why $EMPLOYER's schema development group (to which I belong,
                  although I am currently working on ontologies) develops in RNG and delivers
                  XSD to engineering groups.

                  I must say, though, that the although the handling of ID/IDREF in XSD is
                  rather messy, it is not nearly so messy as RNG's.

                  --
                  John Cowan <cowan@...> http://www.ccil.org/~cowan
                  Raffiniert ist der Herrgott, aber boshaft ist er nicht.
                  --Albert Einstein
                Your message has been successfully submitted and would be delivered to recipients shortly.