[xsl] Need help - Getting the value of an attribute from a following-sibling

Subject: [xsl] 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
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%)")' />
</xsl:for-each>


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).

Ideas?
Any help would be much, much appreciated.

Mario

_________________________________________________________________
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