Re: [xsl] lightweight counterpart for collection()

Subject: Re: [xsl] lightweight counterpart for collection()
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: 20 Aug 2005 06:40:36 +0100
>>>>> "Manfred" == Manfred Staudinger <manfred.staudinger@xxxxxxxxx> writes:

    Manfred> Hi list, As I recently ran into storage problems with
    Manfred> collection() I would like to see a lightweight
    Manfred> counterpart with the following features:

The version you are requesting is not lightweight - on the contrary:

    Manfred> collection() for one directory - on invocation gets a
    Manfred> sequence (dir-seq) representing the documents in the
    Manfred> directory, the order determined by the full URI,
    Manfred> including the member-name

Firstly, there is no requirement for an implementation to provide a
mapping of URIs to a directory. An implementation is compliant if it
raises error FODC0004 for any URI passed to collection().

Requiring that the node sequence is returned in order (which order?),
makes the function more heavyweight - the implementation MUST perform
sorting - the function as specified in the draft avoids sorting - you
get the choice whether to sort or not.
If your desire is rather for conciseness, then you can wrap the call
to collection() in an xsl:function.

    Manfred> If the function is called
    Manfred> again, it reuses the dir-seq.  - each document is fetched
    Manfred> only once from directory when it is referenced for the
    Manfred> first time.

I suspect this is already a requirement of the specification - it says
the function is stable, but does not further specify what this means
(unlike for fn:doc(), where it is explicit).

    Manfred> It will be discarded automatically if an
    Manfred> other document from the same dir-seq is referenced and it
    Manfred> will not be re-fetched later on.

This would cause subtle errors in transformations, because execution order
is not proscribed.
So a later occurring call to fn:doc() for one of the documents in the
collection would have to fail, contradicting the specification for
fn:doc - e,g.:

if during the execution of a transformation , the following events
occurred:

fn:doc (uri-A)
fn:manfred-collection (uri-B)
fn:doc (uri-A)

and uri-A maps to one of the documents in the collection mapped by
uri-B, then you have a contradiction between the requirements of
fn:doc (the nodes returned by the two calls are identical) and your requirement.

-- 
Colin Adams
Preston Lancashire

Current Thread