troubleshooting Question

How to concatenate 3 variables with a single space between each of them in XSL?

Avatar of ipjyo
ipjyoFlag for United States of America asked on
Web Languages and Standards.NET Programming
4 Comments1 Solution330 ViewsLast Modified:
In my XSL, I have 3 variables populating first, middle and last names from an xml document.
I need to concatenate these 3 variables with a space between first and middle name and another space between middle and last name.
With my code as shown below, I will have 2 spaces between first name and last name if middle name does not have a value (null).
Could anybody tell me how to make sure there will always be one space between names?
Thanks for any suggestions!

<xsl:variable name="FirstNm" select="Record/Name.First" />
<xsl:variable name="MiddleNm" select="Record/Name.Middle" />
<xsl:variable name="LastNm" select="Record/Name.LastOrBusiness" />
<xsl:variable name="FullNm" select="concat($FirstNm, $SPACES1, $MiddleNm, $SPACES1, $LastNm)" />
<xsl:value-of select="$FullNm" />
Gertone (Geert Bormans)
Information Architect
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros