This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

need a hint on matching table cells


I wanted to try to figure this out on my own but I think I am at the point where I need a little hint to help me along.

I need to create an HTML table structure that has 3 columns. In my XML I have something like this:
<T-BODY>
<ROW>
	<CELL SPAN="grey">grey equals a colspan of 2 and td shaded in gray.</CELL>
	<CELL SPAN="normal">some text normal td tag</CELL>
</ROW>
<ROW>
	<CELL SPAN="normal">some text normal td tag</CELL>
	<CELL SPAN="normal">some text normal td tag</CELL>
	<CELL SPAN="normal">some text normal td tag</CELL>
</ROW>
<ROW>
	<CELL SPAN="lightgrey">lightgrey equals a colspan of 2 and td shaded in lightgray.</CELL>
	<CELL SPAN="normal">some text normal td tag</CELL>
</ROW>
</T-BODY>

I am currently testing for the SPAN attribute and then applying the appropriate template.(or so I thought)

<xsl:template match="T-BODY/ROW">
	<tr>
		<xsl:if test="CELL/@SPAN = 'grey'">
   			<td colspan="2" class="grey"><xsl:apply-templates  select = "CELL" /></td>
   		</xsl:if>
   		<xsl:if test="CELL/@SPAN = 'lightgrey'">
   			<td colspan="2" class="lightgrey"><xsl:apply-templates  select = "CELL" /></td>
   		</xsl:if>
   		<xsl:if test="CELL/@SPAN = 'normal'">
   			<td><xsl:apply-templates  select = "CELL" /></td>
   		</xsl:if>
	</tr>
</xsl:template>

This is what I get as an end result:
<tr>
<td class="grey" colspan="2">grey equals a colspan of 2 and td shaded in gray.some text normal td tag</td>
<td>grey equals a colspan of 2 and td shaded in gray.some text normal td tag</td>
</tr>
<tr>
<td>some text normal td tagsome text normal td tagsome text normal td tag</td>
</tr>
<tr>
<td class="lightgrey" colspan="2">lightgrey equals a colspan of 2 and td shaded in lightgray.some text normal td tag</td>
<td>lightgrey equals a colspan of 2 and td shaded in lightgray.some text normal td tag</td>
</tr>

As you can see it is taking all the CELL information and dumping it into each td when the SPAN attribute is different and only creating one td for the sections where the SPAN attribute is the same.

I think I understand why it is doing this but I am not sure how to go about changing it to work correctly.

Thanks for any help you have to offer
Brad

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]