Subject: Re: <xsl:if test="@attribute=$varValue"> From: "Steve Muench" <smuench@xxxxxxxxxxxxx> Date: Wed, 16 Feb 2000 07:39:23 -0800 |
Philippe, Given an XML source of: <foo attr="bar"/> A stylesheet of: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="foo"> <xsl:variable name="varValue0" select="bar"/> <xsl:variable name="varValue1" select="'bar'"/> <xsl:variable name="varValue2">bar</xsl:variable> <xsl:if test="@attr = $varValue0"> attr = varvalue0 </xsl:if> <xsl:if test="@attr = $varValue1"> attr = varvalue1 </xsl:if> <xsl:if test="@attr = $varValue2"> attr = varvalue2 </xsl:if> </xsl:template> </xsl:stylesheet> Produces attr = varvalue1 attr = varvalue2 NOTE ---- (1) attr does *NOT* match $varValue0 since the variable was set equal to an empty nodeset when select="bar" did not find any children elements named "bar". (2) There are two ways to get a string value assigned to a variable: <!-- Note the single quotes around 'string' --> <xsl:variable name="x" select="'string'"/> <xsl:variable name="y">string</xsl:variable> Hopefully this example will help see what might be different with your case. _________________________________________________________ Steve Muench, Consulting Product Manager & XML Evangelist Business Components for Java Development Team ----- Original Message ----- From: "Philippe Vijghen" <Philippe.Vijghen@xxxxxxxx> To: <xalan-dev@xxxxxxxxxxxxxx> Sent: Wednesday, February 16, 2000 4:37 AM Subject: RE: <xsl:if test="@attribute=$varValue"> Using <xsl:value-of> in my simplified example was a mistake. The issue is related to tests, such as in <xsl:if>. I could not solve the issue and had to implement a work-around in my stylesheet. Le'ts rephrase it: <xsl:if select="@attribute='myVarValue'">hello</xsl:if> ...is working perfectely and perform the expected test on the attribute value. However <xsl:template name="tmplName"> <xsl:param name="varValue">myVarValue</varValue> <xsl:if select="@attribute=$varValue">hello</xsl:if> </xsl:template> ...is not working: the test is never considered as 'true' although I verified that both the $varValue parameter and the attribute are correctely initiliazed to 'myVarValue'. Philippe > -----Original Message----- > From: Steve Muench [mailto:smuench@xxxxxxxxxxxxx] > Sent: lundi 14 fivrier 2000 18:52 > To: xalan-dev@xxxxxxxxxxxxxx > Subject: Re: <xsl:if test="@attribute=$varValue"> > > > | <xsl:template name="tmplName"> > | <xsl:param name="varValue">myVarValue</varValue> > | <xsl:value-of select="@attribute={$varValue}"> > | </xsl:template> > > The title of the mail says: > > <xsl:if test="@attribute=$varValue"/> > > but in the body of the mail, it says: > > <xsl:value-of select="@attribute=$varValue"/> ... > Could this be the problem? ... XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: XSL or CSS, Steve Tinney | Thread | Problems with sorting in XSL, Andre . Cedik |
Re: Which one to choose, ural | Date | Re: Which one to choose, Steve Muench |
Month |