[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with Muenchian grouping

Subject: Re: Problem with Muenchian grouping
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 7 Nov 2003 19:25:32 +0100
projectmission
> I'm a newbie at XSL, and I have a question regarding Muenchian grouping.
> I've read some threads about it, but can't figure out how to solve my
> problem.

[snip]

> I'm interested in the children of <data> that have an <action> child: I
> would like to group them by name and perform some processing on them.
> The problem is I cannot know those names (that is, each element is
> optional), and the number of elements of each category is undefined.
> So I don't know how to define the <xsl:key> element that I need.
> I have tried <xsl:key name="records-by-name" match="/*/*[action]"
> use="name()"> but that doesn't seem to work.

Why, it works:

This transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text"/>

  <xsl:key name="kWithAction" match="data/*[action]"
   use="name()"/>

    <xsl:template match="/">
      <xsl:for-each
       select="/*/data/*[generate-id()
                        =
                         generate-id(key('kWithAction',
                                         name()
                                         )[1]
                                     )
                        ]">
        <xsl:value-of select="concat(name(), '&#xA;')"/>
      </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

when applied on this xml.source:

<dump>
    <identification>
        ...
    </identification>
    <data>
        <project>
            ....
        </project>
        ...
        <projectmission>
            <action> delete</action>
             ....
        </projectmission>
        ...
        <breakdown>
            <action> update</action>
            ....
        </breakdown>
        <projectmission>
            <action> update</action>
             ....
        </projectmission>
        <breakdown>
            <action> add</action>
            ....
        </breakdown>
        <projectscope>
            <action> update</action>
             ....
        </projectscope>
        ....
    </data>

</dump>


produces the wanted result:

projectmission
breakdown
projectscope



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.