tags:

views:

42

answers:

1

I am trying to compare a value which was grabbed using the get method in a form and then passed into a xslt sheet. I named the string variable passed in browse. I want to check if the variable browse has a string value browse.

the code is below

<xsl:if test="$browse = 'browse' ">
        <A>
         <xsl:attribute name="href">searchPage.php?search=<xsl:value-of select="$search" />&amp;browseButton=Browse&amp;XML=Xml&amp;page=<xsl:value-of select="number($Page)-1"/>&amp;pagesize=<xsl:value-of select="$PageSize"/></xsl:attribute> &lt;&lt;Prev
        </A>
         </xsl:if>
A: 

What is the problem? Certainly the comparison is correct.

Here is a complete XSLT stylesheet demonstrating the correctness of your code:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

 <xsl:param name="browse" select="'browse'"/>
 <xsl:param name="search" select="'searchString'"/>
 <xsl:param name="Page" select="2"/>
 <xsl:param name="PageSize" select="60"/>

 <xsl:template match="/">
   <xsl:if test="$browse = 'browse' ">
        <A>
         <xsl:attribute name="href">searchPage.php?search=<xsl:value-of select="$search" />&amp;browseButton=Browse&amp;XML=Xml&amp;page=<xsl:value-of select="number($Page)-1"/>&amp;pagesize=<xsl:value-of select="$PageSize"/></xsl:attribute> &lt;&lt;Prev
        </A>
         </xsl:if>

 </xsl:template>
</xsl:stylesheet>

When this transformation is applied on any XML document (not used), the desired result is produced:

<A href="searchPage.php?search=searchString&amp;browseButton=Browse&amp;XML=Xml&amp;page=1&amp;pagesize=60"> &lt;&lt;Prev
        </A>
Dimitre Novatchev
Thanks for that, realized it was a simple spelling error
dbomb101