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 September 27th, 2005, 04:19 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Wildcards?

Does XSLT use wildcards? I'm trying to use an external XML feed, but unfortunately one of the values contains a space before and a space after the needed value.

So if the XML feed contains this data:
Code:
<xmlfeed>
    <value> yada </value>
</xmlfeed>
...and I have an XSLT stylesheet to compare that value to an internal value, like this:
Code:
<xsl:if test="$rssfeed/xmlfeed/value = '*yada*'">
    <strong>Current Status: </strong><xsl:value-of select="$rssfeed/xmlfeed/value" />
</xsl:if>
Is there a way to use a wildcard around the value in XSLT? Thanks for any help.

KWilliams
 
Old September 28th, 2005, 10:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You have at least two options, if it's always spaces then use normalize-space function which strips leading and trailing whitespace and compresses whitespace in the middle to single occurrences:
Code:
test="normalize-space($rssfeed/xmlfeed/value) = 'yada'"
If it can be other characters then use the contains function.
Code:
test="contains($rssfeed/xmlfeed/value, 'yada')"
--

Joe
 
Old September 28th, 2005, 10:54 AM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What a GREAT reply. Thanks so much for the 2 options, and the quick reply! It worked great.

KWilliams





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable the wildcards(% and _) kasipandian Oracle 1 February 4th, 2008 12:32 AM
ObjectDataSource and Wildcards pipelineconsulting ASP.NET 2.0 Professional 1 October 19th, 2006 09:08 PM
Datetime, wildcards etc SoC Classic ASP Basics 6 July 19th, 2005 08:53 PM
Using wildcards in subquery hman SQL Language 2 April 11th, 2005 06:18 AM
Help using wildcards in query hman SQL Language 2 April 6th, 2005 03:40 AM





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