Sorry, that can't be done using XSLT because your required result is not well-formed XML. You can get the self-closed element by doing this:
Code:
<xsl:choose>
<xsl:when test="./str[@id='aaa'] !=''">
<xsl:element name="First">
<xsl:value-of select="./str[@id='aaa']"/>
</xsl:element>
</xsl:when>
<xsltherwise>
<First xsl:nil="true" />
</xsl:otherwise>
</xsl:choose>
but you can't use
xsl:nil attribute without having the
Code:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
declaration present at least once in the stylesheet.