Subject: RE: several questions on XML to HTML processing with XSL From: "Albert, Kevin" <kjalbert@xxxxxxxxxxxxxxxxxxxxx> Date: Tue, 13 Jun 2000 12:04:14 -0400 |
I thought it would be nice to do something like this, but I couldn't get it to work (does anybody know if a construct like this is possible): <xsl:variable name="ParamName">param2</xsl:variable> <xsl:template match="blah_blah"> <xsl:call-template name="SomeTemplateName"> <xsl:with-param> <xsl:attribute name="name"> <xsl:value-of select="$ParamName"/> </xsl:attribute> </xsl:with-param> </xsl:call-template> </xsl:template> Anyway, maybe this is not the best solution but it will do what you want: <xsl:variable name="ParamName">param2</xsl:variable> <xsl:template match="blah_blah"> <xsl:if test="$ParamName='param1'"> <xsl:call-template name="SomeTemplateName"> <xsl:with-param name="param1">false</xsl:with-param> </xsl:call-template> </xsl:if> <xsl:if test="$ParamName='param2'"> <xsl:call-template name="SomeTemplateName"> <xsl:with-param name="param2">false</xsl:with-param> </xsl:call-template> </xsl:if> <xsl:if test="$ParamName='param3'"> <xsl:call-template name="SomeTemplateName"> <xsl:with-param name="param3">false</xsl:with-param> </xsl:call-template> </xsl:if> <xsl:if test="$ParamName='param4'"> <xsl:call-template name="SomeTemplateName"> <xsl:with-param name="param4">false</xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> Regards, Kevin Albert -----Original Message----- From: H.vanderLinden@xxxxxxxxxxxxx [mailto:H.vanderLinden@xxxxxxxxxxxxx] Sent: Tuesday, June 13, 2000 2:57 AM To: xsl-list@xxxxxxxxxxxxxxxx Subject: RE: several questions on XML to HTML processing with XSL Hello, > From: Kay Michael <Michael.Kay@xxxxxxx> > Date: Fri, 9 Jun 2000 15:50:14 +0100 >> 4. How do I declare a variable parametername? >> >> I'd like to do the following, but Saxon returns an errormessage on the >> <xsl:with-param> line (invalid $ character). >> >> <xsl:variable >> name="ParamName">someXMLtag/@someAttribute</xsl:variable> >> >> <xsl:call-template name="SomeTemplateName"> >> <xsl:with-param name="$ParamName">whateverValue</xsl:with-param> >> </xsl:call-template> >> >> How should I do this? >Leave out the "$" sign. It's not part of the parameter's name, it's only >used to identify a variable when used within an XPath expression. Sorry, I left something out. The template 'SomeTemplateName' has several parameters which I initialised to a default value and I only want to set one to a different value, but this one parameter can be variable. So it's something like this: <xsl:template name="SomeTemplateName"> <xsl:param name="param1">true</xsl:param> <xsl:param name="param2">true</xsl:param> <xsl:param name="param3">true</xsl:param> <xsl:param name="param4">true</xsl:param> <!-- do some processing here based on the value of the parameters --> </xsl:template> the variable "ParamName" will be either "param1", "param2" etc. and 'whateverValue' could be e.g. 'false'. So instead of passing on the value of all parameters I just want to pass on the only parameter that's changed. I vaguely recall that someone has once asked a similar question, but I can't find it in the archives. Bye, Helma van der Linden Medical Informatics h.vanderlinden@xxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: several questions on XML to HTM, Kay Michael | Thread | RE: several questions on XML to HTM, Kay Michael |
Re: Problems with sort., Brian Burridge | Date | matching templates independent of n, Mack, Daniel |
Month |