Re: [xsl] InDesign IDML table conversion

Subject: Re: [xsl] InDesign IDML table conversion
From: Markus Abt <abt@xxxxxxxx>
Date: Sat, 18 Aug 2012 18:01:07 +0200
Hi,

Ganesh Babu N wrote:
[...]
> 					<tr>
> 						<td morerows="1" rowspan="2">Cigarettes</td>
> 						<td>NA</td>
> 						<td morerows="1" rowspan="2">test</td>
> 						<td>7.6</td>
> 					</tr>
[...]
> 					<tr>
> 						<td morerows="1" rowspan="2">Inhalants</td>
> 						<td morerows="1" rowspan="2">6</td>
> 						<td morerows="1" rowspan="2">0.5</td>
> 						<td>0.0</td>
> 					</tr>
[...]
> I am trying to find out the number tds before the td[@morerows], so
> that i can increase the cell count accordingly. But it is not giving
> the exact number of tds. For the first set it should give 0 and 2 and
> for the 2nd set it should give 3 . But it is giving 2 everywhere.
> Please suggest me where I am going wrong.
> 
> Here is my style sheet
[...]
> 					<xsl:when test="parent::tr/preceding-sibling::tr[1]/td[@morerows]">
> 						<xsl:value-of
> select="concat($trpos,':',count(parent::tr/preceding-sibling::tr[1]/td[@morerows]/preceding-sibling::td))"/>
> 					</xsl:when>
[...]

In the above code, "parent::tr/preceding-sibling::tr[1]/td[@morerows]" 
selects _all_ <td>s with a @morerows attribute in the preceding row. 
Then, "preceding-sibling::td" selects all preceding <td>s, i.e. in your 
input, the two <td>s preceding "test" and "0.5", respectively. In other 
words, you are counting the maximum number of preceding <td>s, 
which happens to be 2 in both cases.

Markus

Current Thread