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

Need help - Getting the value of an attribute from a

Subject: Need help - Getting the value of an attribute from a following-sibling
From: "Mario Grech" <mariogrech@xxxxxxxxxxx>
Date: Sun, 22 Aug 2004 00:03:14 +0000
mario grech
The problem I have is basically this:

I am using an <xsl:key/> that accepts an id attribute as a parameter. So when I use the key function I usually call it as: key(accountName, @id), which retrieves the element from the match xpath expression, with the specified id attribute. This I can do.

I would now like to pass the value of the id-attribute from the following-sibling (not the current node) into the function. But I don't know how to retrieve this attribute value so that I can pass it into the key function. Perhaps there is another way to avoid this problem?

Here is a snippet from my XSL that illustrates the problem:

<xsl:key name="TotalRevenue" match="Stock/Account[@label='TotalRevenue' and @period='Quarterly']/Item" use="@id"/>
<xsl:key name="ExpenseOne" match="Stock/Account[@label='ExpenseOne' and @period='Quarterly']/Item" use="@id"/>
<xsl:key name="ExpenseTwo" match="Stock/Account[@label='ExpenseTwo' and @period='Quarterly']/Item" use="@id"/>
<xsl:for-each select="Account[@label='TotalRevenue' and @period='Quarterly']/Item">
<xsl:value-of select='format-number( (key("TotalRevenue",@id) - following-sibling::*[1],"#0.0%;(#0.0%)")' />

This works fine. I look through the Items in the TotalRevenue account, and for each Item I subtract the value of the next item in the TotalRevenue account. But now I still want to loop through the items in the TotalRevenue account, but I ALSO want to subtract the value of the next Item in this account AND the values of the items in the ExpenseOne and ExpenseTwo accounts which have the SAME id (the id of the following-sibling, not the node selected in the for-each, in the TotalRevenue account).

Any help would be much, much appreciated.


Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN. Premium right now and get the first two months FREE*.

Current Thread


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.
First Name
Last Name
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.