RE: [xsl] null call of document function

Subject: RE: [xsl] null call of document function
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 7 Apr 2007 13:43:01 +0100
> What if I want to make a call to the document() function but 
> I don't expect any value?

That presumably means you expect the call to have side-effects.

A call on the document function is analagous to an HTTP GET request, and
it's considered bad form for GET requests to have side effects:

http://www.w3.org/2001/tag/doc/whenToUseGet.html

At the XSLT level, calling document() and expecting side-effects has all the
problems associated with extensions functions that have side effects,
notably that the call is liable to be optimized away if the result isn't
used. In fact it's worse than extension functions, because:

(a) with extension functions, the optimizer might if you're lucky take into
account the possibility that the call has side-effects; with the document()
function this is unlikely

(b) the semantics of the document() function essentially say that if you
make the same call twice with the same URI, it only gets executed once.

In short - don't do it.

Michael Kay
http://www.saxonica.com/

Current Thread