Need help - Getting the value of an attribute from a
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::*,"#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).
Ideas? 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*.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format