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

Re: Finding parent of the middle child

Subject: Re: Finding parent of the middle child
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 20 Jun 2005 23:52:55 +0100
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
________________________________________________________________________

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.