Subject: Re: [xsl] string-length of all label attributes From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 8 Jul 2004 11:11:15 +0100 |
//@label selects a node set count() expects a node set and returns its size, so > But count(//@label) works fine. But if you use (any) function that expects a string and give it a node set then it will sort the nodes into document order, and take the string value of the first node as its argument. (In XSLT2 draft this is an error as often as not, but XSLT1 rarely generates run time errors) so you get > When I apply string-length(//@label) in the root I only get the length > of the first attribute. You might want <xsl:variable name="x"> <xsl:for-each select="//@label"> <xsl:value-of select="."/> </xsl:for-each> </xsl:variable> <xsl:value-of select="string-length($x)"/> which would work but actually builds the (result tree fragment containing the) string consisting of the concatenation of all the labels which might be expensive in terms of space if you really have lots of them. An alternative would be a recursive template that walks over the tree adding up the string length as it finds labels. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] string-length of all label at, Robert Soesemann | Thread | RE: [xsl] string-length of all labe, Jarno.Elovirta |
Re: [xsl] string-length of all labe, George Cristian Bina | Date | RE: [xsl] string-length of all labe, Robert Soesemann |
Month |