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


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