XSLT: If check parameter value -


following code in xslt (i've cut out irrelevant parts, get-textblock lot longer , has lot of parameters passed correctly):

<xsl:template name="get-textblock">         <xsl:param name="style"/>          <xsl:element name="border">                      <xsl:if test="$style='{staticresource labeltext}'" >                 <xsl:attribute name="background">#ff3b596e</xsl:attribute>             </xsl:if>             <xsl:attribute name="background">#ff3b5940</xsl:attribute>                       </xsl:element>  </xsl:template> 

the style parameter can either '{staticresource labeltext}' or '{staticresource valuetext}' , background of border depends on value.

this if structure fails however, draws ff3b5940 border in output.xaml file. call template this:

<xsl:call-template name="get-textblock">     <xsl:with-param name="style">{staticresource labeltext}</xsl:with-param>                     </xsl:call-template> 

anyone sees might problem? thanks.

the line:

<xsl:attribute name="background">#ff3b5940</xsl:attribute> 

is not protected conditional check, execute.

use this:

<xsl:if test="$style='{staticresource labeltext}'">     <xsl:attribute name="background">#ff3b596e</xsl:attribute> </xsl:if> <xsl:if test="not($style='{staticresource labeltext}')">     <xsl:attribute name="background">#ff3b5940</xsl:attribute> </xsl:if> 

or xsl:choose

<xsl:choose>     <xsl:when test="$style='{staticresource labeltext}'">         <xsl:attribute name="background">#ff3b596e</xsl:attribute>     </xsl:when>     <xsl:otherwise>         <xsl:attribute name="background">#ff3b5940</xsl:attribute>     </xsl:otherwise> </xsl:choose> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -