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

Re: Sort-grouping problem

Subject: Re: Sort-grouping problem
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Wed, 17 Apr 2002 08:57:28 +0000
xml p1 p2 p3
Hi jeni,

Thank you, I think I know a little more about how sort works...

You're currently using xsl:for-each to iterate over the unique dates;
why not sort them in the same way as you were before (remembering that
the context nodes are Date elements this time rather than News
elements)?

But.... I think keeping track of context node is exactly my problem.


I thought my whole problem was sorting the results, but when I try to make yet another group (within the group by date), I am faced with difficulties (which I hope someone can help me with):

Taking my stylesheet below (not sorting it at the moment), I would also want to group by P1 (the XML is at the buttom of the mail).

I thought I could do something like this:
..
<xsl:for-each select="$unique-dates">
<xsl:variable name="unique-p1s" select=".[not(P1=preceding-sibling::News/P1)]/P1"/>
..
but I get the error:
Expected token 'eof' found '['. .-->[<--not(P1=preceding-sibling::News/P1)]/P1


---
<xsl:variable name="unique-p1s" select="/NewsList/List/News[not(P1=preceding-sibling::News/P1)]/P1"/>
does not give any errors, but will take _all_ P1's, not just those within a given date (unique-dates[n], n>=1)


Can anybody can help me with how I go about things like this: what is the context within the <xsl:for-each select="$unique-dates">, how I group within a group (and perhaps within this, the third group..) ?

Sincerly
Ragulf Pickaxe :)


Part of xsl-stylesheet: <xsl:template name="group-by-date"> <xsl:variable name="unique-dates" select="/NewsList/List/News [not(Date=preceding-sibling::News/Date)]/Date"/> <xsl:for-each select="$unique-dates"> Date is: <xsl:value-of select="."/><br/> <xsl:for-each select="/NewsList/List/News[Date=current()]"> <H1><xsl:value-of select="P1"/></H1> into another template --> </xsl:for-each> </xsl:for-each> </xsl:template>

XML input:
<NewsList>
<Meta attributeA="AnAttribute">
<One>Just MetaData</One>
<Two>Not important here</Two>
</Meta>
<List>
<News NewsType="1"><Date>03-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3>More News</P3>
</News>
<News NewsType="2"><Date>03-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3>More News</P3>
</News>
<News NewsType="2"><Date>06-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3>More News</P3>
</News>
<News NewsType="2"><Date>04-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3></P3>
</News>
<News NewsType="2"><Date>05-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3></P3>
</News>
<News NewsType="2"><Date>04-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3>The above P3 tags where empty</P3>
</News>
<News NewsType="2"><Date>01-02-2002</Date><P1>This is a newsletter or some such</P1><P2>The News</P2><P3>Yet more News</P3>
</News>
</List>
</NewsList>



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx



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.