[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Can not convert number to a NodeList
Carlos,
I believe the prior respondent mentioned 2 ways to achieve what you want: recursively write out rows and col or, if using for-each, supply for the "rows" a nodeset equal to the number of @lines. The second approach is described below (and for simplicity we derive # cols ): With this input: <data> <radio line="1"> <opt>Masc</opt> <opt>Fem</opt> <opt>other</opt> <opt>Masc2</opt> <opt>Fem2</opt> <opt>other2</opt> </radio> </data> This XSL: <?xml version="1.0" encoding="iso8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="radio"> <table> <xsl:variable name="numcols" select="count(opt) div @line"/> <xsl:for-each select="opt[position() <= current()/@line]"> <xsl:variable name="r" select="position() - 1"/> <tr> <xsl:apply-templates select="../opt[position() >= $r * $numcols + 1 and position() <= $r * $numcols + $numcols ]"/> </tr> </xsl:for-each> </table> </xsl:template> <xsl:template match="opt"> <td><xsl:value-of select="."/></td> </xsl:template> </xsl:stylesheet> produces: <?xml version="1.0" encoding="UTF-8"?> <table> <tr> <td>Masc</td> <td>Fem</td> <td>other</td> <td>Masc2</td> <td>Fem2</td> <td>other2</td> </tr> </table> If you change @lines to 2, you should get 2 rows. This may not work for @lines = sqrt( 2 ) Regards, --A From: "Carlos M. S. Bento Nogueira" <cmsbn@xxxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: Can not convert number to a NodeList Date: Sun, 12 Jun 2005 03:00:36 +0100 (WEST) _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
|
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
|