Re: Uncle Dave ponders the meaning of namespaces

Date view Thread view Subject view Author view

From: Dan Brickley (Daniel.Brickley@bristol.ac.uk)
Date: Fri Aug 11 2000 - 02:18:34 PDT


On Thu, 10 Aug 2000, Dave Winer wrote:

> As long as we're trashing cherished beliefs tonight..

[...]
> I found myself wondering why the designers of
> namespaces didn't use an attribute to specify the namespace. Then it would
> look familiar to people who have experience in HTML.
>
> Instead of:
>
> <mynamespace:mytag/>
>
> It would have been
>
> <mytag namespace="mynamespace"/>

I'm not sure if this is 100% what you're after, but
you can do this for default namespaces, e.g.:
(writing xmlns= not namespace=)

        <mytag xmlns="http://example.com/namespace/" />

Excerpt from spec, http://www.w3.org/TR/REC-xml-names/#defaulting

        5.2 Namespace Defaulting

        A default namespace is considered to apply to the element where it is
        declared (if that element has no namespace
        prefix), and to all elements with no prefix within the content of that
        element. If the URI reference in a default
        namespace declaration is empty, then unprefixed elements in the scope of
        the declaration are not considered to be
        in any namespace. Note that default namespaces do not apply directly to
        attributes.

[...]

Example from the spec:

<?xml version="1.0"?>
 <!-- initially, the default namespace is "books" -->
 <book xmlns='urn:loc.gov:books'
       xmlns:isbn='urn:ISBN:0-395-36341-6'>
     <title>Cheaper by the Dozen</title>
     <isbn:number>1568491379</isbn:number>
     <notes>
       <!-- make HTML the default namespace for some commentary -->
       <p xmlns='urn:w3-org-ns:HTML'>
           This is a <i>funny</i> book!
       </p>
     </notes>
 </book>

This seems pretty close to what you're after with:

> <mytag namespace="mynamespace"/>

In practice I think we see less of this style of xmlns authoring than
you expect, ie. people live with seeing colon'd prefixes scattered
everywhere, eg. <s:title>, <book:title>,
<dc:title> since it makes document fragments immediately
understandable without the need to trawl back up the tree looking for
the namespace-setting attribute that tells you _which_ notion of 'title'
we're talking about.

While you're doubtless right that all those colon'd prefixes look
a bit funny to someone who has only known HTML, they can be minimised
using techniques such as that above. This has its own usability
tradeoffs, ie. lose visual clutter at cost of more grovelling around to
figure out the current default namespace. The ability to mix
independently defined language contructs is fundamental to XML (why
else have a notion of wellformedness as well as validity). I reckon
it's not the end of the world to expect developers learning XML to get
their heads around the notion that <title> might mean many things and
that XML provides the xmlns attribute as a way of picking out which
sense we mean...

 
> You could put more attributes there. This might be the only indisputable
> place to use an attribute, but of course a True Believe would say you have
> to do it this way:
>
> <mytag>
> <namespace>mynamespace</namespace>
> </mytag>
>
> So that the namespace could become something much cooler 25 years from now.
>
> Which is probably why they went with the colonular notation.
>
> Anyway, more pissing in the wind from Uncle Dave.

Well since the namespace has a web identifier, we can (25 years later or
right now) use that to describe it some more. Inline or at
veryimportantxmlregistry.org or wherever. This trick lets us punt the
elements-versus-attributes issue to a certain extent since we can always
come back and add extra information to anything we've described with a URI.

eg:

<!-- a decription of the namespace with the web identifier
                                        http://example.com/namespace/
        this might be aggregated at schemasschemasschemas.org or
        wherever... -->

<namespace xmlns="http://example.com/util"
        webid="http://example.com/mynamespace/">

        <title>The MyNamespace XML vocabulary</title>
        <blurb>This vocabulary provides a B2C2B2B e-vocabulary
        to e-mpowerise XML-driven e-apps</blurb>
        <pricing>call now for further information</price>
        <contact webid="tel:234-234-234-234"/>
        <preferredPrefixList>default my My eMY</preferredPrefixList>

</namespace>

--danbri


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Aug 11 2000 - 02:23:00 PDT