|
next
|
Subject: Keeping track of position after sorting Author: ishpal singh Date: 07 Jun 2011 02:22 PM
|
Hi,
I've been trying to apply xsl to the result set returned by Analysis Service database.
The result set looks like the following...
<Axis name="Axis1">
<Tuples>
<Tuple>
<Member Hierarchy="[Org].[Class1]">
<UName>[Org].[Class1].&[10629]</UName>
<Caption>Independent</Caption>
<LName>[Org].[Class1].[Ownership]</LName>
<LNum>2</LNum>
<DisplayInfo>65898</DisplayInfo>
<PARENT_UNIQUE_NAME>[Org].[Class1].&[2]</PARENT_UNIQUE_NAME>
</Member>
</Tuple>
<Tuple>
<Member Hierarchy="[Org].[Class1]">
<UName>[Org].[Class1].&[14331]</UName>
<Caption>A #5839</Caption>
<LName>[Org].[Class1].[Owner Region]</LName>
<LNum>3</LNum>
<DisplayInfo>65537</DisplayInfo>
<PARENT_UNIQUE_NAME>[Org].[Class1].&[10629]</PARENT_UNIQUE_NAME>
</Member>
</Tuple>
....
</Axis>
<CellData>
<Cell CellOrdinal="0">
<FmtValue>Ownership</FmtValue>
</Cell>
<Cell CellOrdinal="1">
<ForeColor>0</ForeColor>
<FmtValue>73%</FmtValue>
</Cell>
<Cell CellOrdinal="2">
<ForeColor>0</ForeColor>
<FmtValue>68%</FmtValue>
</Cell>
<Cell CellOrdinal="3">
<ForeColor>0</ForeColor>
<FmtValue>70%</FmtValue>
</Cell>
<Cell CellOrdinal="4">
<ForeColor>0</ForeColor>
<FmtValue>59%</FmtValue>
</Cell>
<Cell CellOrdinal="5">
<FmtValue>Owner Region</FmtValue>
</Cell>
<Cell CellOrdinal="6">
<ForeColor>0</ForeColor>
<FmtValue>75%</FmtValue>
</Cell>
.....
</CellData>
Each Tuple above has a corresponding set of Cells in the CellData.
So, if the file is parsed sequentially, the relevant cells can be gathered using the position() of the Tuple.
However, if the Tuple is sorted using xsl-sort, LNum property, and iterated over using for-each, the position of the Tuples is now changed and so can not find the corresponding Cell for the Tuple.
How can I keep track of the Tuple ordinal based on UName, so that I can get to the relevant cell.
I have created a key for the UName as <xsl:key name="tuples-by-uName" match="/xa:root/xa:Axes/xa:Axis/xa:Tuples/xa:Tuple" use="xa:Member/xa:UName" />
<xsl:key name="tuples-by-parentUName" match="/xa:root/xa:Axes/xa:Axis/xa:Tuples/xa:Tuple" use="xa:Member/xa:PARENT_UNIQUE_NAME" />
And want to iterate over the tuples using something like the following.
<xsl:for-each select="key('tuples-by-parentUName', $thisQuestion/xa:Member/xa:UName)">
<xsl:sort data-type="number" select="xa:Member/xa:LNum" order="descending"/>
Here I need the original position of the Tuple so I can calculate the position of the Cell.
Have spent a lot of time, but can not figure this one out.
Please help!
-Ishpal
|
|
|