RE: Determining if an XSLT template has run

Another suggestion I received was: 
	<xsl:template match="/">
	    <xsl:choose>
	        <xsl:when test="//row">
	                <!-- this outputs the regular page -->
	        </xsl:when>
	        <xsl:otherwise>
	                <!-- this outputs a message saying nothing can be
output -->
	        </xsl:otherwise>
	    </xsl:choose>
	</xsl:template>

I am using ASP to set the contents of the brackets, and I will eventually
move to client-side JavaScript DOM. I would prefer to only change one part
of the stylesheet in script, but both of these suggestions require that I
change two different attributes' values: the when-test or variable-select
and the template-match. This is possible but inconvenient. It breaks the
theory of storing information in exactly one place.
I could probably use an entity reference, but this seems inelegant.
A way to fire if an <xsl:for-each> never runs would also be perfectly
acceptable.

-----Original Message-----
From: Sampo Syreeni [mailto:decoy@iki.fi]
Sent: Friday, March 30, 2001 7:06 AM
To: Jeffrey Yasskin
Cc: www-style@w3.org
Subject: Re: Determining if an XSLT template has run


On Thu, 29 Mar 2001, Jeffrey Yasskin wrote:

>	<xsl:template match="/">
>		<h1>Header</h1>
>		<xsl:apply-templates />
>		<xsl:if test="$fired">
>			NO RESULTS!!
>		</xsl:if>
>	</xsl:template>
>	<xsl:template match="row[lots-of-conditions]">
>		<xsl:variable name="fired" select="true">
>		<p>Stuff</p>
>	</xsl:template>

Try <xsl:variable name="fired" select="//row[lotsa-conditions]/> (or
something faster with a more explicit path, or with keys) at the top level
instead. You just need to worry about variable scoping. No need for new
features in XSLT.

Sampo Syreeni <decoy@iki.fi>, aka decoy, student/math/Helsinki university

Received on Friday, 30 March 2001 09:04:56 UTC