RE: [xsl] xpath question, getting count of cousins

Subject: RE: [xsl] xpath question, getting count of cousins
From: "Marty McKeever" <marty.mckeever@xxxxxxxxxx>
Date: Tue, 25 Feb 2003 16:44:44 -0500
this seemed to do the trick:
count(preceding::input[@type=$inputGroupType][ancestor::group/@name=$inputGr
oupName])


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Marty
> McKeever
> Sent: Tuesday, February 25, 2003 4:13 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] xpath question, getting count of cousins
>
>
> Trying to count the preceding-siblings?-cousins? of input[@type='radio']
> that belong to the current group or form:
>
> Input example:
> <html>
> <form id="1">
> 	<input type="radio" />
> </form>
> <form id="2">
> 	<input type="text" />
> 	<radiogroup>
> 	<input type="radio" />
> 	<p>
>  		<input type="radio" />
> 		<input type="radio" />
> 	</p>
> 	<input type="radio" />
> 	<input type="radio" />
> 	</radiogroup>
> </form>
> </html>
>
> processing form[@id='2'], the result of my xpath should enable
> the following
> indexing of radio buttons:
>
> Output example:
> <form id="2">
> 	<input type="text" />
> 	<input type="radio" id="radio_1"/>
> 	<p>
>  		<input type="radio" id="radio_2" />
> 		<input type="radio" id="radio_3" />
> 	</p>
> 	<input type="radio" id="radio_4" />
> 	<input type="radio" id="radio_5" />
> 	</radiogroup>
> </form>
>
> the closest i've come is with match="input[@type='radio']"
> <xsl:variable name="idx"
> select="count(preceding-sibling::input[@type='radio'])+1"/>
> which only works per level:
> 	1
> 		<p>
> 			1
> 			2
> 		</p>
> 	2
> 	3
>
> or
> <xsl:variable name="idx"
> select="count(preceding::input[@type='radio'])+1"/>
> which ignores the radioGroup boundary.
>
> Basically each radio needs to count the preceding relatives of his own
> radiogroup family.
>
> or am i thinking this through wrong...?
>
> TIA!
>
>
>
>
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of G. Ken Holman
> > Sent: Tuesday, February 25, 2003 1:47 PM
> > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [xsl] xpath question, getting last instance of element
> >
> >
> > At 2003-02-25 13:37 -0500, Alan Stein wrote:
> > >I'm trying to figure out how to select the final instance of
> > "DDD" in the
> > >following example,
> >
> > (//DDD)[last()]
> >
> > By putting the XPath expression in parentheses you are obtaining
> > the set of
> > all DDD elements from the whole document.  Then, applying the
> > predicate to
> > the entire set, you end up with the last DDD.  Had you not used
> > parentheses
> > you would end up with the set of all DDD elements that are the last of
> > their sibling DDD elements.
> >
> > I hope this helps.
> >
> > ................... Ken
> >
> >
> > --
> > Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO
> >                               North America:      June 16-20, 2003
> >
> > G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
> > Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
> > Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
> > ISBN 0-13-065196-6                      Definitive XSLT and XPath
> > ISBN 0-13-140374-5                              Definitive XSL-FO
> > ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
> > ISBN 1-894049-10-1              Practical Formatting Using XSL-FO
> > Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
> >
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread