Subject: Re: [xsl] Finding parent of the middle child From: "Sam D. Chuparkoff" <sdc@xxxxxxxxxx> Date: Mon, 20 Jun 2005 15:00:45 -0700 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Finding parent of the middle , Brook Ellingwood | Thread | RE: [xsl] Finding parent of the mid, Michael Kay |
Re: [xsl] dynamic document() templa, Sam D. Chuparkoff | Date | RE: [xsl] Finding parent of the mid, Brook Ellingwood |
Month |