[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Finding the maximun number of nodes

Subject: Re: Finding the maximun number of nodes
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 5 Jan 2001 01:47:59 -0800 (PST)
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.