I'm not sure I understand correctly. On this fragment:
<item>
<item>...</item>
<item>...</item>
</item>
You'll get 0, 1, 1.
I now realize that maybe you want 0,1,2 (or 1,2,3). If that is the case,
sorry, I was misled by your use of the term "recursive calls". You want
the number of past calls, right? Can you give us a short example,
please?
You're right, but I show you an example
I have got a XML tree like
<component>
<subcomponent>
<subsubcomponent>
</subcomponent>
<componentdef>
<subcomponent>
....
</.>
</.>
</.>
my XSL will first match the component, so that I can create the first
section header
#
the next it will match the subcomponent twice
##
##
But the exact matches are in real depend on different if-else / choose
structures, so
that I have eg
<xsl:template match="subcomponent">
<xsl:if text="...">
<xsl:call-template name="header">
...
</xsl:call-template>
</xsl:if>
</xsl:template>
So not every match creates a header in the output (here I create
plain-text output),
eg I can have also
<xsl:template match="something-else">
<xsl:choose>
<xsl:when test="first">
<xsl:call-template name="header">
...
</xsl:call-template>
</xsl:when>
<xsl:when test="second"
do something without header
</xsl:when>
<xsl:when test="third">
do something
<xsl:call-template name="header">
...
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
All templates matches, that creates a headline call one central template
<xsl:template name="header">
<xsl
aram name="value" required="yes"/>
<xsl:for-each select="1 to $indent">
<xsl:call-template name="head"/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:value-of select="$value"/>
<xsl:call-template name="nl"/>
</xsl:template>
so my problem is, that I need a value for the $indent variable, that I can
create the correct number of header indents ($value is the header title).
So I need the recursion depth of my header template, that depends on
various call on the input XML tree. The header calls are on different
position in the XSL, that analyses the XML tree.
So the efficient way is, that my header template can detect how often it is
called recursiv.
If you sort adjacent <item> during traversal, it gets more complex
because you can't rely on document order. In this case I would suggest
to first traverse your structure to generate a table associating numbers
to nodes inside a result tree fragment, use exslt:document() to get a
usable form of the table, and then retraverse the document to output the
result.
That's new for me, I can traversel first over my XML tree, create a table with
data and after that the normal XSL traversel starts, so that I can read data
from the table? Do you have an example or a link?
In my case I would traversel the XML nodes, catch the depth of my headers
and will set the $indent var in the second run from the table.
Thanks a lot
Phil