[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xml-dev] RE: Namespaces Best Practice
- From: David Brownell <david-b@pacbell.net>
- To: Jonathan Borden <jborden@mediaone.net>, xml-dev@lists.xml.org
- Date: Thu, 20 Sep 2001 11:13:46 -0700
> > > > 1) An XML Namespaces best practice for document/application design is
> > > > to define all namespace prefix bindings at the document (root)
> > > > element context.
> >
> > For the record: yeech!
> >
> > In every style guide I've ever seen, the guidance for lexical scoping
> > mechanisms is to use them to localize information to its most natural
> > scope. Loop-private variables are invisible outside the loop, etc.
>
> For the record, this best practice is lifted from "Common XML" itself a best
> practices guideline:
> http://www.simonstl.com/articles/cxmlspec.txt
That writeup adopts a per-file definition of "most natural scope",
which is more extreme than any definition I'd adopt, though
it fits into the "wriggle room" which I mentioned.
That's a bit less extreme than what you wrote, though
that still wouldn't make me adopt it! :)
> I fail to see how a "loop private variable" relates to a namespace defined
> by a URI. This is like comparing apples not with oranges but with entire
> countries which themselves have farms which themselves contain orange
> groves.
That's like ... hyperbole!
The relationship is: both bind values to names.
Both use "lexical scoping" to determine values at use point.
> > (The analogy to Java package names is false; that's not a lexical
> > scoping mechanism. Block scoped variables are examples of
> > lexical scoping mechanisms in Java and most modern languages.
> > "xmlns" declarations are lexically scoped.)
>
> You need to understand this recommendation in its entirety. I do not
> advocate reusing namespace prefixes, and so the use of namespaces in order
> to accomplish "block" scoping is not really that important (IMHO).
Information scoping (one variant is "information hiding") is a classic
best-practice in systems development. Lexical scoping isn't only to
support rebinding of names to values; it's also to minimize the amount
of global state (vs maximizing it, per the CXML policy or the one
which you proposed).
> I do see
> reasons why such lexical scoping may facilitate "cut and paste" operations
> on namespace qualified documents, but that is a minor role of namespaces in
> XML.
Cut'n'paste is a task, not a role, and one which is exemplary of many other
tasks. I can understand that you may not care much about those tasks, but
that doesn't mean that they're not common parts of working with XML.
> We need to see the role of XML Namespaces in a larger context than mere
> lexical scoping. Indeed an XML Namespace is very much like a Java package.
Maybe you're talking about a policy for what the namespace URI
denotes, not about the policy for managing binding of those URIs
to prefix names (or as a default prefix). There are other policies;
the namepaces spec doesn't touch on any preferred policy.
If that's what you're talking about, I claim apples/oranges! :)
- Dave