Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi I am using an XLST to style an X 1

Status
Not open for further replies.

rxg00u

Programmer
Apr 11, 2002
16
GB
Hi I am using an XLST to style an XML document .

In my xml document I have the code :

<TABLE id=&quot;4.1&quot;>
<ROW>
<CELL>Value entered</CELL>
<CELL>Message to Display</CELL>
</ROW>
<ROW>
<CELL>1</CELL>
<CELL>Happy First Birthday</CELL>
</ROW>
.....


The problem I have is that I want to make the first row in the table bold, because they are the headings . However I do not know how to only make the first row bold. Is there any way in the XLST of making the first instance bold and then the rest regular ??

Here is the code I am currently using in my XSLT:

<xsl:template match=&quot;TABLE&quot;>
<br/>
<br/>
<table border=&quot;1&quot; align = &quot;center&quot;>
<xsl:apply-templates select=&quot;ROW&quot;/>
</table>
</xsl:template>

<xsl:template match=&quot;ROW&quot;>
<tr>
<xsl:apply-templates select=&quot;CELL&quot;/>
</tr>
</xsl:template>

<xsl:template match=&quot;CELL&quot;>
<td align =&quot;center&quot; COLSPAN =&quot;100&quot;>
<xsl:value-of select=&quot;self::node()&quot;/>
</td>
</xsl:template>


Thank you
 
Add this template to your script:

Code:
<xsl:template match=&quot;CELL[position() = 1]&quot;>
<td align =&quot;center&quot; COLSPAN =&quot;100&quot;>
<b><xsl:value-of select=&quot;self::node()&quot;/></b>
</td>
</xsl:template>

-- Chris Hunt
Extra Connections Ltd
 
Hi ,

That seems to make the first column bold and not the first row bold . I have changed the COLSPAN to ROWSPAN but that does not seem to help.

Thanks Again

Rakesh
 
Oops. try this:

Code:
<xsl:template match=&quot;ROW[position() = 1]/CELL&quot;>
<td align =&quot;center&quot; COLSPAN =&quot;100&quot;>
<b><xsl:value-of select=&quot;self::node()&quot;/></b>
</td>
</xsl:template>

instead of the above, I think it'll work.
-- Chris Hunt
Extra Connections Ltd
 
Chris, if you &quot;just add&quot; that template won't that result in the first row being displayed twice once with <b> and another without?

-pete
 
Pete,

It shouldn't do, because XSLT should (I think) pick the more specific template (i.e. one with a [] in the XPath expression) in preference to the more generic one.

I've just tried it using the Microsoft IE6 XSLT engine and it works as it should do (row 1 appearing once, and in bold). -- Chris Hunt
Extra Connections Ltd
 
Ok, i had a similar attempt at doing that which failed so my &quot;select&quot; condition must not have been specific or something. Maybe i saved the file and i can check it out.

Thanks
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top