[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: "Sam D. Chuparkoff" <sdc@xxxxxxxxxx>
Date: Mon, 20 Jun 2005 15:00:45 -0700
chuparkoff
On Mon, 2005-06-20 at 13:21 -0700, Brook Ellingwood wrote:
> I'm having a hard time breaking a list of nested elements into a
> two-column layout in HTML output.
> 
> There are several section elements containing a variable number of
> child elements. I want to return a count of all the child elements and
> identify the mid point of all the child elements. At the top of my
> XSL, I do this with:
> 
> <xsl:variable name="gearMid">
> 	<xsl:value-of select="round(count(//rec_gear_sec/*) div 2)"/>
> </xsl:variable>
> 
> This returns "34."
> 
> Next, I want to identify which parent element contains the child at
> position 34, so I can split the list beginning with the following
> sibling. However, I can't even get as far as finding the matching
> child when I try a similar method to returning the count:
> 
> <xsl:variable name="gearSplit">
> 	<xsl:value-of select="//rec_gear_sec/*[position() = $gearMid]"/>
> </xsl:variable>
> 
> That returns nothing. When I substitute numbers for the variable, I
> discover that it's matching the first child element at that position
> *within its parent element* not within the list of all child elements.
> Even though this is behavior that I've used and expected in the past,
> I'm now confused as to why the context is interpreted differently for
> those two matches.

Quick pointer. version="2.0", right?

What you're looking for is:

(//rec_gear_sec/*)[$gearMid]

I also, against my better judgement, found it tempting to disbelieve the
spec about dynamic context sometimes until I realized how easy it is to
manipulate sequences.

sdc

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.