[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: output in table
The answer is the same no matter how many rows you plan to have. The details are slightly different depending on the number of columns you wish to display. You will need to use the mod operator in conjunction with the position() function to create a new row where you want one. Sic, <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" encoding="UTF-8" /> <xsl:strip-space elements="*" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="root"> <table border="1"> <xsl:apply-templates /> </table> </xsl:template> <xsl:template match="carrier"> <xsl:choose> <xsl:when test="count(preceding-sibling::carrier)mod 3=0"> <tr> <td><xsl:value-of select="@name" /></td> <td><xsl:value-of select="following-sibling::carrier[1]/@name" /></td> <td><xsl:value-of select="following-sibling::carrier[2]/@name" /></td> </tr> </xsl:when> <xsl:otherwise /> </xsl:choose> </xsl:template> </xsl:stylesheet> -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Charles Ohana <charles.ohana@xxxxxxxxxxxxxx> Sent: Mon, 20 Jun 2005 11:40:02 -0500 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: output in table I need the following output. But I need it generic since I don't know how many element I'm going to have ... - Thanx <table border="1"> <tr> <td> cingular </td> <td> t-mobile </td> <td> att </td> </tr> <td> verizon </td> <td> nextel </td> <td> sprint </td> </tr> <td> boost </td> <td> Other </td> <td> Unknown </td> </tr> </table> <root> <carrier name="cingular" position="1" /> <carrier name="t-mobile" position="2" /> <carrier name="att" position="0" /> <carrier name="verizon" position="3" /> <carrier name="nextel" position="4" /> <carrier name="sprint" position="5" /> <carrier name="boost" position="6" /> <carrier name="Other" position="7" /> <carrier name="Unknown" position="7" /> </root> ----- Original Message ----- From: <cknell@xxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, June 20, 2005 10:23 AM Subject: RE: output in table > You have given us half of the information we need, now show us the output > you would like to produce from this XML and we can show you how to write > the XSLT. > -- > Charles Knell > cknell@xxxxxxxxxx - email > > > > -----Original Message----- > From: Charles Ohana <charles.ohana@xxxxxxxxxxxxxx> > Sent: Mon, 20 Jun 2005 11:21:46 -0500 > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > Subject: output in table > > Hello, > I'm trying to have an output of the xml below in a table with 3 rows and 3 > columns. > Is there a quick and easy way to do it ... > Thanx ... > > <root> > <carrier name="cingular" position="1" /> > <carrier name="t-mobile" position="2" /> > <carrier name="att" position="0" /> > <carrier name="verizon" position="3" /> > <carrier name="nextel" position="4" /> > <carrier name="sprint" position="5" /> > <carrier name="boost" position="6" /> > <carrier name="Other" position="7" /> > <carrier name="Unknown" position="7" /> > </root>
|
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
|