RE: [xsl] question about identity transform

Subject: RE: [xsl] question about identity transform
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 2 Nov 2006 16:31:15 -0000
> From a user's perspective, how is it helpful 
> to make a distinction between processing order and result 
> order? 
> I haven't implemented an XSLT processor, but when is this 
> distinction even useful, in practice?

It's useful to remember that there is a distinction in the case of a
stylesheet that has side-effects. For example, if you do this:

<xsl:for-each select="//in">
  <out pos="{position()}"/>
  <xsl:message select="[{position()}]"/>

then the result tree is guaranteed to contain 

<out pos="1"/><out pos="2"/><out pos="3"/><out pos="4"/>...

but the message output might be


Similarly, if you do

<xsl:for-each select="//in">
  <xsl:result-document href="x{position()}.xml">zzz</xsl:result-document>
  <xsl:if test="position() = 5">
  	<xsl:message terminate="yes">BANG</xsl:message>

then there is no guarantee that you have written documents x1, x2, x3, and
x4 when you stop; you might have written x12, x9, x3, and x7 (or any other
subset of the result you would have got without the "terminate").

Optimizers are gradually getting smarter, and the smarter they get, the more
likely it is that this kind of thing will hit you.

Michael Kay

Current Thread