Ответ 1
Просто используйте:
<xsl:template match="someElement/@someAttrName">
<!-- Whatever specific work when someElement has @someAttrName -->
</xsl:template>
<xsl:template match="someElement[not(@someAttrName)]">
<!-- Whatever specific work when someElement has no @someAttrName -->
</xsl:template>
Обратите внимание. В хорошо написанном XSLT-коде количество условных инструкций (например, <xsl:choose>
, <xsl:when>
, <xsl:otherwise>
, <xsl:if>
,... и т.д.). близко к нулю. В этом решении оно равно 0.