xsl variable is not working in xsl choose

413 Views Asked by At

This "$PAGE_SCOPE[title]" will display the title of the page i want to display different headlines based on the title so i am trying to get the page title in a variable, this variable is displaying the title in the paragraph tag but it's not working in the when loop.

<xsl:variable name="PageTitle" select="'$PAGE_SCOPE[title]'" />
<xsl:variable name="test"><xsl:value-of select="$PageTitle" /></xsl:variable>
<p><xsl:value-of select="$test" /></p>

<xsl:choose>
<xsl:when test="$test='RAQ'">
    <h1 class="h3"><strong>.....</strong></h1>
</xsl:when>

<xsl:otherwise>
    <h1 class="h3"><strong>Error</strong></h1>
</xsl:otherwise>
</xsl:choose>

any pointers would be helpful.

1

There are 1 best solutions below

0
lesthaeghet On

Assuming that $PAGE_SCOPE[title] works and does what it's supposed to normally (the quote marks above are kind of strange), is this actually returning an element? If it's returning a string value, then this should be working, but if the value of your variable is actually a node, then this would likely explain your issue.

Try using string($test) for your comparison instead. Also, you might consider adding a normalize-space() just to make sure you don't have any white space that's shown up unexpectedly.