Re: namespace node implementation

Per Bothner wrote:

> let $a := <a xmlns:ns1="NS1"><b ns1:x="X"/></a>
> let $c := <c xmlsns:ns2="NS2">{$a/b}</c>
> what is the result of get-in-scope-namespaces($c/b)?  It could be:
> [("ns2") or ("ns1") or: ]
> ("ns1", "ns2"):  Works but requires merging or copying, which is 
> difficult to do efficiently.  (It could be a high-frequency operation.)

Actually, I guess it wouldn't be difficult to return ("ns1", "ns2") by 
just adding the prefixes found in the ancestors of the copied <b> node.

What would be expensive is if after:

let $d := <d xmlsns:ns3="NS3">{$c/b}</d>

we want get-in-scope-namespaces($d/b) to return ("n1", "n2", "n3").
However, it would not be difficult to have get-in-scope-namespaces($d/b) 
return ("ns1", "ns3").

I.e. extend to my algorithm:

* Implement get-in-scope-namespaces by taking the union of the namespace 
prefixes of the namespace mappings of the argument node and all its 

This is more expensive that just using the namespace mapping of the 
argument node (without its ancestors), but its not a frequent operation.

It might also make sense to modify my algorithm to implement a 
"namespace mapping" using a linked list rather than a vector.
	--Per Bothner

Received on Wednesday, 22 October 2003 19:03:12 UTC