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

Re: creating html tables from cells

Subject: Re: creating html tables from cells
From: Mukul Gandhi <mukulgw3@xxxxxxxxx>
Date: Wed, 15 Oct 2003 11:51:46 -0700 (PDT)
create html table
Hi Dan,
 I came up with a recursive solution.. The XSL is --

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0"
encoding="UTF-8" indent="yes"/>
	
<xsl:template match="/RS">
  <html>
    <head>
      <title/>
    </head>
    <body>
      <table>
	<xsl:for-each select="RI">
	   <xsl:if test="@col = '1' ">			      <tr>					     
  <td><xsl:value-of select="." /></td>
		  <xsl:call-template name="process-xml-subset">
								    <xsl:with-param name="xml-subset"
select="following-sibling::RI"/>
		  </xsl:call-template>			      </tr>					   
</xsl:if>
        </xsl:for-each>
      </table>
   </body>
</html>
</xsl:template>
	
<xsl:template name="process-xml-subset">
   <xsl:param name="xml-subset"/>
     <xsl:if test="$xml-subset[1][@col &gt; 1]">
	<td>
	  <xsl:value-of select="$xml-subset[1]"/>
	</td>
	<xsl:call-template name="process-xml-subset">
	   <xsl:with-param name="xml-subset"
select="$xml-subset[position() &gt; 1]"/>
	</xsl:call-template>
     </xsl:if>		
</xsl:template>
</xsl:stylesheet>

Hope its useful..

Regards,
Mukul


--- "Whitney, Dan (CanWest Interactive)"
<DWhitney@xxxxxxxxxxx> wrote:
> 2 questions.
> 
> I have the following xml structure:
> 
> <RS>
> <RI col="1">Row 1 - Column 1</RI>
> <RI col="2">Row 1 - Column 2</RI>
> <RI col="3">Row 1 - Column 3</RI>
> <RI col="4">Row 1 - Column 4</RI>
> <RI col="1">Row 2 - Column 1</RI>
> <RI col="2">Row 2 - Column 2</RI>
> <RI col="3">Row 2 - Column 3</RI>
> <RI col="4">Row 2 - Column 4</RI>
> </RS>
> 
> I'm wondering if there's an effecient way with xsl
> to transform it to:
> <table>
>   <tr>
>     <td>Row 1 - Column 1</td>
>     <td>Row 1 - Column 2</td>
>     <td>Row 1 - Column 3</td>
>     <td>Row 1 - Column 4</td>
>   </tr>
>   <tr>
>     <td>Row 2 - Column 1</td>
>     <td>Row 2 - Column 2</td>
>     <td>Row 2 - Column 3</td>
>     <td>Row 2 - Column 4</td>
>   </tr>
> </table>
> 
> I know I have to somehow create the tr's on the RS
> element but I'm not at
> all sure how.
> 
> Thanks for any help
> 
> Dan
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


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.