Re: References in XPath that can be represented by a string andstill can be garbage collected

"Michael Kay" <[email protected]> Thu, 18 Dec 2008 16:27:45 -0000
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <BD1A0535849947538369281B77A7A8F1@Sealion>
 
> > 
> > Given a node $N whose string-reference happens to be 
> 'n123', if you do
> > 
> > String $S = ref(RM, $N);
> > Node $M = deref(RM, 'n123');
> > 
> > you will get $M set to the node $N; but if you do the two 
> instructions 
> > the other way round, $M will be null. That is, the result 
> depends on 
> > order of evaluation. As I said, I'm not sure this is 
> serious, because 
> > if you call
> > deref() with a string that wasn't obtained from the RM, the results 
> > are undefined anyway. But it's a warning signal that 
> indicates we need 
> > to be very careful.
> 
> What is the problem?
> 
> Getting a null when trying to access a Ref by an non-existing 
> key is... the right thing !

I seem to be having trouble explaining this. The problem is that the result
of the expression

(ref($RM, $N), deref(RM, 'n123'))

depends on the order of evaluation of the two subexpressions.

Michael Kay
http://www.saxonica.com/