xsl-list
[Top] [All Lists]

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

2008-01-08 09:23:59
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(_at_)indiana(_dot_)edu
________________________________________
From: Trish(_at_)musictoday(_dot_)com [Trish(_at_)musictoday(_dot_)com]
Sent: Tuesday, January 08, 2008 11:15 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--