xsl-list
[Top] [All Lists]

Re: Trouble using recursion to make a Counter

2004-07-29 20:47:30
Here is a another solution -

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
 
<xsl:output method="text" /> 

<xsl:template match="/">
   <xsl:for-each
select="descendant::*[contains(name(),'Desc')]">
     <xsl:value-of select="position()" /><xsl:text>
</xsl:text><xsl:value-of select="." />
     <xsl:text>&#xA;</xsl:text>
   </xsl:for-each>
</xsl:template>
  
</xsl:stylesheet>

Regards,
Mukul

I have data that looks like this:

<level1>
      <Level1Desc>Neighborhood</Level1Desc>
      <Level1ID>1</Level1ID>
      <Level2>
            <Level2Desc>Street</Level2Desc>
            <Level2ID>100</Level2ID>
            <Level3>
                  <Level2Desc>House</Level2Desc>
                  <Level2ID>1000</Level2ID>
            </Level3>
            <Level3>
                  <Level2Desc>Condo</Level2Desc>
                  <Level2ID>1001</Level2ID>
            </Level3>
      </Level2>
      <Level2>
            <Level2Desc>Park</Level2Desc>
            <Level2ID>101</Level2ID>
      </Level2>
</level1>

There are many level 1s in my data.

So the end result of the processing would look
something like

1 Neighborhood
2 Street
3 House
4 Condo
5 Park



                
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail