[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Counting nodes
wd-xsl doesnt have a count function, so you have to write your own. This should do what you want: function count(obj,tagName) { var a = getElementsByTagName(tagName); return a.length; } Pass to it the parent element which contains all of the nodes you wish to count, and the element name. For example: <xsl:template match="lineage"> <xsl:eval>count(this,'procstep')</xsl:eval> </xsl:template> Or, the less reusable but ultimately better: <xsl:template match="lineage"> <xsl:eval>getElementsByTagName('procstep').length</xsl:eval> </xsl:template> Of course, to save your head from bursting, its easier to move to XSLT and use the count() function or <xsl:number> cheers andrew -----Original Message----- From: Mike Leahy [mailto:mgleahy@xxxxxxxxxxxxxxxx] Sent: 02 July 2002 14:52 To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: Counting nodes Hello list, I am using the namespace "http://www.w3.org/TR/WD-xsl" I would like to be able to count the occurrance of a particular tag (e.g. "procstep" can occur multiple times within "metadata/dataqual/lineage" in the XML files I am using). The count function is not a recognized function in the namespace I am using - is there any other way I could get this number? Mike XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002 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
|