[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Finding the maximun number of nodes
Here's the solution with variable number of tables -- you can parameterise it as an exercise... :o))) <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > <xsl:key name="numCells" match="tr" use="count(td)"/> <xsl:template match="/"> <xsl:value-of select="count(//table[@ID='1']/tr[not(key('numCells', count(td) + 1)[parent::table[@ID='1']] )]/td)"/> </xsl:template> </xsl:stylesheet> Given the following input: <tables> <table ID="1"> <tr><td>(1,1)</td></tr> <tr><td>(2,1)</td><td>(2,2)</td><td>(2,3)</td></tr> <tr><td>(3,1)</td><td>(3,2)</td></tr> </table> <table ID="2"> <tr><td>(1,1)</td></tr> <tr><td>(2,1)</td><td>(2,2)</td><td>(2,3)</td></tr> <tr><td>(3,1)</td><td>(3,2)</td><td>(3,3)</td><td>(3,4)</td></tr> </table> </tables> it produces: 3 Cheers, Dimitre. Michael Lee wrote: Dimitre's solution makes use of <xsl:key>, something that I am not familiar with. However, I believe it still doesn't work if the stylesheet has to handle an unknown number of tables. Michael Lee __________________________________________________ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/ 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
|