W3C home > Mailing lists > Public > www-ql@w3.org > October to December 2003

Re: namespace node implementation

From: Per Bothner <per@bothner.com>
Date: Tue, 21 Oct 2003 16:18:46 -0700
Message-ID: <3F95BED6.70503@bothner.com>
To: james anderson <james.anderson@setf.de>
Cc: www-ql@w3.org

james anderson wrote:

> 
> On Tuesday, Oct 21, 2003, at 21:15 Europe/Berlin, Per Bothner wrote:
>> I don't know what "first-class names" refers to, so I don't know if 
>> I'm not thinking about it ...
> 
> 
> "first class" in the standard sense: data which can be passed, bound, 
> and returned.

Yes, but how are your "first class names" different from QNames, which 
can be passed, bound, and returned in XQuery?

Btw, QNames in Qexo are implmented using a class called Symbol, which is 
also used for the JEmacs (Emacs Lisp) and (embryonic) Common Lisp 
implementations that are also part of Kawa.  So I am quite familiar with 
first-class names.

Your implementation is of course a very natural one when using Common 
Lisp.  However, it is not particularly space-efficient one, since you 
appear to use a CLOS object for each node.  (This is similar to using 
DOM, of course.)  I'm aiming for a much more space-efficient implementation.

Also note that XQuery requires that $b and $c/b must be two *different* 
nodes.  Specifically, the parent of $b is $a, while the parent of $c/b 
is $c.  Conceptually you must copy the $b node when evaluating 
<c>{$b}</c>.  That means that if $b and hence $c/b has a sub-element 
that uses the ns1 prefix, you can't find it by looking up the parent 
chain to get to $a.

 > inscope-namespaces($B)
 >  -> (#<NS-NODE ns2 -> NS2 #x12B1956> #<NS-NODE ns3 -> NS3 #x12C3B2E>)

I don't think this is acceptable.

What you've left out is what algorithm write-node uses to select where 
to put the namespace attributes.  My guess is that when it prints an 
element that uses a namespace prefix that it hasn't yet printed a 
definition for then it searches up the parent links for a matching 
binding in the namespaces slot.  Is that correct?

That works, but consider:
   let $a := <a xmlns:ns1="NS1"><b><ns1:bx/><ns1:by/></b></a>
   return $a/b

This can print as either:
   <b xmlns:ns1="NS1"><ns1:bx/><ns1:by/></b>
or:
   <b><ns1:bx xmlns:ns1="NS1"/><ns1:by xmlns:ns1="NS1"/></b>
Both are valid, but I would much prefer the former.  My algorithm does 
that.  I think it would be difficult for your algorithm to do that 
without an extra pass.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Received on Tuesday, 21 October 2003 19:21:35 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:16 UTC