[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Namespace: what's the correct usage?
- From: "Simon St.Laurent" <simonstl@simonstl.com>
- To: Martin Gudgin <marting@develop.com>
- Date: Sat, 19 May 2001 18:52:43 +0000
On 19 May 2001 23:38:56 +0100, Martin Gudgin wrote:
> > > But attributes are declared in the scope of their owner element. Why not
> > > child elements? This is the crux of the question I think.
> >
> > You certainly can write processors which behave this way, but there's
> > nothing _in the markup_ which indicates that the namespace scope for the
> > child elements behaves that way.
>
> [MJG]
> What about the qualified parent element? It is in the markup and would serve
> perfectly well as a namespace scope for its attributes. I'm just extending
> that in my case to the child elements.
But that's going beyond the scoping rules presented in Namespaces in
XML. The logic that understands that scoping has to take place at the
application level, and the labels coming strictly out of the parse are
downright misleading given anything resembling a conservative reading of
Namespaces in XML.
> [MJG]
> Agreed. But local scoping is useful in programming languages and I
> anticipate that it will be ( is? ) useful in XML documents even when not
> dealing with class serialization.
Then I suggest that you create a namespace which indicates that local
scoping of this kind is in effect, rather than relying on an assumption
about elements which have no namespace which may not hold true in pretty
much every XML processing environment I've encountered.
> > Unfortunately, I think the way you're going about using namespaces makes
> > a lot of potentially unfounded assumptions about how the document will
> > be processed. In an environment you completely control, that's fine,
> > but if your documents ever leak out to the rest of the world, you may
> > well find that no one else shares your assumptions and that therefore
> > the document is interpreted quite differently.
>
> [MJG]
> I think whichever way you use namespaces you are making assumptions about
> the people who will see and process your XML. People use local scoping in
> programming languages because it was recognised that putting everything in
> global variables was a bad idea. I suspect that over time a similar
> observation may apply to XML.
Sure - we're always making assumptions. But if you're designing for
interchange, it's usually wise to be as absolutely explicit as possible
about the assumptions you're making, and to share them _in the markup_.
By relying on a null value without explaining the meaning of that null
value, you're potentially misleading anyone else who has to deal with
your XML document in any context other than the one you create.
From my perspective, you're taking a very dangerous shortcut, one which
is more dangerous to other people than to yourself. It might be smart
to create a namespace URI - like http://develop.com/ns/localscoping -
and put a RDDL document there explaining what you're doing. That might
get you out of a number of the concerns expressed here _and_ provide a
means for other people to explain that they're also taking your
shortcut.