[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem with conditional parameter in call-templat
Hi Carlos, > I'm simplifying my xsl code and I faced a problem. I can't put > <xsl:choose> either <xsl:if> elements inside a <xsl:call-template> > so there is a parameter (the one called tipus) that should be > password when the name of the node is contrasenya and that should be > text when the node has another name. You can put any instructions you like in the content of xsl:with-param to set the value of the parameter. I'd do: <xsl:call-template name="entradaTexte"> <xsl:with-param name="id" select="@id" /> <xsl:with-param name="valor" select="valor" /> <xsl:with-param name="tipus"> <xsl:choose> <xsl:when test="name() = 'contrasenya'">password</xsl:when> <xsl:otherwise>text</xsl:otherwise> </xsl:choose> </xsl:with-param> </xsl:call-template> Note that I've used the select attribute to set the other parameters as it's shorter and passes in the nodes themselves rather than result tree fragments. If you wanted to save space on setting the $tipus parameter (and pass in a string rather than a result tree fragment) then you could use: <xsl:with-param name="tipus" select="substring('password text', 9 * not(name() = 'contrasenya') + 1, 8)" /> If the node whose name you're testing is an element (rather than an attribute), you should probably change the name() = 'contrasenya' to self::contrasenya as this is a more robust way of testing the type of the current node. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|