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

RE: Calculation using the position of an element??

Subject: RE: Calculation using the position of an element??
From: Jarno.Elovirta@xxxxxxxxx
Date: Fri, 20 Sep 2002 11:58:01 +0300
RE:  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


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.