[Home] [By Thread] [By Date] [Recent Entries]

  • From: "Costello, Roger L." <costello@m...>
  • To: "xml-dev@l..." <xml-dev@l...>
  • Date: Thu, 30 Apr 2015 13:30:27 +0000

Hi Folks,

 

An XML object is an element whose content is a collection of heterogeneous data items. For example, this Book element contains a collection of heterogeneous data items and therefore is an XML object:

 

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

 

The fact that it is an object becomes more apparent with this graphic:

 

Recommendation: Don’t create XML objects with duplicate keys. For example, this Book object has duplicate Author keys:

 

<Book>
   
<Title>Parsing Techniques</Title>
   
<Author>Dick Grune</Author>
   
<Author>Ceriel Jacobs</Author>
   
<Date>2007</Date>
   
<ISBN>978-0387202488</ISBN>
   
<Publisher>Springer</Publisher>
</Book>

 

https://doctoralschool.files.wordpress.com/2011/07/stop-dont-do-it-stay-away-3.jpg

 

Instead, create a single Authors element whose content is an array:

 

<Book>
   
<Title>Parsing Techniques</Title>
   
<Authors><Author>Dick Grune</Author><Author>Ceriel Jacobs</Author></Authors>
   
<Date>2007</Date>
   
<ISBN>978-0387202488</ISBN>
   
<Publisher>Springer</Publisher>
</Book>

 

Now the Book object contains a collection of unique keys. The value of the Authors key is an array of Author elements.

 

Why follow this recommendation? Here’s why:

 

1. It enables XML objects to evolve, using the Must-Ignore policy, as I described in yesterday’s message.

 

2. It enables conversion between XML and programming language objects and databases.

 

3. It is consistent with rfc 7493 (http://www.rfc-editor.org/rfc/rfc7493.txt) which recommends that no JSON object have duplicate keys.

 

/Roger

 



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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member