Constructing strings

5 views
Skip to first unread message

DrPantos

unread,
Nov 1, 2011, 7:13:28 AM11/1/11
to XSLT
Hi,
I want to know the best way on concatenating string for an element
values. I usually end up using lots of xsl:value-of s because I know
it works but it's very verbose and difficult to read. I'm sure that I
could do most/all things with on value-of but I'm not what I need to
be careful about.

Sadly i'm currently stuck with xslt 1.1. It may change in the future
but I don't have time to sort it out at the moment so please don't say
I should be using some 2.0 feature.

I tend to have things which look a little like this:

<name><xsl:value-of select="$someComputedVariable"/>-<xsl:value-of
select="someElement"/> <xsl:value-of select="someOtherElement/@attr"/
></name>

Also how would I put a space instead of a - in this element, i've
found that all the spaces are stripped.

Thanks for your help,
Stefan

Christian Wahl

unread,
Nov 3, 2011, 4:02:43 PM11/3/11
to xs...@googlegroups.com
Hi Stefan

What about the xpath function concat()?
<name><xsl:value-of select="concat($someComputedVariable,someElement,someOtherElement/@attr)"/></name>
Reply all
Reply to author
Forward
0 new messages