Re: Extension candidates

John Snelson <[email protected]> Fri, 12 Dec 2008 10:48:37 +0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <[email protected]>
Dimitre Novatchev wrote:
> On Thu, Dec 11, 2008 at 12:06 PM, Michael Kay <[email protected]> wrote:
>>>> * xx:node-ref() - for any node produce a value, which can be
>>>>   used to obtain this node (node reference)
>>>> * xx:node-from-ref() - navigate to (select) a node from its node
>>>>   reference
>>>   By "value," do you mean "atomic value"?  I am not sure to
>>> see exactly the purpose, would you have a sample use case?
>> There's been a fair bit of discussion of such functions on the XQuery WG
>> mailing list in the last few weeks.
>> Some people wanted the ref to take a
>> form of a string or URI so it could be stored in a document. Some wanted
>> ref() to be synonmous with generate-id(). Some wanted it to be a ref() to
>> any value (sequence), not necessarily just a node. A big difficulty is the
>> interaction with garbage collection. There are two conflicting requirements
>> - the reference should be a string, so you can store it in a document; but
>> the node should continue to exist so long as the reference exists. Basically
>> these two requirements come from different use cases, and I think they might
>> need different facilities.
> 
> These two requirements are not conflicting. I imagine an
> implementation where references are stored in a hash table, where the
> string is the key and the actual reference is the value.

The problem is, when can the implementation garbage collect the 
documents stored in the hash values? It would need to prove that no one 
was going to be trying to dereference a particular key - but since the 
keys are just strings (can be copied, concatenated, embedded in XML and 
extracted etc.) it's impossible to prove this. Therefore this approach 
basically represents a big memory leak.

Let me ask a question that no one on the XQuery WG has yet been able to 
answer compellingly: why do you need node references if you have 
sequences of sequences (or some other more complex structure)?

John

-- 
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:            http://oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net