Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 29th, 2006, 02:38 AM
Authorized User
Join Date: Dec 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ramesh.kumarm
Default Check two string values on a single variable??

<xsl:variable name="temp1">
  <xsl:value-of select="local-name()"/>

Need to check the variable $temp1 for values 'RefNum' OR 'Qualifier'

I tried this...but this throws an illegal expression.
<xsl:if test=" $temp1 = 'RefNum' | 'Qualifier'">

i also tried
<xsl:if test=" $temp1 = conatins('RefNum','Qualifier')">

Still nogo

Kindly advice.

\"Always Look For Something NEW\"
Old June 29th, 2006, 02:48 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

Never write this:

<xsl:variable name="temp1">
  <xsl:value-of select="local-name()"/>

when you mean this:

<xsl:variable name="temp1" select="local-name()"/>

unless you're paid for the number of lines of code you write and don't care about efficiency. The former construct is creating a result tree fragment - a pretty complex data structure with all sorts of properties like node identity, base URI, etc - when all you want is a string.

To answer your question, a lot of people seem to have trouble finding this in the specs and I've never understood why. The syntax is

<xsl:if test="$temp = 'a' or $temp = 'b'">...

In 2.0, if you prefer, you can write

<xsl:if test="$temp = ('a', 'b')">

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Old June 29th, 2006, 03:29 AM
Authorized User
Join Date: Dec 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ramesh.kumarm

thanx a lot man.
It worked out.

Thanx again for your time.

Similar Threads
Thread Thread Starter Forum Replies Last Post
concat multiple column values into single col sirf_vs Reporting Services 8 May 29th, 2008 09:16 AM
Need to print a string value in a single line simmy_tj BOOK: Beginning Java 2 1 February 13th, 2007 06:36 AM
how to return string value with quotes (single or tllcll BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 November 10th, 2005 01:57 PM
How to store single value in variable? sacred21 Classic ASP Basics 1 December 29th, 2004 05:25 AM
Trying to send SQL results to a single variable NathanielMc VB Databases Basics 9 June 3rd, 2004 02:36 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.