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 May 2nd, 2014, 04:27 AM
Registered User
Join Date: May 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Compare value of an xml node with a String using xsl : if

Dear Experts,

I have an xml file with the following structure :


My requirement is : whenever the value of <ProfitCenterCode> equals the String "Total"
I want to call a styleID which will make my BalanceYTD value print in bold in an excel sheet.

To achieve this, I have written a code , but it does not seem to work. Can you please advise:

<xsl:for-each select="//YTD">
<xsl:if test="ProfitCenterCode=Total">
<Cell ss:StyleID="sMAKETOTALBOLD">
<Data ss:Type="Number"><xsl:value-of select="BalanceCarryFwd"></xsl:value-of></Data> </Cell>
Old May 2nd, 2014, 05:40 AM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

ProfitCenterCode=Total compares an element called ProfitCenterCode against an element called Total, which obviously doesn't exist. Strings should be enclosed in quotes:

/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a node to an existing xml node list. codehelp C# 2008 aka C# 3.0 2 October 12th, 2009 07:41 AM
Compare current value with previous parent node ratjetoes XSLT 2 July 17th, 2008 06:15 AM
XSLT Help to get value from Upper Node by compare pixelheart XSLT 10 May 1st, 2008 12:25 PM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM

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