Jump to content

choose


patrivet

Recommended Posts

Hi there,I am using the "choose" function for the first time and not encountering what I expected yet.Here is what I am doing:-

	 <xsl:variable name="myString" select="//whatever"/>	 <xsl:variable name="myNumber"/>	<xsl:choose>		   <xsl:when test="$myString = 'myName'">			<xsl:variable name="myNumber" select="1"/>		   </xsl:when>		</xsl:choose>

The "myNumber" variable is remaining null even though a match is found, so either the assignment is not working (my syntax error), or the test constraint is wrongly specified.Thanks

Link to comment
Share on other sites

your variable is out of scope. Try this: <xsl:variable name="myString" select="//whatever"/> <xsl:variable name="myNumber"> <xsl:choose> <xsl:when test="$myString = 'myName'"> <xsl:text>1</xsl:text> </xsl:when> </xsl:choose></xsl:variable>

Link to comment
Share on other sites

..or with a select attribute. Yes.And variables can't take new values. Parameters can, but only on template basis. That is, when you call a template or apply it, you can use xsl:with-param to assign a new value to a parameter in it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...