From: Sam Roberts Date: 2003-06-28T10:22:36+09:00 Subject: Re: REXML and Namespaces. This seems similar to APIs in XOM, which I've been reading about. Have you looked at it, and the design discussion behind it? http://www.cafeconleche.org/XOM/ Sam Quoteing ser@germane-software.com, on Sat, Jun 28, 2003 at 04:30:34AM +0900: > > the element "b" would get the w3.org namespace, and foo:a would get the > > foo.org namespace. > > This is an interesting idea. I was thinking along the same lines, but > with setting the context in the node tree itself: > > a = doc.add_element("a") # New element, no namespace > a.define_namespace( "foo", "http://foo.org/b" ) > # Assoc. namespace w/ prefix > a.namespace = "http://foo.org/b" # Set a's namespace > b = a.add_element("b") # Add b to a; no default (no) > # namespace > c = a.add_element("c", "http://x.org") > # Add c to a in x.org namespace > d = c.add_element("d") # Add d to c, in default (x.org) > # namespace > e = c.add_element("e", '') # Add e to c, w/ empty namespace > > My hesitation with doing things this way is that it marginalizes > prefixes, which is how XML is defined. However, it is not the way > people think about namespaces. It also hides the nature of default > namespaces, which I really don't like. > > > 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. > > If you can think of a way to do this, I'd really like to hear about > it. At one point I wrote a version of XPath that used indexed trees, > in the hopes that I could speed it up. I discovered that the time > consuming aspects of XPath are things that are not indexable: > predicates. Predicates must be evaluated in the context of a node. > Ironically, having to deal with namespaces also really slows down > XPath searches. In the end, the cost of indexing a document offset > any speed gains the indexing provided; in fact, for simple 'a/b' > XPaths, the indexed version was only faster where the indexing cost > was amortized over multiple searches. > > It sounds like you've got something in mind that bypasses parsing the > XML document at all, which would be interesting; to be honest, I can't > imagine how you could evaluate an XPath in that context, but feel free > to email me about it -- I'd love to hear your ideas. > > --- SER >