2012-10-27 45 views
1

我有...動態colspan屬性在XSLT TD

<tr> 
<xsl:variable name="noofrows" select="count(ChargeGroupsVo)"></xsl:variable> 
<td colspan="$noofrows" style="border-top: 1px solid black;padding: 5px;"></td> 
</tr> 

這裏 ChargeGroupsVo是類數據具有數約800 我想,計8列跨度.... 輸出類型的xslt是HTML 如何做到這一點...

回答

0

我這樣做...

<td> 
               <xsl:for-each select="ChargeGroupNames"> 
                <xsl:variable name="norows" select="count(ChargeGroupsVo)"></xsl:variable> 
                <xsl:if test="$norows &gt; 1"> 
                 <xsl:attribute name="colspan"> 
                  <xsl:value-of select="$norows + 2"/> 
                 </xsl:attribute> 
                </xsl:if> 
               </xsl:for-each> 
</td> 

動態添加的屬性和值....

3

你需要在這裏使用'屬性值模板'。

而不是做這個的....

<td colspan="$noofrows" style="border-top: 1px solid black;padding: 5px;"></td> 

你需要這樣做

<td colspan="{$noofrows}" style="border-top: 1px solid black;padding: 5px;"></td> 

大括號{}表明它是進行評估,而不是東西,是一個表達式字面輸出。

事實上,你根本不需要變量。你也可以這樣做:

<td colspan="{count(ChargeGroupsVo)}" style="border-top: 1px solid black;padding: 5px;"></td> 
+0

感謝UR答案.... –