[Bug 3173] [F+O, DM] A difficulty with document-uri()

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3173





------- Comment #5 from mike@saxonica.com  2006-06-16 11:06 -------
I was actioned to propose a way forward on this bug (Action A-301-01). My
proposal is as follows. 

PROPOSAL

1. In F+O section 2.6, replace

<old>
If fn:document-uri($arg) does not return the empty sequence, then the following
expression always holds:

fn:doc(fn:document-uri($arg)) is $arg
</old>

by:

<new>
In the case of a document node $doc that was obtained as the result of calling
the fn:doc function, provided that the user has not chosen to relax the
requirements for _stable_ evaluation, then the following expression always
holds:

fn:doc(fn:document-uri($doc)) is $doc

In the case of document nodes obtained by other means, for example documents
passed as parameters to a query or stylesheet, or documents returned by the
fn:collection function, there is no such guarantee. For example, there is
nothing to prevent two query or stylesheet parameters having as their values
two distinct documents that share the same document URI (they could perhaps
represent two different states of the same resource at different points in
time).
</new>

2. In XPath/XQuery 2.1.2, under the definition of "available documents" in the
dynamic context, add the Note:

<note>If available documents maps one or more strings to a document D, then the
_document-uri_ accessor applied to D must return one of those strings.</note>

RATIONALE

The changes are as follows:

(a) we remove the constraint that doc(document-uri($doc)) returns $doc except
in the case where $doc was originally obtained as the result of calling doc().
It's not generally possible to enforce this constraint in the case of documents
supplied as external parameters to a query, without defining additional
difficult-to-specify rules, for example that document-uris must be unique
within the scope of a query/transformation.

(b) we link the constraint to the rules on stable execution, so that the
constraint is not enforced if stability has been relaxed

(c) the residual rule for document-uri() in F+O still implies a constraint on
the "available documents" mapping in the dynamic context, and this constraint
is now documented where it belongs. It is phrased in such a way as to avoid
imposing any further constraints, for example it is still possible to have two
URIs that map to the same document, and it is still possible to have a document
with a document URI that is not present in "available documents".

(d) We could extend the constraint to apply also to documents loaded using the
collection() function. I chose not to do so, on balance, in order to allow
maximum freedom to implementors of collection(). For example, I can envisage an
implementation of collection() in which the sequence of documents is
constructed algorithmically, in which case it might be difficult to make the
same documents individually accessible using doc().

Michael Kay 

Received on Friday, 16 June 2006 11:06:31 UTC