![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XSLT Newbie Help >Thread Next - Re: XSLT Newbie Help Re: XSLT Newbie HelpTo: NULL Date: 7/3/2005 9:34:00 PM <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- this works on my pc using MSXML 3. I'll let you figure out the
centering
and the sorting... -->
<xsl:template match="*">
<!-- setup the style for the table... -->
<style>
table {border-collapse: collapse; border: .25mm solid black;
font-size: 10pt;}
tr.pink {background: pink}
tr.pblue {background: powderblue}
caption {font-weight: bold}
th {background: gold}
</style>
<!-- table just for Group = 0 -->
<table border="1" cellpadding="3" width="20%">
<caption>Group 0</caption>
<tr><th>Type</th><th>Group #</th></tr>
<tr>
<xsl:for-each select="//Car[Group=0] | //Bike[Group=0]"> <!-- use the
union operator "|"
to grab both types of elements -->
<tr>
<xsl:choose>
<xsl:when test="name() = 'Car'">
<xsl:attribute name="class">pink</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">pblue</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<td><xsl:value-of select="name()"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</tr>
</table>
<br/>
<!-- table just for Group > 0 -->
<table border="1" cellpadding="3" width="20%">
<caption>Group 1 or 2</caption>
<tr><th>Type</th><th>Group #</th></tr>
<tr>
<xsl:for-each select="//Car[Group!=0] | //Bike[Group!=0]">
<tr>
<xsl:choose>
<xsl:when test="name() = 'Car'">
<xsl:attribute name="class">pink</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">pblue</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<td><xsl:value-of select="name()"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
