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]
RE: [xml-dev] 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]


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