This is a good example of how one should trim down a stylesheet to isolate the problem. I think you could cut away all the xsl:choose and xsl:attribute instructions and find the basic issue here: <xsl:template match="/"> <xsl:element name="FICHE"> <xsl:for-each select="database/table0/record0"> <xsl:variable name="DEF" select="DEFINITION" /> ... </xsl:for-each> </xsl:element> <xsl:if test="$DEF='T'"> The above may or may not be the problem, but it will be easier to know by trimming away other parts. If you want $DEF to be in-scope throughout the template, set it right away, like this: <xsl:template match="/"> <xsl:variable name="DEF" select="database/table0/record0/DEFINITION"/> <xsl:element name="FICHE"> ... Again, this may not be what you want or need to do, but I suspect your varaible really is out-of-scope at the time you test it. .................David Marston
