Namespace prefixes optional?
rev-bob at gotc.com
rev-bob at gotc.com
Sun Jan 9 22:52:58 GMT 2000
> David Megginson wrote:
> > Here are the tricky points about Namespaces:
> > 1. Namespace URIs are just unique identifiers, like Java or Perl
> > package names; they don't (necessarily) point to anything.
> > 2. There can be a default Namespace for element names but not for
> > attribute names.
> > 3. Not withstanding #2, some apps may treat unprefixed attribute names
> > as if they belong to the same Namespace as the corresponding
> > element name.
Seems from here that a simple containment-based default scheme would avoid a lot of
headaches in this matter. That is, unless X has an explicit namespace, X defaults to the
namespace of its parent - whether X is an attribute (parent = element) or an element
(parent = containing element). That certainly seemed to be what the XHTML spec
implied; define the namespace for <html>, and everything contained within the html
element defaults to the html namespace unless otherwise noted.
As it stands, I really don't like the idea of having to prefix each and every element name
and attribute name with a namespace prefix just to ensure that the intent is clear.
Defining the deltas ("here's where the namespace changes") seems *much* more
logical...not to mention being easier to maintain and easier to read. (Yeah, tacking a
namespace onto every token may not seem like a big deal when generating a document
- but have you ever tried to *modify* such a monstrosity?)
For a basic example of what I mean, in hopes of making my intentions clearer, take this
fragment - assuming that all referenced namespaces have been defined, of course.
<rbns:fragment name="Fred" creator="Rev. Bob">
<htmlns:p align="left">Here's a bit of <b bubbans:foo="bar">XHTML</b> thrown into
What I am proposing would make that equal to this namespace-explicit fragment:
<rbns:fragment rbns:name="Fred" rbns:creator="Rev. Bob">
<htmlns:p htmlns:align="left">Here's a bit of <htmlns:b
bubbans:foo="bar">XHTML</htmlns:b> thrown into the mix.</htmlns:p>
That is, by defining "fragment" as belonging to namespace rbns, I am defining the
attributes of "fragment" and the children of "fragment" as belonging to the same
namespace by default. With the "p" element, I declare that it belongs to the htmlns
namespace, along with (by default) its children and attributes. With the "b" element, for
some reason, I need to attach an attribute from the bubbans namespace - so I mark just
that attribute as belonging to a different space. When "p" closes, so does the htmlns
fragment, and the default namespace reverts back to rbns.
Rev. Robert L. Hood | http://rev-bob.gotc.com/
Get Off The Cross! | http://www.gotc.com/
Download NeoPlanet at http://www.neoplanet.com
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev