RE: [xsl] Sorting and Grouping Alphabetically: Two Levels

Subject: RE: [xsl] Sorting and Grouping Alphabetically: Two Levels
From: "Wei, Alice J." <ajwei@xxxxxxxxxxx>
Date: Tue, 8 Jan 2008 11:20:21 -0500
Hi, Trish:


   You don't need any of it if you only want to display the stuff as you have
had in your example.

This is your XML:

<Events>
    <Festival id="2005">
        <Artist name="beta1">
            <Date></Date>
            <Stage></Stage>
        </Artist>
        <Artist name="alpha1">
            <Date></Date>
            <Stage></Stage>
        </Artist>
        <Artist name="beta2">
            <Date></Date>
            <Stage></Stage>
        </Artist>
        <Artist name="alpha2">
            <Date></Date>
            <Stage></Stage>
        </Artist>
    </Festival>
    <Festival id="2006">
        <Artist name="gamma">
            <Date></Date>
            <Stage></Stage>
        </Artist>
        <Artist name="delta2">
            <Date></Date>
            <Stage></Stage>
        </Artist>
        <Artist name="delta1">
            <Date></Date>
            <Stage></Stage>
        </Artist>
    </Festival>
</Events>

For your output, I am not sure how you want your format would look, but you
can do something like

 <xsl:template match="Events">
        <xsl:for-each select="Festival" >
            <xsl:sort select="./@id" order="descending"/>
            <xsl:sort select="./@name" order="descending"/>
            <xsl:value-of select="./@id"/><br />
            <xsl:for-each select="Artist">
                  <ul><li><xsl:value-of
select="./@name"/></li></ul></xsl:for-each>
        </xsl:for-each>
    </xsl:template>

to reach the output you want. You can assign your stuff to descending for one
of them if you want to apply this to other types of contexts. In your case, I
have set it to HTML format, but feel free to implement it to something else.

I hope this helps.
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei@xxxxxxxxxxx
________________________________________
From: Trish@xxxxxxxxxxxxxx [Trish@xxxxxxxxxxxxxx]
Sent: Tuesday, January 08, 2008 11:15 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Sorting and Grouping Alphabetically: Two Levels

Oh. So sorry. x:node-set() is not available. There is lots of additional
mark-up but I extracted the essentials for the sorting and grouping that
I was attempting. I realize that the display I represented requires the
extra mark-up and I can easily put that in later. Do you think the path
I've started down will work at all? Or should I scrub and try something
totally different?

Trish

Current Thread