Wednesday, April 29, 2009

Extra Characters in Concatenated XML String

I was attempting to concatenate two strings to form a new string. For some reason when I viewed the concatenated string there were extra characters between the concatenated values. The characters were tabs, carriage returns and spaces.

The value for the second part of the concatenated string was passed from a parent stylesheet to child template and then from child template to another child template. I am not quite sure why but some extra tabs and spaces got appended to the value as it was passed around. My xml file did not have any spaces or tabs around the value. I tried removing all the spaces and tabs around the with-param values and that didn't solve the problem either.

Well however those spaces got there I just wanted them to be gone so used the normalize-space XSL function which removed all the extraneous characters.

<xsl:value-of select="normalize-space(/little/suh-m/suh-m)"/>