Avatar of mr_stevie
Flag for Australia

asked on 

Joining strings/variables in XSLT/Xpath

Hello EE,

I've been looking everywhere but I can't seem to find an answer (maybe I'm not looking hard enough... :()

Anyways, I have an XML document of addresses that I import and extract the variables like the following:

<xsl:variable name="StreetNo" select="Address/StreetNo"/> 
<xsl:variable name="Street" select="Address/Street"/> 
<xsl:variable name="Suburb" select="Address/Suburb"/> 
<xsl:variable name="State" select="Address/State"/> 
<xsl:variable name="Postcode" select="Address/Postcode"/>

Open in new window

I have to join all the variables into one string into a new variable "NewAddress" like the following:

<xsl:variable name="NewAddress" select="$StreetNo + ' ' + $Street + ' ' + $Suburb + ', ' + $State + ' ' + $Postcode"/>

Open in new window

I want it so it'll print a string like "123 Smith Street Sydney, New South Wales 2000".

I'm not getting the right output and it's returning as "NaN". I'm pretty sure the "+" only works with numbers and using a "." doesn't seem to work either.

Hope this makes sense. Can anyone help me with this?

Thank you very much in advance.
Web Languages and StandardsScripting LanguagesWeb Development

Avatar of undefined
Last Comment
David Johnson, CD

8/22/2022 - Mon