I want to count the parent elements and return count in String format. I have mentioned tried code below.
Input:
<node>
<dot>
<title>paragaraph 12</title>
</dot>
<dot>
<dot>
<dot>
<ttle>paragaraph 23</ttle>
</dot>
</dot>
</dot>
<dot>
<dot>
<title>paragaraph 24</title>
</dot>
</dot>
</node>
Tried code:
<xsl:template match="title[parent::dot]">
<xsl:value-of select="count(parent::dot)"/>
</xsl:template>
Expected output:
<output>
<out type="One">paragaraph 12</out>
<out type="Three">paragaraph 23</out>
<out type="Two">paragaraph 24</out>
</output>
Explain output:
<out type="One">paragaraph 12</out>
--> here there are one <dot>
above title. so @type
should be as One
<out type="One">paragaraph 23</out>
--> here there are three <dot>
above title. so @type
should be as Three
<out type="One">paragaraph 24</out>
--> here there are two <dot>
above title. so @type
should be as Two