RE: Base URI as used by document

> > Possibly. But it's the normal convention on the web that 
> when one file 
> > contains a reference to another, the reference is considered to be 
> > relative to the file in which the reference was contained.
> 
> But it is *not* the source file that contains the reference. 
> The filename is an expression that is calculated at run-time. 
> And the normal convention for when a filename is calculated 
> at run-time, then the reference is relative to the current 
> *run-time* context (directory).

The spec for the document() function distinguishes the case where the
argument is a string from the case where it is a node. In the first case,
the base URI is taken from the static context, in the second case, it is the
base URI of the node containing the relative URI. The first case is designed
primarily for the situation where the value is a string literal. In the case
of a computed string, you can select an alternative base URI by supplying
the second parameter to the document() function. This, I think, was designed
to enable you to supply a run-time base URI. Perhaps the spec should be
refined so that the second argument is also allowed to be a string, rather
than necessarily a node.
> 
> Which of course is difficult because there is no convenient 
> way for an application to get an absolute url from the 
> execution environment - i.e. no way reasonable way to get a 
> string parameter from the environment.  I suggested way to do 
> that in the posting "Variable Declaration in Query Prolog" 
> from March 
>
(http://lists.w3.org/Archives/Public/www-xml-query-comments/2002Mar/0007.htm
l).
> I was disappointed to not get a response of this, since I think this is an
essential 
> feature for practical use of XQuery.

I think there is a good argument for allowing a query to take parameters, in
the same way as stylesheets can. On the other hand, there is an alternative
argument that a query with parameters is no different from a function, and
if you want this capability the right way to provide it is to allow the API
to invoke an XQuery function directly.

Michael Kay

Received on Monday, 20 May 2002 09:18:23 UTC