<lign="left">Index Nav:
[Date Index] [Subject Index] [Author Index] [Threadp;Index]
Message Nav: [Date Prev< [Date Next] [Thread Prev] [Thread Next]

Re: <xsl:if test="@attribute=$varValue">


Philippe,

Given an XML source of:

<foo attr="bar"/>

A stylesheet of:

<xsl:stylesheet xmlsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:teme 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 = vlue0
   </xsl:if>
   <xsl:if test="@attr = $varValue1">
     attr = varvalue1
   </xsl:if>
   <xsl:if t"@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 l to an empty
      nodeset when select="bar" did not find
      any children elements named "bar".

  (2) There are two way get a string value
      assigned to a variable:

        <!-- Note the single quotes around 'string' -->
        <:variable name="x" select="'string'"/>
        <xsl:variable name="y">string</xsl:variable>


Hopefully this ple will help see what might
be different with your case.

_________________________________________________________
Steve Mh, Consulting Product Manager & XML Evangelist
Business Components for Java Development Team

----- Original Message ---rom: "Philippe Vijghen" <Philippe.Vijghen@forem.be>
To: <xalan-dev@xml.apache.org>
Sent: Wednesday, February 16,0 4:37 AM
Subject: RE: <xsl:if test="@attribute=$varValue">


Using <xsl:value-of> in my simplified example was stake.
The issue is related to tests, such as in <xsl:if>.

I could not solve the issue and had to implement a work-ar
in my stylesheet.

Le'ts rephrase it:

<xsl:if select="@attribute='myVarValue'">hello</xsl:if>

...is working pctely and perform the expected test
on the attribute value.

However

<xsl:template name="tmplName">
<xsl:param namarValue">myVarValue</varValue>
<xsl:if select="@attribute=$varValue">hello</xsl:if>
</xsl:template&g...is not working:
the test is never considered as 'true'
although I verified that both the $varValue parameter
and the attre are correctely initiliazed to 'myVarValue'.

Philippe



> -----Original Message-----
> From: Steve Muench [mailto:smuench@us.oracle.com]
> Sent: lundi 14 fivrier 2000 18:52
> To: xalan-dev@xml.he.org
> Subject: Re: <xsl:if test="@attribute=$varValue">
>
>
> |            <xsl:template name="tmplN>
> |            <xsl:param name="varValue">myVarValue</varValue>
> |            <xsl:value-of selecattribute={$varValue}">
> |            </xsl:template>
>
> The title of the mail says:
>
>    <xs test="@attribute=$varValue"/>
>
> but in the body of the mail, it says:
>
>    <xsl:value-of select="@attte=$varValue"/>

...

> Could this be the problem?

...



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

<e border="0"> Index Nav: [Date In/A>] [Subject Index] [Author Index] [Thread Index] Message Nav: [Date Prev] [Date Next] [Thread&nPrev] [Thread Next]