Re: [xsl] the fastest way to test if variable is empty

Subject: Re: [xsl] the fastest way to test if variable is empty
From: Dusan Zatkovsky <zatkovsky@xxxxxxxxxxxx>
Date: Thu, 9 Dec 2004 09:32:48 +0100
Ok, here is example structure of code and why I use it:

At first, my old implementation does something like:

<xsl:variable name="mayContinue">
	<xsl:choose>
		<xsl:when 
test="some_big_test_over_big_xml_trees_which_was_very_slow">1</xsl:when>
		<xsl:otherwise>0</xsl:otherwise>
	</xsl:choose>

	<xsl:if test="$mayContinue=1">

		<xsl:if test="other_big_test_to_check_if_something_will_be_processed">
			<!-- print header -->
			<!-- process data and generate output -->
			<!-- print bottom -->
		</xsl:if>

	</xsl:if>


but test other_big_test_to_check_if_something_will_be_processed was very slow. 
Much faster it is like this:


.....
	<xsl:if test="$mayContinue=1">
		<xsl:variable name="processOutput">
			<!-- process data and generate output -->
		</xsl:variable>

		<xsl:if test="string-length($processOutput)!=0">
			<!-- print header -->
			<xsl:value-of select="$processOutput"/>
			<!-- print bottom -->
		</xsl:if>

	</xsl:if>

But I am afraid that when $processOutput will be too big (for example 100000 
lines of text output), test for it's string-length may be slow.


I will test it.

Thanks



-- 


S pozdravom,
Dusan Zatkovsky

Current Thread