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.

http://www.zvon.org/xxl/XMLSchemaTutorial/Output/ser_simpleContent_st2.html

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

In brief:

Valid document:

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

WXS:

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

RNG:

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

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 
model."

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

http://www.xml.com/pub/a/2002/01/23/relaxng.html?page=1

which cross-references to Using W3C XML Schema

http://www.xml.com/pub/a/2000/11/29/schemas/part1.html?page=1

The key section is Content Types

http://www.xml.com/pub/a/2002/01/23/relaxng.html?page=4

from which:

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

 <element name="book">
  <attribute name="isbn">
   <text/>
  </attribute>
  <interleave>
   <element name="title">
    <text/>
   </element>
   <element name="author">
    <text/>
   </element>
   <zeroOrMore>
    <text/>
   </zeroOrMore>
  </interleave>
 </element>

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">
  <zeroOrMore>
   <text/>
   <element name="br">
  </zeroOrMore>
  <optional>
   <text/>
  </optional>
 </element>
"""

As another example of the added expressivity RNG allows, see Modularization of 
XHTML in RELAX NG

http://www.thaiopensource.com/relaxng/xhtml/

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

http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#string-sequenc
es

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

http://lists.oasis-open.org/archives/relax-ng/200207/msg00002.html

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 
content.

General: Some other useful WXS/RNG comparison links:

* XML Schema and RELAX NG Element Comparison: http://www.wyeast.net/compare.htm
l
* Converting RELAX NG to W3C XML Schema: http://www.idealliance.org/papers/xml0
2/dx_xml02/papers/04-01-04/04-01-04.html
* 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
ite5-i/
XML class warfare - http://www.adtmag.com/article.asp?id=6965
MusicBrainz  metadata - http://www-106.ibm.com/developerworks/xml/library/x-thi
nk14.html




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


Powered by eList eXpress LLC