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 | 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 November 12th, 2004, 02:21 PM
Authorized User
 
Join Date: Nov 2004
Location: , , .
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default indexing within grouping

I've got a structure like
Code:
<links>
  <linktype1>
     <link parent="1" target="3"/>
     <link parent="1" target="4"/>
     <link parent="1" target="5"/>
     <link parent="2" target="6"/>
     <link parent="2" target="7"/>
  </linktype1>
  <linktype2>
     <link parent="3" target="8"/>
     <link parent="1" target="9"/>
  </linktype2>
...
</links>
The final simplified structure looks like:

Code:
<links>
     <link parent="1" order="1" target="3"/>
     <link parent="1" order="2" target="4"/>
     <link parent="1" order="3" target="5"/>
     <link parent="2" order="1" target="6"/>
     <link parent="2" order="2" target="7"/>
     <link parent="3" order="1" target="8"/>
     <link parent="1" order="1" target="9"/>
...
<links>
However, I am missing the last link (parent=1, target=9)

I need other to be the index based on the parent (per group). what I have now creates a temporary variable using the Muenchian method and then uses the position() to get the order. The actual 'links' contain much more information, and involve copying complex nodes..

Code:
<xsl:key name="linkbyparent" match="link" use="@parent" />
<xsl:variable name="merged">
<links>
    <xsl:for-each select="*\link[count(. | key('linkbyparent', @parent)[1]) = 1]">
        <xsl:for-each select="key('linkbyparent', @parent)">
        <link>
            <xsl:copy-of "@*"/>
            <xsl:attribute name="order"><xsl:value-of select="position()"/></xsl:attribute>
        </link>
        </xsl:for-each>
    </xsl:for-each>
</xsl:variable>
Reply With Quote
  #2 (permalink)  
Old November 12th, 2004, 02:34 PM
Authorized User
 
Join Date: Nov 2004
Location: , , .
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default

    <xsl:for-each select="*\link[count(. | key('linkbyparent', @parent)[1]) = 1]">
seems to be the problem line.. anyone know a different method, or one that doesn't use key?
Reply With Quote
  #3 (permalink)  
Old November 13th, 2004, 07:07 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Haven't examined your code but your separator is wrong here:
Code:
<xsl:for-each select="*\link[count(. | key('linkbyparent', @parent)[1]) = 1]">
should be:
Code:
<xsl:for-each select="*/link[count(. | key('linkbyparent', @parent)[1]) = 1]">
--

Joe (Microsoft MVP - XML)
Reply With Quote
  #4 (permalink)  
Old November 15th, 2004, 04:08 PM
Authorized User
 
Join Date: Nov 2004
Location: , , .
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default

thanks for the feedback, I checked that out in my code, but I'm using 2 for-each loops there instead...

to rephrase my problem:
is there a way to group nodes where the sources are differentiated?, you can have seperate sets of groups for each linktype?

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
CANNOT APPLY INDEXING WITH [] pallone .NET Framework 2.0 7 April 8th, 2008 06:40 AM
Protect cells and allow grouping/un-grouping sfreuden Excel VBA 4 December 14th, 2006 08:01 AM
indexing vohra_vikas SQL Server 2000 2 September 28th, 2004 11:49 PM
Indexing. kilika SQL Server 2000 3 May 24th, 2004 03:14 PM



All times are GMT -4. The time now is 11:46 PM.


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