<xsl:if test="count(child::Data_For_Visio/node() ) > 1 and count(child::Data_For_Visio/child::*/node()) = 0 ">
<xsl:text>Data_For_Visio has more than one child and no grandchildren</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Make sure there is no whitespace in the xml elements and it works
Subject:Counting children and grandchildren Author:Liam B Date:13 Feb 2009 06:09 AM
Hi John,
Thanks for your responses.
The data is for an orgchart, and when a person has two or more subordinates, but those subordinates have no subordinates then apply a different transorm to those subordinates. For example in the following XML i wish to apply a different transform to Jon Snow, Moira Stewart, Jimmie Krankie and Alex Zane only.
<xsl:for-each select="//Data_For_Visio">
<xsl:choose>
<xsl:when test="count(child::*) > 1 and count(child::*/child::*) = 0 ">
more than one child and no grandchildren
</xsl:when>
<xsl:otherwise>
the condition fails
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>