Subject: Re: [xsl] Finding parent of the middle child From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 20 Jun 2005 23:52:55 +0100 |
(//rec_gear_sec/*)[$gearMid] is returning the very first child, even though $gearMid returns 34. I wasn't even sure if that syntax would be allowed in 1.0. This is a FAQ. The expression is equivalent to //rec_gear_sec/* and selects _all_ such elements not just the first (as you would see if you used xsl:copy-of xsl:value-of always discards all but the first node. The predicate [$gearMid] is the same as [true()] so doesn't filter anything as a result tree fragment acts teh same way in a predicate as a node set, that is a node set counts as true if it is non-empty and false if it is empty. Result tree fragments always correspnd to node sets with exactly one node (a root node) so always count as true in a boolean context. <xsl:variable name="gearMid"> <xsl:value-of select="round(count(//rec_gear_sec/*) div 2)"/> </xsl:variable> is a result tree fragment with a root node and a text node with string vakue the decimal represntation of the number. You don't want that, you want the number, which is <xsl:variable name="gearMid"> select="round(count(//rec_gear_sec/*) div 2)"/> If $gearMid is a number defined like this [] will be a numeric predicate rather than a boolean one. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 -> |
---|---|---|
RE: [xsl] Finding parent of the mid, Michael Kay | Thread | Re: [xsl] Finding parent of the mid, Sam D. Chuparkoff |
Re: [xsl] dynamic document() templa, David Carlisle | Date | Re: [xsl] Finding parent of the mid, Sam D. Chuparkoff |
Month |