[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: empty row between types

Subject: RE: empty row between types
From: cknell@xxxxxxxxxx
Date: Fri, 08 Dec 2006 14:55:45 -0500
empty row xsl
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:strip-space elements="*" />
 <xsl:output method="xml" indent="yes" encoding="UTF-8" />

   <xsl:template match="/">
       <xsl:apply-templates />
   </xsl:template>

		<xsl:template match="data">
		  <xsl:apply-templates />
		</xsl:template>
		
 <xsl:template match="row[following-sibling::row/@type = @type]">
 <tr><td><xsl:value-of select="@type"/></td></tr>
 </xsl:template>

 <xsl:template match="row[not(following-sibling::row/@type = @type)]">
 	<xsl:choose>
 		<xsl:when test="position() = last()">
 			<tr><td><xsl:value-of select="@type"/></td></tr>
 		</xsl:when>
 		<xsl:otherwise>
			  <tr><td><xsl:value-of select="@type"/></td></tr>
			  <tr><td></td></tr>
 		</xsl:otherwise>
 	</xsl:choose>
 </xsl:template>

</xsl:stylesheet>
--
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Sam Carleton <scarleton@xxxxxxxxxxxxxxxx>
Sent:     Fri, 8 Dec 2006 14:20:35 -0500
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:   empty row between types

Here is my data:

<data>
 <row type="red"></row>
 <row type="red"></row>
 <row type="red"></row>
 <row type="blue"></row>
 <row type="blue"></row>
 <row type="blue"></row>
</data>

What I want is a blank row between the red and the blue:

<table border="1">
   <tr><th>Color</th></tr>
   <tr><td>red</td></tr>
   <tr><td>red</td></tr>
   <tr><td>red</td></tr>
   <tr><td></td></tr>
   <tr><td>blue</td></tr>
   <tr><td>blue</td></tr>
   <tr><td>blue</td></tr>
</table>

Here is the good old basic XSLT, that does not include the empty row between:

<xsl:template match="data">
   <html>
     <body>
       <table border="1">
         <tr><th>Color</th></tr>
         <xsl:apply-templates/>
       </table>
     </body>
   </html>
 </xsl:template>

 <xsl:template match="row">
 <tr><td><xsl:value-of select="@type"/></td></tr>
 </xsl:template>

How do I go about getting the empty row.  Oh, there is one catch, I do
*NOT* know what the types are or when they will change.  I only know
there *MIGHT* be different types, might not.

P.S. I am working with the Microsoft .Net 2.0 XSLT Transformer, IE XSLT 1.

Sam
--
Miltonstreet Photography
http://www.miltonstreet.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.