[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Backward and forward compatible schemas ... Relax NG --> Yes ... XML Sc

  • From: "Costello, Roger L." <costello@m...>
  • To: <xml-dev@l...>
  • Date: Thu, 23 Aug 2007 15:41:50 -0400

Backward and forward compatible schemas ...  Relax NG --> Yes ... XML Sc
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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.