OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

office message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Subject: [office] RELAX NG vs WXS for mixed content

Sorry for all the delays.  It has been a hectic month.

I'd still like to do more work on this, but I decided I should just get what I 
have to the group without further delay.  As I find more, I'll post it.

Side note: I may not be able to make today's conference call.

These notes are all from secondary sources.  I am familiar enough with both 
schema languages to get a basic feel that my findings make sense.

The excellent ZVON tutorial pages include a lot of side-by-side comparison of 
WXS and RNG.


compares mixed content in the form of text and only one element.

In brief:

Valid document:

  <AAA>   xxx yyy
    <BBB>ZZZ</BBB> aaa


  <xsd:element name="AAA">
    <xsd:complexType mixed="true">
      <xsd:sequence minOccurs="1">
        <xsd:element name="BBB" type="xsd:string"/>


  <element name="AAA" xmlns="http://relaxng.org/ns/structure/1.0"; >
      <element name="BBB" ns="">

So far, so similar.  The main difference is that, in Eric van der Vlist's 
words, "[in WXS] you can't ANY constraint on the text nodes in a mixed content 

For more information on this, see Eric's Relax NG, Compared


which cross-references to Using W3C XML Schema


The key section is Content Types


from which:

To define mixed content models you declare both embedded text and elements:

 <element name="book">
  <attribute name="isbn">
   <element name="title">
   <element name="author">

Since text nodes are handled like elements and attributes, their individual 
location and type can be defined and constrained, something which isn't 
possible with W3C XML Schema. Suppose we have an element p containing lines 
terminated by empty br elements, and that we want to disallow blank lines. We 
can write

 <element name="p">
   <element name="br">

As another example of the added expressivity RNG allows, see Modularization of 


where it is pointed out that RELAX NG permits even more expressivity than DTD:

"The object and applet modules takes advantage of RELAX NG's absence of 
restrictions on mixed content to enforce the requirement that params precede 
other content.  The forms module takes advantage of RELAX NG's absence of 
restrictions on mixed content to enforce the requirement that any legend 
precedes other content."

These features are also not available to WXS.

RELAX NG does restrict sequences of content which can match a data type and 
child element or tex in the same span.  See section 7.2 String sequences


for details.  Eric van der Vlist has posted objections to this restriction.  
See discussion throughout this thread


Note that this is a lighter restriction than WXS, which doesn't allow such 
patterns anyway because it doesn't allow constraints on text nodes in mixed 

General: Some other useful WXS/RNG comparison links:

* XML Schema and RELAX NG Element Comparison: http://www.wyeast.net/compare.htm
* Converting RELAX NG to W3C XML Schema: http://www.idealliance.org/papers/xml0
* James Clark's post "RELAX NG and W3C XML Schema" ( 
http://www.imc.org/ietf-xml-use/mail-archive/msg00217.html ) has been widely 
debated.  It does not discuss mixed content issues, though.

Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Python Generators + DOM - http://www.xml.com/pub/a/2003/01/08/py-xml.html
4Suite Repository Features - https://www6.software.ibm.com/reg/devworks/dw-x4su
XML class warfare - http://www.adtmag.com/article.asp?id=6965
MusicBrainz  metadata - http://www-106.ibm.com/developerworks/xml/library/x-thi

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Powered by eList eXpress LLC