I think you can do this using recursive template. Just past the indent to
the child section. Here is an example, hope this helps.
<xsl:template match="section">
<xsl:param name="indent"/>
<xsl:value-of select="$indent"/><xsl:value-of select="something"/><br/>
<xsl:apply-templates select="section">
<xsl:with-param name="indent" select="concat($indent," ")"/>
</xsl:apply-templates>
</xsl:template>
You could also use <xsl:call-template> I think.
----- Original Message -----
From: "Evgeniy Strokin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 03, 2002 3:23 PM
Subject: How I can know level of nesting of each descendant?
> Hi,
> I have code:
> <script>
> <xsl:for-each select="ProductMetadata">
> <xsl:variable name="prod" select="."/>
> var prod_<xsl:value-of select="$prod/@product"/>=new
> Array(<xsl:value-of select="count(descendant::*)"/>);
> <xsl:for-each select="descendant::*">
> prod_<xsl:value-of
> select="$prod/@product"/>[<xsl:value-of
> select="position()"/>]="<xsl:value-of
> select="@mnemonic"/>";
> </xsl:for-each>
> </xsl:for-each>
> </script>
> How I can know level of nesting of each descendant?
> Actually I want to put how many before
> <xsl:value-of select="@mnemonic"/> what level of
> nesting is.
> For example:
> If I have XML like:
> <root>
> <ProductMetadata product="pr1">
> <prop1 mnemonic="1">
> <prop2 mnemonic="2"/>
> <prop3 mnemonic="3"/>
> </prop1>
> <prop4 mnemonic="4"/>
> </ProductMetadata>
> </root>
> I want result like:
> var prod_pr1=new Array(4);
> prod_pr1[0]="1";
> prod_pr1[1]=" 2";
> prod_pr1[2]=" 3";
> prod_pr1[3]="4";
>
> Is it possible at all?
> Thanks,
> Jenya
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>