I'm trying to generate a <body> tag that will have a couple of attributes that will only be needed based on the presence of a variable.

This is what I have:

<xsl:element name="body">
<xsl:variable name="jsString" select="$sourcingInsertJavascriptString"/>
<xsl:attribute name="class">body</xsl:attribute>

<xsl:if test="$jsString">
<xsl:attribute name="onclick">dynOutline()</xsl:attribute>
<xsl:attribute name="language">Javascript1.2</xsl:attribute>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<xsl:apply-templates select="@*|node()" />

This is not working for me. I am using $sourcingInsertJavascriptString variable elsewhere and it works correctly. Is this conditional adding of attributes to the body tag possible like this? I only want the onclick attribute added to the body tag if that variable is present.