[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Reformatting tables
Hi all, I have a large number of html tables in the following format: <table> <tr> <td> <p>Animal</p> </td> <td> <p>Colour</p> </td> </tr> <tr> <td> <p>Elephant</p> <p>Pig</p> <p>Sheep</p> <p>Canary</p> </td> <td> <p>Grey</p> <p>Pink</p> <p>White</p> <p>Yellow</p> </td> </tr> </table> Where someone has used FrontPage or something and has ended up creating one row of multiple paragraphs instead of a row for each item. How can I write some xsl to reformat this into proper rows? Eg: <tr> <td> <p>Elephant</p> </td> <td> <p>Grey</p> </td> </tr> So far I have made: <xsl:template match="tr"> <xsl:for-each select="td[1]/p"> <tr> <td><p><xsl:value-of select="."/></p></td> <xsl:variable name="n" select="position()"/> <td><p><xsl:value-of select="//td[2]/p[position()=$n]"/></p></td> </tr> </xsl:for-each> </xsl:template> But this always leaves them out of sync. What am I doing wrong? Thanks in advance, Neil. PS. Excuse the animal colours example, the real data is confidential internal stuff :-) 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
|