> ....defined in the specification, and then there's the intuitive,
> programmatically easy way.  Unfortunately, if you do them the correct
> way, the XML API immediately becomes obtuse to casual XML users.  If
> you don't, then it is very difficult to have them behave as an XML
> expert would expect.  For example, take the following pseudo-code:
> 
> 	a = Element.new( "a", "some namespace" )  # create <a> in namespace
> "some namespace"
> 	b = a.add_element( "b" )
> 
> What namespace is "b" in?  Is "some namespace" the default namespace
> for "a" and its children?  No matter how you solve this problem, the
> result is an API that is tedious to use.  I'm still struggling with
> this, and probably will be, until XML is replaced by something else.

May I offer the suggestion of a "context" object that defines /all/ the
namespaces and mappings to their prefixes, and then, all one has to do
is:
	
	context = new Context({'foo', 'http://foo.org/b', 
		'', 'http://www.w3.org/somewhere'})
	context.do {
		a = Element.new("foo:a")
		b = a.add_element("b")
	}

the element "b" would get the w3.org namespace, and foo:a would get the
foo.org namespace.

It's implementable with a little hacking, with a thread variable to hold
the current context, and the context.do method could be a little ugly
push-popping that and tweaking in the thread namespace.  Quite doable,
though, and easy to use, I think -- you define your namespaces similarly
to as in XML, where they've a lexical scope on all contained elements,
and here, on all contained statements.  They're nestable, which would be
nice, too.

It's a thought, anyway, and if anyone has ideas that don't use thread or
global variables, I'd love to see them, because I want an API for XML
that's not a monster.  REXML is as close as exists so far, I think.

A sidenote: Sean, I'd like to pick your brain some time, since I'm
planning to set up a way of indexing content of XML documents in a
separate index file, and it may make XPath searches much faster and add
the possibly of disk-based access instead of parse-whole-tree access of
docs for XPath.

Be well, all.

Ari