Subject: Re: [xsl] Problem with conditional parameter in call-template From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Tue, 4 Sep 2001 10:14:11 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem with conditional , Gavin Corfield | Thread | [xsl] document() path created from , Jeroen Janssen |
Re: [xsl] Generating namespace node, David Carlisle | Date | Re: [xsl] Generating namespace node, Francis Norton |
Month |