patrivet Posted July 30, 2007 Share Posted July 30, 2007 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 More sharing options...
aalbetski Posted July 30, 2007 Share Posted July 30, 2007 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 More sharing options...
patrivet Posted July 31, 2007 Author Share Posted July 31, 2007 Thanks. So if I understood correctly, variable value assignment in XSLT has to be done within it's creation tag? Link to comment Share on other sites More sharing options...
boen_robot Posted July 31, 2007 Share Posted July 31, 2007 ..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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.