Check URL for a '?' using XSLT

Hi,
We use an XSLT/XML transformation to build sections of our page, and for some of the links we append parameters on the fly in the XSLT. However, there are instances where the link will already contain a '?' therefore instead of appending '?param=param' as default we need to append '&param=param'.

Is there a straightforward way of detecting whether a question mark exists in the URL?

Thanks
Al4ddin2Asked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
use the contains() function

contains(url, '?') returns a boolean

something like this
<xsl:choose>
<xsl:when test="contains(url, '?')">
<xsl:value-of select="url"/>
<xsl:text>&amp;param=param</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="url"/>
<xsl:text>?param=param</xsl:text>
...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.