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

A simple and non-brittle way to create XML that evolves over time

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Wed, 29 Apr 2015 13:39:39 +0000

A simple and non-brittle way to create XML that evolves over time

Hi Folks,

 

Acknowledgement: Some of the below text and idea comes from section 4.2 of RFC 7493 (http://www.rfc-editor.org/rfc/rfc7493.txt)

 

It is frequently the case that changes to XML Schemas are required after they have been put in production.  XML Schemas that allow the introduction of new elements in a way that does not disrupt the operation of existing software have proven advantageous in practice.

 

This can be referred to as a "Must-Ignore" policy, meaning that when an implementation encounters an element that it does not recognize, it should treat the rest of the document as if the new element simply did not appear, and in particular, the implementation must not treat this as an error condition.  The converse "Must-Understand" policy does not tolerate the introduction of new elements, and while this has proven necessary in certain designs, in general it has been found to be overly restrictive and brittle.

 

A good way to support the use of Must-Ignore in XML designs is to require that the root element must contain a list of key/value pairs where each key is unique, and to specify that keys whose names are unrecognized must be ignored.

 

Example. Here is an XML document where the root element contains a list of key/value pairs and each key is unique:

 

<Book>
   
<Title>The First and Last Freedom</Title>
   
<Author>J. Krishnamurti</Author>
   
<Date>1954</Date>
   
<ISBN>0-06-064831-7</ISBN>
   
<Publisher>Harper &amp; Row</Publisher>
</Book>

 

This example shows simple values for each key. Of course the values could be complex.

 

Suppose that at a later date the XML Schema is extended to include a NumPages element. Now XML instances contain this:

 

<Book>
    
<Title>The First and Last Freedom</Title>
   
<Author>J. Krishnamurti</Author>
   
<Date>1954</Date>
   
<NumPages>289</NumPages>
   
<ISBN>0-06-064831-7</ISBN>
   
<Publisher>Harper &amp; Row</Publisher>
</Book>

 

If a consumer of this XML has not been coded to understand that new key/value pair, the consumer must ignore it.

 

Recap: design your XML so that the root element contains a list of key/value pairs where each key is unique. Notify consumers that over time the set of root element keys will expand and they should ignore any root element keys they do not understand.

 

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