Advertisement

12.29.2004 at 04:34AM PST, ID: 21256225
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

XSLT: How do I pick out a cell in the first column of a dynamically generated table.

Asked by Jezcentral in Extensible Markup Language (XML)

Tags: , ,

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[whatever]"/otherwise, 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(header)">
            <h2><xsl:value-of select="header"/></h2>
      </xsl:if>
      <xsl:if test="normalize-space(intro)">
            <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(action-button)">
            <div class="rightPad10px">
                  <xsl:apply-templates select="action-button" mode="common-action-button" />
            </div>
      </xsl:if>
      <xsl:if test="normalize-space(footer)">
            <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(header)">
            <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(header)">
            <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(column/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($cell-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
 
Loading Advertisement...
 
[+][-]12.29.2004 at 11:52AM PST, ID: 12921535

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.29.2004 at 03:27PM PST, ID: 12922898

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.30.2004 at 12:36AM PST, ID: 12924637

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Extensible Markup Language (XML)
Tags: first, table, xslt
Sign Up Now!
Solution Provided By: dualsoul
Participating Experts: 2
Solution Grade: B
 
 
[+][-]12.30.2004 at 01:17AM PST, ID: 12924788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.30.2004 at 02:50AM PST, ID: 12925035

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44