Forum Moderators: open
Example 1: Only match nodes that have the example attribute...
<xsl:for-each "sample[@example]">
</xsl:for-each> Example 2: Use an if statement to decide whether to perform an action based on the existence (irrelevant of content) of the example attribute on the current context node...
<xsl:if test="@example">
</xsl:if> I have always used this technique in the past but I overheard someone say it was incorrect - I'm trying to work out why....
See [msdn.microsoft.com...]
PS - Whoops, thanks for spotting the missing select=
boolean it will first test for (non-)existence, plus the result (true/false) is predictable across processors. Based on the following references it would seem processors which accept a direct <xsl:if test="@example"> are implicitly testing boolean(@example). [dpawson.co.uk...]
[msdn.microsoft.com...]