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 April 4th, 2006, 04:15 PM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL Variable Contains...

I am kind of familiar with xsl: choose and xsl: when but how do properly format my code when I want to perform one action if the value of a variable contains a certain string (such as subdomain.mydomain.com) and another action when it does not.

I am new to XSL so please excuse my rather basic question.

Thanks.

Al Dugan
www.atomicpark.com
__________________
Al Dugan
www.atomicpark.com
 
Old April 4th, 2006, 05:17 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Something like this:

<xsl:choose>
  <xsl:when test="$var = 'subdomain.mydomain.com'">
    <xsl:call-template name="one.action"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:call-template name="another.action"/>
  </xsl:otherwise>
</xsl:choose>

Unless by "contains" you mean "contains as a substring", in which case change the test to contains($var, 'subdomain.mydomain.com').

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 5th, 2006, 10:02 AM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Unless by "contains" you mean "contains as a substring", in which case change the test to contains($var, 'subdomain.mydomain.com')
Thank you Michael, that is what I meant and it works perfectly.

Al Dugan
www.atomicpark.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
xsl:variable holding name of an xsl:param perissos XSLT 0 December 5th, 2006 07:09 AM
The difference between xsl:variable and xsl:param NEO1976 XML 2 July 24th, 2006 06:05 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
xsl variable in xsl tag? di98svpa XSLT 1 February 10th, 2006 01:41 PM





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