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

RE: matching nodes and counting columns

Subject: RE: matching nodes and counting columns
From: Ben Robb <Ben@xxxxxxxxxx>
Date: Tue, 15 Aug 2000 09:58:30 +0100
get number of matching templates
> How can I apply one template to first <table> and another 
> template to the
> second <table>,
> or how can I skip first and third tables and apply template 
> to the second
> only?
Either name your templates, and use xsl:call-template, or create more
specific templates for your tables. If they have distinguishing features,
use filters in your XPath expressions:

e.g.

<xsl:template match="table[@name='useMe']">

Or, if they do not, and you are certain that you can say where in the
document the special cases are, use the position() method in your XPath
statement:

<xsl:template match="table[position() = 2]">

which will take the nodeset created when you call the <xsl:apply-templates
/> method on the <body> node, and apply this particular template to the
second node.

Or, if you were only interesting in processing the one specific table
element (and its children), and no other child of the body tag, you could
use the select attribute in <xsl:apply-templates />, using the same XPath
statements and filters as above.


> 2. <table> tag in wml requires columns attribute with number 
> of colums.
> So actually I need to count number of <td> in first <tr> of the table
> (lets say there are no colspans and rowspans in html)
> <xsl:value-of select="count(tr/td)" /> - gives me a number of 
> all <td> in
> the table
> I found a way out:
> <xsl:value-of select="count(tr/td) div count(tr) "/>
> (to divide number of cells by number of rows :-))
> but that is probably not the best way doing it

Thats as elegant a way as any other. Though you could probably extend it to
account for rowspan and colspan attributes to make it more generic.

Ben


 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.