Grouped and sorted table row numbers
Good morning,
Given this input:
<Product>
<ProductType>Non-Subscription</ProductType>
<ProductGrouping>License 1</ProductGrouping>
<ProductName>Renewal</ProductName>
</Product>
<Product>
<ProductType>Subscription</ProductType>
<ProductGrouping>License 1</ProductGrouping>
<ProductName>New</ProductName>
</Product>
<Product>
<ProductType>Subscription</ProductType>
<ProductGrouping>License 2</ProductGrouping>
<ProductName>Renewal</ProductName>
</Product>
<Product>
<ProductType>Subscription</ProductType>
<ProductGrouping>License 2</ProductGrouping>
<ProductName>New</ProductName>
</Product>
I am sorting and grouping to create a table in WordML:
<xsl:for-each select="//ProductName[generate-id()=generate-id(key('subscriptionProducts', preceding-sibling::ProductGrouping) [1])]">
<xsl:sort select="preceding-sibling::ProductType='Subscription'" order="descending"/>
<xsl:sort select="preceding-sibling::ProductGrouping"/>
etc.
...
<xsl:for-each select="key('subscriptionProducts', preceding-sibling::ProductGrouping)">
<xsl:sort select="."/>
etc.
Which seems to be working correctly, producing:
Subscription
License 1
New
License 2
New
Renewal
Non-Subscription
License 1
Renewal
But then, in order to generate cell formulas, I need to find the sorted row number of each New or Renewal row, producing something like:
Subscription
License 1
New =C3
License 2
New =C5
Renewal =C6
Non-Subscription
License 1
Renewal =C9
Is this possible? Using position() seems promising but I've been wading through the FAQs and just can't seem to wrap my head around how it would work with the nested for-each loops.
Any help would be much appreciated.
Many thanks,
Allison
|