Jump to content

How can i use IF and VARIABLE


Guest vogash
 Share

Recommended Posts

Guest vogash

Hi all,I need some help...I don't know how can i use IF and VARIABLE together..I have this code<xsl:if test="MyTest/Request/@category[.=All]"> <Test id="1111" name="Box"/> <Test id="1111" name="Golf"/></xsl:if>and it's worksbut i want to use variable in IF that containts this path MyTest/Request/@category and use every time in IF, because i have many IF'sI tried to use this:<xsl:variable name="CategoryPath" select="MyTest/Request/@category'"/><xsl:if test="$CategoryPath[.=All]"> <Test id="1111" name="Box"/> <Test id="1111" name="Golf"/></xsl:if>but it is not work :) anybody know answer for this question...?

Link to comment
Share on other sites

Did you tryied something like:

<xsl:variable name="CategoryPath">MyTest/Request/@category</xsl:variable>

Let me explain... What the select statement does is to apply the path, so the result is the actual thing in the path, not the path itself. So to store the path itself, it's necessary to open the variable and store plain text in it, which would actually be the path.Note I haven't tryed this myself, so I have no idea if it would work. If it doesn't, try using

<xsl:param name="CategoryPath">MyTest/Request/@category</xsl:param>

Or maybe calling the variable/parameter with something like this:

<xsl:if test="{string($CategoryPath)}[.='All']">

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...