Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2004, 02:21 PM
Authorized User
 
Join Date: Nov 2004
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>
 
Old November 12th, 2004, 02:34 PM
Authorized User
 
Join Date: Nov 2004
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?
 
Old November 13th, 2004, 07:07 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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)
 
Old November 15th, 2004, 04:08 PM
Authorized User
 
Join Date: Nov 2004
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?






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





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