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

RE: My report on experiments with unused namespaces

  • From: Amelia A Lewis <amyzing@talsever.com>
  • To: "Costello, Roger L." <costello@mitre.org>
  • Date: Wed, 22 Sep 2010 11:56:31 -0400

RE:  My report on experiments with unused namespaces
On Wed, 22 Sep 2010 10:21:13 -0400, Costello, Roger L. wrote:
> David Carlisle suggested validating an XML document against a DTD as 
> a mechanism for detecting unused namespaces. I tried it. It works 
> well.

Nonsense.

> I created this DTD:
> 
> <!ELEMENT Root (child)>
> <!ATTLIST Root
>           xmlns CDATA #FIXED 'http://www.used.org'>
> 
> <!ELEMENT child (#PCDATA)>
> <!ATTLIST child
>           xmlns CDATA #FIXED 'http://www.used.org'>
> 
> 
> This XML document contains no unused namespaces:

This XML document contains no attributes undefined in the DTD.

> -----------------------------------
> <Root xmlns="http://www.used.org">
> 
>         <child>true</child>
> 
> </Root>
> -----------------------------------


> Then I added an unused namespace:

Then you added an attribute not defined in the DTD.

> -----------------------------------
> <Root xmlns="http://www.used.org"
>       xmlns:foo="blah">
> 
>         <child>true</child>
> 
> </Root>
> -----------------------------------
> 
> Validation fails. Good! Validation detected the unused namespace.

DTD validation knows *nit* about namespaces.  It detected the 
introduction of an attribute which was not specified in the DTD.  These 
are *different* errors.

> Conversely, this XML Schema does not detect the unused namespace:

This XML Schema understands namespaces, and consequently permits any 
attribute with the reserved "xmlns" prefix, as required by the Schema 
specification.

Sheesh.

> Validation succeeds with or without the unused namespace.

Still haven't defined this term.

Your "DTD validation" to check for an "unused namespace" is doing 
nothing of the sort.  Fix your DTD:

<!ELEMENT Root (child)>
<!ATTLIST Root
          xmlns CDATA #FIXED 'http://www.used.org'
          xmlns:foo CDATA #IMPLIED>

<!ELEMENT child (#PCDATA)>
<!ATTLIST child
          xmlns CDATA #FIXED 'http://www.used.org'>

Validates.  Not doing anything about "detecting unused namespaces".  It 
is *validating*.  It is determining whether all of the attributes (and 
DTD validation don't know from "namespaces") have been declared or not.

From an earlier email:

On Wed, 22 Sep 2010 04:58:34 -0400, Costello, Roger L. wrote:
> Amelia Lewis wrote:
> 
>> Given these potentially significant characterizations, what's the goal 
>> of categorizing namespace declarations as "in use" or "not in use"?
> 
> Simon noted in his message:
> 
>     ... namespace declarations as kind of a 
>     backchannel for propagating information
> 
> In my first message I showed that unused namespaces can contain large 
> amounts of information which is unchecked by XML applications (e.g., 
> XML Schema validation ignores unused namespaces).
> 
> This is a significant concern for me and others.
> 
> Eliminating unused namespaces reduces concern.
> 
> Goal: identify and eliminate unused namespaces.

Goal: make the problem worse, not better.

Example:

<doc xmlns:grue="http://it.is.dark/">
 ... 1024 MB content, nesting six levels deep:
            <room id="xyzzy" grue:eat="if-dark" />
 ... another half gig of content ...
</doc>

Another document is identical, except that //room[@id='xyzzy'] has no 
attribute grue:eat.

One instance of the namespace buried levels and levels deep, while the 
namespace declaration appears (perhaps with many others) on the root.  
This is a document that demands some form of streaming processing 
(perhaps in chunks).

There's one set of best practices that cause enormous kerfluffle:

bp-a) declare namespaces as "locally" as possible (minimal scope 
required for well-formedness)

bp-b) declare namespaces "eagerly" (if possible, declare on the 
document element)

But this is just silly.  You have the goal of removing "unused" 
declarations.  I consider that dangerous, verging on worst practice.

Amy!
-- 
Amelia A. Lewis                    amyzing {at} talsever.com
Igne natura renovatur integra.




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