RE: TR/xquery-operators/#func-doc

> http://www.w3.org/TR/xslt20/ 16.1 seems to half answer this,
> or contradict it.
> 
> quote. The effect of these rules is that unless XML entities 
> or xml:base are used, document("") refers to the document 
> node of the containing stylesheet module. The XML resource 
> containing the stylesheet module is processed exactly as if 
> it were any other XML document, for example there is no 
> special recognition of xsl:text elements, and no special 
> treatment of comments and processing instructions. unquote.
> 
> Impact on users:
>   If I want to use xml:base, I can't access the filesheet 
> using document("")?
> 
> I find this unacceptable. 
> Many people utilise data within the stylesheet as a lookup.
>

I think you are misunderstanding the way this worked in XSLT 1.0. There was
never any special handling of document(""). It worked because "" is a legal
relative URI, which was resolved relative to the base URI of the stylesheet,
and would therefore retrieve the XML entity containing the call on
document(""). This was a happy consequence of the specification, which was
mentioned in a note, though the note unfortunately failed to mention that it
only worked if the call was contained in the document entity of the
stylesheet module. In XSLT 2.0 we now support xml:base; xml:base changes the
meanings of relative URIs in a document, including the meaning of the
relative URI "". It's reasonable that the spec should warn you of this.
> 
> 
> 2. Is there another out of sync issue here?
> xslt 2 says:
> 
> document($uri-sequence as item()*, $base-node as node()) as node()*
> 
> which is missing from the former reference?
> 

By "the former reference" do you mean the fn:doc() function in Functions and
Operators? This doesn't have a second argument, because it doesn't need one.
There is now a function fn:resolve-uri() that allows you to resolve relative
URIs against absolute URIs in any way you choose; this is far more flexible
than the limited capabilities of the old document() function, so there is no
need to carry these capabilities forward into the new fn:doc() function.

The equivalent of:

   fn:document(concat(@a, '.xml'), @a)

using the new function is:

   fn:doc(resolve-uri(concat(@a, '.xml'), base-uri(@a)))

(This might be longer, but in my experience the second argument of
document() is very rarely used).

Michael Kay

Received on Monday, 12 May 2003 22:40:44 UTC