Assuming you don't care what element the attribute appears on, use
<xsl:when test="//@class='program'">YYY</xsl:when>
<xsl:otherwise>NNN</xsl:otherwise>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference