[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Finding parent of the middle child
(//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 ________________________________________________________________________
|
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
|