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

RE: Lesson Learned: Use namespaces for both markup anddata

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "'xml-dev@lists.xml.org'" <xml-dev@lists.xml.org>
  • Date: Wed, 12 Aug 2009 12:58:28 -0400

RE:  Lesson Learned: Use namespaces for both markup anddata

Hi Folks,

This discussion has been very enlightening for me. Thank you!

I think that I now understand the disadvantages of using QNames in element and attribute content. 


Allow me to summarize:


EXAMPLE: Create an <object-id> element, whose value is a URL-based identifier for any object. Here are two approaches:

------------------------------------------------------
Approach #1: QName Content

The content of <object-id> is a QName:

<example xmlns:aquarium="http://www.aquarium.org#">

    <object-id>aquarium:tank</object-id>

</example>

------------------------------------------------------
Approach #2: anyURI Content

The content of <object-id> is an anyURI value:

<example>

    <object-id>http://www.aquarium.org#tank</object-id>

</example>

------------------------------------------------------


*** Approach #2 is preferred. ***


There are several disadvantages to Approach #1:

1. It's easier to compare two anyURI values than it is to compare QName values. A QName value has to be "resolved," i.e. the prefix has to be associated with the namespace URI, and then you have to compare the namespace URIs and the local names.

Comparing the value of these two <object-id> elements:

------------------------------------------------------
<example xmlns:aquarium="http://www.aquarium.org#">

    <object-id>aquarium:tank</object-id>

</example>

<Boston xmlns:a="http://www.aquarium.org#">

    <object-id>a:tank</object-id>

</Boston>
------------------------------------------------------


is more challenging than comparing these two <object-id> elements:


------------------------------------------------------
<example>

    <object-id>http://www.aquarium.org#tank</object-id>

</example>

<Boston>

    <object-id>http://www.aquarium.org#tank</object-id>

</Boston>
------------------------------------------------------

2. If you, say, use the XSLT document() function to copy this element:

   <object-id>aquarium:tank</object-id>

into another document then you've lost the association between the prefix (aquarium) and its namespace URI (http://www.aquarium.org#)

Thus, QName content doesn't lend itself to copy-and-paste. 

The prefix looses its value once it's outside the XML document where it's defined. 


3. A good division of labor is:

   - XML Parsers deal with markup
   - Applications deal with data

By using QNames in content you've lost the division of labor between the XML Parser and application because the XML Parser must process the prefix that's in the content.


Is this a correct summary of the disdvantages of using QNames in content? Is there anything else you recommend adding?

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