<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Expressing IT &#187; XSL:IF</title>
	<atom:link href="http://developer.expressionz.in/blogs/tag/xslif/feed/" rel="self" type="application/rss+xml" />
	<link>http://developer.expressionz.in/blogs</link>
	<description>User Interface : just another, but a serious developers weblog</description>
	<lastBuildDate>Thu, 20 May 2010 18:05:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Variety of XSL Test Conditions (Collection of XSL:IF and XSL:WHEN TEST Conditions)</title>
		<link>http://developer.expressionz.in/blogs/2008/09/14/a-variety-of-xsl-test-conditions-collection-of-xslif-and-xslwhen-test-conditions/</link>
		<comments>http://developer.expressionz.in/blogs/2008/09/14/a-variety-of-xsl-test-conditions-collection-of-xslif-and-xslwhen-test-conditions/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 07:11:46 +0000</pubDate>
		<dc:creator>Nikhil</dc:creator>
				<category><![CDATA[XSL]]></category>
		<category><![CDATA[XSL:IF]]></category>
		<category><![CDATA[XSL:WHEN]]></category>

		<guid isPermaLink="false">http://developer.expressionz.in/blogs/?p=34</guid>
		<description><![CDATA[
			
				
			
		
Every time I have to do a XSL:IF or XSL:WHEN test, I have go back to the reference books. I never seem to remember them. Thought there would be more out there, just like me, who would rather prefer to have all of them, possible, at one place, ready to be referred when needed.
For those [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdeveloper.expressionz.in%2Fblogs%2F2008%2F09%2F14%2Fa-variety-of-xsl-test-conditions-collection-of-xslif-and-xslwhen-test-conditions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdeveloper.expressionz.in%2Fblogs%2F2008%2F09%2F14%2Fa-variety-of-xsl-test-conditions-collection-of-xslif-and-xslwhen-test-conditions%2F&amp;source=nikhild&amp;style=normal&amp;hashtags=XSL%3AIF,XSL%3AWHEN" height="61" width="50" /><br />
			</a>
		</div>
<p>Every time I have to do a XSL:IF or XSL:WHEN test, I have go back to the reference books. I never seem to remember them. Thought there would be more out there, just like me, who would rather prefer to have all of them, possible, at one place, ready to be referred when needed.</p>
<p>For those who are new … Syntax for XSL:IF</p>
<blockquote><p>&lt;xsl:if test=&#8221;expression&#8221;&gt;<br />
&lt;!&#8211; Content: template &#8211;&gt;<br />
&lt;/xsl:if&gt;</p></blockquote>
<p><strong>The xsl:if/xsl:when Test Collection</strong><br />
The conditions below are all simple and self explanatory. So I believe it won’t need much explanation</p>
<blockquote><p>&lt;xsl:if test=&#8221;position()=last()-1&#8243;&gt;<br />
This if the last but one element in the list!<br />
&lt;/xsl:if&gt;</p>
<p>&lt;xsl:if test=&#8221;SALARY &gt; 5000&#8243;&gt;<br />
The salary of this person is greater than Rs. 5000<br />
&lt;/xsl:if&gt;</p>
<p>&lt;xsl:if test=&#8221;count(JOBS) &gt; 3&#8243;&gt;<br />
There are more than 3 jobs in this list!<br />
&lt;/xsl:if&gt;</p>
<p>&lt;xsl:if test=&#8221;(@DEPT = &#8216;SALES&#8217;) or (@JOINYEAR = &#8216;1997&#8242;)&#8221;&gt;<br />
       This person is from sales department OR his Year of Joining is 1997<br />
&lt;/xsl:if&gt;</p>
<p>&lt;xsl:if test=&#8221;EXPERIENCE&#8221;&gt;<br />
       This person have atleast one EXPERIENCE child element.<br />
&lt;/xsl:if&gt;</p>
<p>&lt;xsl:if test=&#8221;@HOBBY&#8221;&gt;<br />
    The person has a hobby attribute.<br />
&lt;/xsl:if&gt;</p></blockquote>
<p><strong>The same text conditions could be used for XSL:CHOOSE/XSL:WHEN as well</strong></p>
<h3>xsl:choose</h3>
<p>XSLT&#8217;s  xsl:choose instruction is similar to xsl:if but has a few key differences:<br />
• One xsl:choose element can test for more than one condition and add different nodes to the result tree based on which condition is true. <br />
• An xsl:choose element can have a default template to add to the result tree if none of the conditions are true. (Compare xsl:if, which has no equivalent of an &#8220;else&#8221; condition.)<br />
• The xsl:choose element has specific subelements that are necessary for it to work, while you can put any well-formed elements you want inside of an xsl:if element.</p>
<blockquote><p>&lt;xsl:choose&gt;<br />
&lt;xsl:when test=&#8221;boolean-expression&#8221;&gt;<br />
   Do something when this boolean-expression is TURE<br />
&lt;/xsl:when&gt;<br />
&lt;xsl:otherwise&gt; Do something else &lt;/xsl:otherwise&gt;<br />
&lt;/xsl:choose&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://developer.expressionz.in/blogs/2008/09/14/a-variety-of-xsl-test-conditions-collection-of-xslif-and-xslwhen-test-conditions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
