XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Backward and forward compatible schemas ... Relax NG --> Yes ... XML Schema --> No

Hi Folks,
 
I am trying to characterize the types of changes to schemas which
enable backward and forward compatibility.
 
[Definition] An old and new schema are backward and forward compatible
with the other if each can validate XML instance documents that were
written to the other schema.  Thus, a new application can process XML
instances from an old application, and an old application can process
XML instances from a new application.

Assertion: Relax NG supports backward and forward compatibility but XML
Schemas does not.

Here's how I arrived at my assertion ...

Example of Two Schemas that are Backward and Forward Compatible

Suppose the old schema has an "open section" where zero or more
arbitrary elements may be inserted.  The new schema is created by
making this change to the old schema: prepend to the open section an
optional <Reviewer> element.  

The old application may produce XML instances without a <Reviewer>
element, which is acceptable to the new application. XML documents
produced by the new application may contain a <Reviewer> element, which
is acceptable to the old application (since <Reviewer> will be
considered to be part of the open section).

Relax NG Implementation

Old Schema:

        <element name="Book">
            <element name="Title">
                <text/>
            </element>
            <element name="Author">
                <text/>
            </element>
            <element name="Date">
                <text/>
            </element>
            <element name="ISBN">
                <text/>
            </element>
            <element name="Publisher">
                <text/>
            </element>
            <zeroOrMore>
                <element>     
                    <anyName/>
                    <text/>
                </element>
            </zeroOrMore>
        </element>

The contents of Book is: Title, Author, Date, ISBN, Publisher, and then
anything (i.e. "open section").

New Schema:

        <element name="Book">
            <element name="Title">
                <text/>
            </element>
            <element name="Author">
                <text/>
            </element>
            <element name="Date">
                <text/>
            </element>
            <element name="ISBN">
                <text/>
            </element>
            <element name="Publisher">
                <text/>
            </element>
            <optional>
                <element name="Reviewer"> 
                    <text/>
                </element>
            </optional>
            <zeroOrMore>
                <element>     
                    <anyName/>
                    <text/>
                </element>
            </zeroOrMore>
        </element>

Now the contents of Book is: Title, Author, Date, ISBN, Publisher,
Reviewer?, and then anything (i.e. "open section").  Observe that the
new schema has an additional element - Reviewer.

XML instances conforming to the old schema validate against the new
schema, and XML instances conforming to the new schema validate against
the old schema. Thus, these two schemas are backward and forward
compatible, and Relax NG supports backward and forward compatible
schemas.

XML Schema Implementation

Old Schema:

        <element name="Book" maxOccurs="unbounded">
            <complexType>
                <sequence>
                    <element name="Title" type="string"/>
                    <element name="Author" type="string"/>
                    <element name="Date" type="string"/>
                    <element name="ISBN" type="string"/>
                    <element name="Publisher" type="string"/>
                    <any minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </complexType>
         </element>

The contents of Book is: Title, Author, Date, ISBN, Publisher, and then
anything (i.e. "open section").

New Schema:


        <element name="Book" maxOccurs="unbounded">
            <complexType>
                <sequence>
                    <element name="Title" type="string"/>
                    <element name="Author" type="string"/>
                    <element name="Date" type="string"/>
                    <element name="ISBN" type="string"/>
                    <element name="Publisher" type="string"/>
                    <element name="Reviewer" minOccurs="0"
type="string"/>
                    <any minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </complexType>
         </element>

Now the contents of Book is: Title, Author, Date, ISBN, Publisher,
Reviewer?, and then anything (i.e. "open section").  Observe that the
new schema has an additional element - Reviewer.

However, the new schema is not legal; an optional element prior to an
<any/> is not legal, as it makes the content of Book
"non-deterministic"; a validator will generate an error:
Non-deterministic Content Model.  Thus, XML Schema does not support
backward and forward compatible schemas for this type of change.

Do you agree with my assertion: Relax NG supports backward and forward
compatibility but XML Schemas does not?

I am unable to think of other types of changes to a schema that would
provide backward and forward compatibility.  Can you think of any?

/Roger






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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS