Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 21st, 2006, 09:30 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

Reply With Quote
  #2 (permalink)  
Old April 24th, 2006, 10:06 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Good morning,

Well, it looks like the solution to this is the node-set() extension function. I was able to wrap the generated table within a variable and then access the sorted row numbers.

<xsl:for-each select="exsl:node-set($temporary-tree)/w:tr">
<xsl:variable name="rowPos" select="position()"/>

Allison

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems rendering to a table with sorted results jlmacdonald XSLT 6 March 27th, 2008 05:54 PM
How to get least value numbers in a sorted array? ashokparchuri Other Programming Languages 3 December 5th, 2006 09:25 AM
UPDATING 1 row with another row in same table rit01 SQL Server 2000 3 February 19th, 2006 08:55 AM
sorted table crmpicco Javascript How-To 0 March 17th, 2005 10:29 AM
numbers on grouped records mkapler Access 2 March 6th, 2005 05:49 PM



All times are GMT -4. The time now is 03:07 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.