Wednesday, August 20, 2008

Introducing RELAX NG

Previous posts mentioned RELAX NG as an alternative to XML Schema. There are both advantages and disadvantages to using that technology. Before mentioning all these, it might be interesting to see what your first impression is, just by giving an example.

This example is a translation from the XML Schema presented in the developerWorks post on creating maintainable and extensible XML formats. It is from the section "Design a more general format". This is RELAX NG Compact Notation:


default namespace = "http://car.org/car"

namespace tr = "http://car.org/tire"

namespace wnd = "http://car.org/windscreen"


start =

  element car {

    element brand { text },

    element type { text },

    element kind { text },

    (element tr:tire {

       attribute tr:count { xsd:integer },

       element tr:brand { text },

       element tr:type { text }

     }

     | element wnd:windscreen {

         attribute wnd:count { xsd:integer },

         element wnd:brand { text }

       })+

  }


0 reacties: