Hi, I need to test to see if a cell is in the first column of a table that has been dynamically generated by XSLT. If it is, and it contains "text", I will then use a certain style on it (I will underline it).
The xml looks like this:
<table>
<column>
<cell>value1</cell>
<cell>value2</cell>
</column>
<column>
<cell>value3</cell>
<cell>value4</cell>
</column>
</table>
The test needs to be in the 9th and final template (i.e. right at the bottom of this page), where the cells are rendered. It should be a simple xsl:choose/when test="../../column/cell[wh
atever]"/o
therwise, once anyone can tell me what the [whatever] is.
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<!-- ##########################
##########
##########
##########
##########
##########
##########
##########
-->
<!-- ##########################
##########
##########
##########
##########
##########
##########
##########
-->
<xsl:template match="module-0030" priority="1">
<xsl:apply-templates mode="module-0030" />
</xsl:template>
<xsl:template match="a" mode="module-0030">
<xsl:for-each select="list-table">
<xsl:apply-templates select="." mode="module-0030" />
</xsl:for-each>
</xsl:template>
<xsl:template match="list-table" mode="module-0030">
<xsl:if test="normalize-space(head
er)">
<h2><xsl:value-of select="header"/></h2>
</xsl:if>
<xsl:if test="normalize-space(intr
o)">
<xsl:for-each select="intro">
<xsl:apply-templates select="." mode="module-0030" />
</xsl:for-each>
</xsl:if>
<xsl:for-each select="table">
<xsl:apply-templates select="." mode="module-0030" />
</xsl:for-each>
<xsl:if test="normalize-space(acti
on-button)
">
<div class="rightPad10px">
<xsl:apply-templates select="action-button" mode="common-action-button
" />
</div>
</xsl:if>
<xsl:if test="normalize-space(foot
er)">
<xsl:for-each select="footer">
<xsl:apply-templates select="." mode="module-0030" />
</xsl:for-each>
</xsl:if>
</xsl:template>
<!-- match intro -->
<xsl:template match="intro" mode="module-0030">
<xsl:if test="normalize-space(head
er)">
<h3><xsl:value-of select="header"/></h3>
</xsl:if>
<p><xsl:value-of select="rtf" /></p>
<p><xsl:apply-templates select="link" mode="common-link" /></p>
</xsl:template>
<!-- match footer -->
<xsl:template match="footer" mode="module-0030">
<xsl:if test="normalize-space(head
er)">
<h3><xsl:value-of select="header"/></h3>
</xsl:if>
<p><xsl:value-of select="rtf" /></p>
<p><xsl:apply-templates select="." mode="common-link-list" /></p>
</xsl:template>
<!-- match table -->
<xsl:template match="table" mode="module-0030">
<table cellspacing="1" class="spanPage">
<!-- output column headers -->
<xsl:if test="normalize-space(colu
mn/header)
">
<tr class="whiteBackground">
<xsl:for-each select="column">
<th>
<a href="#"><xsl:value-of select="header" /></a>
</th>
</xsl:for-each>
</tr>
</xsl:if>
<!-- output rows - select first column -->
<xsl:apply-templates select="column[1]" mode="first-column" />
</table>
</xsl:template>
<!-- match first column -->
<xsl:template match="column" mode="first-column">
<!-- match cells via this column and use to render rows -->
<xsl:apply-templates select="cell" mode="first-column" />
</xsl:template>
<!-- match cells from first column -->
<xsl:template match="cell" mode="first-column">
<xsl:param name="cell-row" select="position()" />
<tr class="greyBkgnd_{position
() mod 2}">
<!-- select cell from each column which has this position -->
<xsl:apply-templates select="../../column/cell[
position()
=number($c
ell-row)]"
mode="render-cell" />
</tr>
</xsl:template>
<!-- match cell -->
<xsl:template match="cell" mode="render-cell">
<xsl:if test="text">
<td class="padlr5px">
<xsl:value-of select="." />
</td>
</xsl:if>
<xsl:if test="link">
<td class="padlr5px">
<xsl:apply-templates select="link" mode="common-link" />
</td>
</xsl:if>
<xsl:if test="options">
<td class="padlr5px">
<xsl:apply-templates select="options" mode="common-select" />
</td>
</xsl:if>
<xsl:if test="textbox">
<td class="padlr5px">
<input type="text" class="textBox" />
</td>
</xsl:if>
<xsl:if test="image">
<td>
<xsl:apply-templates select="image" mode="common-image" />
</td>
</xsl:if>
</xsl:template>
<!-- ##########################
##########
##########
##########
##########
##########
##########
##########
-->
<!-- end of stylesheet -->
<!-- ##########################
##########
##########
##########
##########
##########
##########
##########
-->
</xsl:stylesheet>
Start Free Trial