This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Calculation using the position of an element??
- From: "Clifford, Karen" <Karen dot Clifford at fid-intl dot com>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 20 Sep 2002 10:39:45 +0100
- Subject: RE: [xsl] Calculation using the position of an element??
- Reply-to: xsl-list at lists dot mulberrytech dot com
Thank you very very much!!
-----Original Message-----
From: Jarno.Elovirta@nokia.com [mailto:Jarno.Elovirta@nokia.com]
Sent: Friday, September 20, 2002 9:58 AM
To: xsl-list@lists.mulberrytech.com
Subject: RE: [xsl] Calculation using the position of an element??
Hi,
> > Ive tried to come up with an XPath solution involving
> position() (one
> > line) to produce a certain value using <xsl:value-of
> select="......."/>
> >
> My Sample XML File
>
> > <tgroup cols = "5">
> > <colspec colname="col1"/>
> > <colspec colname="colspec1"/>
> > <colspec colname="col2"/>
> > <colspec colname="col4"/>
> > </tgroup>
> >
> > I have two different values (say x and y) elsewhere in the
> xml doc and I
> > need to perform a small calculation that I will now outline in
> > Pseudocode...
> >
> > If x="colspec1" then
> > position1 = 2
> > If y="col4" then
> > position2 = 4
> > Result= position2 - position1
> >
> > ie Result=2
<xsl:value-of select="count(colspec[@colname =
$y]/preceding-sibling::colspec) - count(colspec[@colname =
$x]/preceding-sibling::colspec)" />
Jarno
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list