[xsl] adding column number to the entry

Subject: [xsl] adding column number to the entry
From: Ganesh Babu N <nbabuganesh@xxxxxxxxx>
Date: Tue, 1 Sep 2009 15:09:05 +0530
Dear All,

I am having a input like this.

<table>
	<row>
		<entry align="left" valign="top">Table 1 TB C1 R5</entry>
		<entry align="left" valign="top" morerows="1">Table 1 TB C2 R5 and
TB C2 R6 are merged</entry>
		<entry align="left" valign="top">Table 1 TB C3 R5</entry>
                <entry align="left" valign="top">Table 1 TB C4 R5</entry>
	</row>
	<row>
		<entry align="left" valign="top">Table 1 TB C1 R6</entry>
		<entry align="left" valign="top">Table 1 TB C3 R6</entry>
                <entry align="left" valign="top">Table 1 TB C4 R6</entry>
	</row>
</table>

My required output is as follows:

<table>
   <cell Name="1" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R5</cell>
   <cell Name="2" RowSpan="2" ColumnSpan="1">Table 1 TB C2 R5 and TB
C2 R6 are merged</cell>
   <cell Name="3" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R5</cell>
   <cell Name="4" RowSpan="1" ColumnSpan="1">Table 1 TB C4 R5</cell>
   <cell Name="1" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R6</cell>
   <cell Name="3" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R6</cell>
   <cell Name="4" RowSpan="1" ColumnSpan="1">Table 1 TB C4 R6</cell>
</table>

I have tried with the following code but it is changing the number in
all the 2nd row entries. It requires to be changed only in C3 of R6
and C4 of R6. Because C2 of R6 is already merged with C2 of R5.

<xsl:template match="entry>
      <xsl:if test="parent::row/preceding-sibling::row/entry/@morerows">
           <xsl:value-of select="position() +
parent::row/preceding-sibling::row/entry[@morerows]/position()"/>
      </xsl:if>
</xsl:template>

Please help me getting required output.

Regards,
Ganesh

Current Thread