[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xml-dev] RE: Namespaces Best Practice
- From: "Simon St.Laurent" <simonstl@simonstl.com>
- To: David Brownell <david-b@pacbell.net>, Rick Jelliffe <ricko@allette.com.au>,xml-dev@lists.xml.org
- Date: Thu, 20 Sep 2001 14:29:02 -0400
At 10:57 AM 9/20/2001 -0700, David Brownell wrote:
>But aren't there issues like "how far do you bubble down"?
>Normally I'll think that certain nodes in a given document will
>be natural spots to bubble down to, even if some decls could
>get bubbled down even further.
This is where the problems start to get interesting. From the point of
view of least-number-of-declarations, you need to check a big chunk of the
tree to put namespace declarations in the element which is one above where
the namespace actually gets used.
Putting namespace declarations in where they are used (tight scoping) works
well when a namespace only appears once, but produces piles of declarations
that could have been avoided when a namespace appears lots of time over the
course of a document but is scattered. (XLink tends to do that, but there
are lots of other cases.)
It's the kind of problem humans are generally good at solving but which
take some algorithmic tree-trickery to solve efficiently on a computer.
As a guideline, I'm pretty happy with "declare all namespaces on the root
element whenever possible", while still recognizing that isn't always possible.
Finally, I don't think variable-scoping is a useful comparison for
namespace-scoping in XML documents. There aren't a lot of
XLink-attribute-like things that get used in a scattered way across a Java
program but are still in the same namespace, for instance. Variable
scoping is nicely contained by the logic of program flow, while namespace
scoping may be much more arbitrary.
Simon St.Laurent
Associate Editor
O'Reilly & Associates, Inc.