Re: About node references

Dimitre Novatchev <[email protected]> Mon, 15 Dec 2008 12:27:37 -0800 (PST)
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <[email protected]>
> 
> That gives us three functions perhaps:
> 
> ref(item()*) -> x:ref  creates(*) a reference that points to a sequence
> 
> deref(ref) -> item()*  returns the sequence that the reference points to
> 
> flatten(item()*) -> item()* applies deref recursively to all items in a
> sequence that are references until the sequence contains no references;
> reports a dynamic error if the sequence contains circular references
> (otherwise this would never terminate).

What use case do we have for flatten()? It seems that just using deref() is sufficient and also there might be cases when flattening a sequence and processing it may have different results than when processing and dereferencing on the go.


I would like to add the function I already proposed:

   string refCopy(ref)

which is to be used any time we want to copy/save a ref. Dereferencing a copied/saved ref will be guaranteed to be successful only for strings obtained from refCopy(). This eliminates the "leakage" problem.


To summarize, we will have four functions:

   ref(item()*) -> x:ref  creates(*) a reference that points to a sequence
 
   deref(ref) -> item()*  returns the sequence that the reference points to

   string refCopy(ref)   Dereferencing a copied/saved ref will be guaranteed to be successful only for strings obtained from refCopy(). This eliminates the "leakage" problem

    flatten(item()*) -> item()* applies deref recursively to all items in a
 sequence that are references until the sequence contains no references;
 reports a dynamic error if the sequence contains circular references
 (otherwise this would never terminate).



Cheers,
Dimitre