My XML is completely recursive in that every element within it is an "Item" and the type is delineated by a "type" property. In my XSL I want to be able to determine what level of iteration I am at, or in other words, how many levels from the root I am currently. I can't figure out how to do this . . .
XML Sample:
<Questionnaire>
<Item ItemType="Group">
<Caption>ABC</Caption>
<Item ItemType="Group">
<Caption>DEF</Caption>
<Item ItemType="Question">
<Caption>What's Wrong?</Caption>
</Item>
</Item>
</Item>
<Item ItemType="Group">
<Caption>QRS</Caption>
<Item ItemType="Group">
<Caption>TUV</Caption>
<Item ItemType="Question">
<Caption>What's Wrong?</Caption>
</Item>
</Item>
<Item ItemType="Group">
<Caption>XYZ</Caption>
<Item ItemType="Question">
<Caption>What's Wrong?</Caption>
</Item>
</Item>
</Item>
</Questionnaire>
XSL Sample:
<xsl:template match="/Questionnaire">
<xsl:for-each select="Item">
<fieldset>
<legend><xsl:value-of select="Caption" /></legend>
<xsl:call-template name="ItemTemplate" />
</fieldset>
</xsl:for-each>
</xsl:template>
<xsl:template name="ItemTemplate">
<xsl:if test="@ItemType != 'Question'">
<ol>
<xsl:for-each select="Item">
<li>
<xsl:value-of select="Caption" />
<xsl:call-template name="ItemTemplate" />
</li>
</xsl:for-each>
</ol>
</xsl:if>
</xsl:template>