[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Multiple expressions in if conditons

Subject: Re: Multiple expressions in if conditons
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 16 Feb 2007 15:36:43 +0100
Re:  Multiple expressions in if conditons
Thangavelu Srinivasan wrote:

<xsl:for-each select="//*">

There is hardly ever a reason to use that statement. In all-but-one scenario's you can replace it with:


..before..
<xsl:apply-templates select="//*" />
..after..

<xsl:template match="*" >
 ...code here ..
</xsl:template>

Of course, depending on context node, //* may not be desirable at all (it is a very expensive instruction that should be avoided). Every beginner book or tutorial on XSLT should point you to how to use matching templates.


<xsl:variable name="code" select="name()" />

Make sure you understand the differences between using name() and local-name(). This involves understanding namespaces. It is a tricky subject, but once you get the hang of it, it will work to your advantages. Again, I recommend any good text book or online tutorial.


<xsl:variable name="value" select="." />
<xsl:if test= "$code != ('state_results') or ('game_results')">

This is considered 'evil' code (apart from the obvious error). You can do this, of course, but it is far from extensible and hardly ever necessary. See above. Instead, write this for each node you want to match:


<xsl:template match="not(state_results | game_results)" >
  ... your code ...
</xsl:template>


I am not able to test multiple value using if condition. i want to confirm whether my if conditon is correct for checking multiple value

You can, by joining with 'or'. But, as with any computer language, you must complete your expression.


$code != 'state_results' or $code != 'game_results'

which, by the way, will likely not do what you want: it is always true.

Good luck with learning XSLT. Please read a tutorial, it will save you tons of time. XSLT is not a language like you are likely to be accustomed with, and a tutorial should help you putting on the different pair of glasses needed to work productively and without too many hair-tearing situations ;)

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.