|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: creating html tables from cells
Hi > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Whitney, Dan (CanWest Interactive) > Sent: Wednesday, October 15, 2003 4:06 PM > To: 'mulberry - xsl' > Subject: creating html tables from cells > > > 2 questions. > (...) > > 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. > You can use keys to do this, though it might not be the best solution for big files. Check the comments in the code Stylesheet: <!-- set the key to look for the closest previous RI with @col=1 --> <xsl:key match="RI" name="RI" use="generate-id((preceding-sibling::RI | self::RI)[@col=1][last()])"/> <xsl:template match="RS"> <table> <!-- start only with RI the belong to the first column --> <xsl:apply-templates mode="start" select="RI[@col=1]"/> </table> </xsl:template> <xsl:template match="RI" mode="start"> <!-- for each one create a row --> <tr> <!-- then select the nodes until the next RI[@col=1] --> <xsl:apply-templates select="key('RI',generate-id())"/> </tr> </xsl:template> <xsl:template match="RI"> <!-- here you do whatever you want with the columns --> <td> <xsl:apply-templates/> </td> </xsl:template> Regards, Americo Albuquerque XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








