On Tue, Oct 01, 2002 at 08:58:34AM +0900, MikkelFJ wrote:
> > > What about scoped access:
> > > ns_of_fullname("N") yields prefix for outermost scope
> > > ns_of_fullname("N.N") yields namespace string of nested scope.
> > > ns_of_name("N") yields best matching, preferring least nested scope in
> case
> > > of a conflict.
> >
> > Maybe I'm dense, but I don't follow this at all. Are you saying these
> > methods exist somewhere? I haven't seen them in the docs for Ruby or
> > REXML, or in the XML Namespaces spec*. Or are you just asking what-if?
> 
> I'm saying what-if.

Okay, it starts to make a bit more sense then. Unfortunately I don't
think your idea is quite compatible with how XML namespaces work. The 
problem is that at any given scope (i.e. within any given element in the
document hierarchy), there may be several namespaces in scope, or none.
And an unqualified name may either have no namespace or be part of a
default namespace (i.e. one defined with no prefix). So if I have a
document like this:

  <doc>
    <junk>Blablabla</junk>
    <innerSanctum xmlns="http://www.sillyxml.com/">
      <junk>Yadda yadda yadda</junk>
    </innerSanctum>
  </doc>

the first <junk> has no namespace, but the second <junk> belongs to the
"http://www.sillyxml.com/" namespace. So,

> > > ns_of_fullname("N") yields prefix for outermost scope

Nope, not if you apply it to the second <junk>.

> > Are you sure you're talking about XML Namespaces as defined by the W3C?
> > If so, you're using terminology that I've never heard in that context.
> 
> I'm working with hierachical data in other contexts so I recognized the
> problem but I'm not deep into XML DOM or REXML naming conventions. I believe
> the term 'name' and 'fullname' is used fairly widely. ns just seemed more
> convenient than namespace.

I guess I was thinking mainly of 'fullname' and 'namespace string',
which are perfectly understandable but not commonly used in XML circles.

> BTW: I've alwas found it difficult to accept that XML namespaces are flat -
> one namespace cannot belong to another, although the URL's provide som sort
> of hierarchy. Prefixes are scoped, but that is different.

I'm not sure how much of a problem that really is. You can think of the
elements themselves  as constituting a kind of namespace hierarchy--and
tools like XPath allow you to easily distinguish between the <address>
elements in the two following examples:

  <leaders>
    <president>
      <name>Abraham Lincoln</name>
      <address>Gettysburg Address</address>
      ...

and

  <PO>
    <customer>
      <name>A Graham Pinken</name>
      <address>
        <line>3939 A St.</line>
        ...

So you can process the <address> differently based on whether it's a 
'/leaders/*/address' or a 'customer/address' ... or to take a more
likely example, distinguish a 'book/title' from a 'section/title' or a
'section/section/section/title'. And, unlike DTDs, XML Schema and RELAX
NG allow you to create context-dependent element definitions.

There are certainly difficult issues with XML Namespaces--especially
related to what, if any, semantics the namespace URI should have, and 
whether unqualified attributes should have no namespace while
unqualified attributes may belong to a default namespace. But if you
know how to work with the element hierarchy, I don't see what great
advantage there would be in having hierarchical namespaces. I imagine
you're talking about something like:

  <doc>
    <a:foo xmlns:a="http://www.example.com/a">
      <b:bar xmlns:b="b"/>
    </a:foo>
  </doc>

so that the b:bar element could be referred to as 'a:b:bar', and its
namespace URI would resolve to "http://www.example.com/a/b"? Is there
something you could do under this scheme that is difficult or impossible
with flat namespaces? Or is it more a matter of convenience?

Just curious, really. I have been very steeped in the SGML/XML
worldview, and I sense that you are more of a programmer, which is of
course fine, but it entails a slightly different way of thinking.

-- 
Matt Gushee
Englewood, Colorado, USA
mgushee / havenrock.com
http://www.havenrock.com/