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

grouping, sorting and selection by language(s)

Subject: grouping, sorting and selection by language(s)
From: chunga srevenge <chunga_srevenge@xxxxxxxx>
Date: Tue, 25 Jan 2005 15:45:00 -0500 (EST)
dutch sorting
I use ASP to transform the following XML (an article
index) and XSL to HTML. The XSL groups the articles by
category, sorts them by date within each category and
only shows two articles per category. That works OK, 
but I want to show on one page only the articles in
English, on another page the ones in French, Dutch and
German, and on a third page only the ones in French
and German. How do I do that ?

<?xml version="1.0" encoding="ISO-8859-1"?>
<articles>
<article lang="fr">
<category>Catigorie 2</category>
<source>Publication in French</source>
<date pubdate="20050124">24/01/2004</date>
<art_title>Title of the first article in
French</art_title>
<firstpara>Text of the first article in
French.</firstpara>
<link>http://www.anyurl.com/articles/20050124-fr.asp</link>
</article>
<article lang="en">
<category>Category 3</category>
<source>English-language publication</source>
<date pubdate="20041221">21/12/2004</date>
<art_title>Title of the first article in
English</art_title>
<firstpara>Text of the first article in
English.</firstpara>
<link>http://www.anyurl.com/articles/20041221-en.asp</link>
</article>
<article lang="de">
<category>Kategorie 1</category>
<source>German-language publication</source>
<date pubdate="20040724">24/07/2004</date>
<art_title>Title of the first article in
German</art_title>
<firstpara>Text of the first article in
German.</firstpara>
<link>http://www.anyurl.com/articles/20040724-de.asp</link>
</article>
<article lang="fr">
<category>Catigorie 2</category>
<source>Publication in French</source>
<date pubdate="20040302">02/03/2004</date>
<art_title>Title of the second article in
French</art_title>
<firstpara>Text of the second article in
French.</firstpara>
<link>http://www.anyurl.com/articles/20040302-fr.asp</link>
</article>
<article lang="nl">
<category>Categorie 1</category>
<source>Dutch-language publication</source>
<date pubdate="20041119">19/11/2004</date>
<art_title>Title of the first article in
Dutch</art_title>
<firstpara>Text of the first article in
Dutch.</firstpara>
<link>http://www.anyurl.com/articles/20041119-nl.asp</link>
</article>
<article lang="de">
<category>Kategorie 3</category>
<source>German-language publication</source>
<date pubdate="20031224">24/12/2003</date>
<art_title>Title of the second article in
German</art_title>
<firstpara>Text of the second article in
German.</firstpara>
<link>http://www.anyurl.com/articles/20031224-de.asp</link>
</article>
<article lang="nl">
<category>Categorie 2</category>
<source>Dutch-language publication</source>
<date pubdate="20040919">19/09/2004</date>
<art_title>Title of the second article in
Dutch</art_title>
<firstpara>Text of the second article in
Dutch.</firstpara>
<link>http://www.anyurl.com/articles/20040919-nl.asp</link>
</article>
<article lang="en">
<category>Category 1</category>
<source>English-language publication</source>
<date pubdate="20040621">21/06/2004</date>
<art_title>Title of the second article in
English</art_title>
<firstpara>Text of the second article in
English.</firstpara>
<link>http://www.anyurl.com/articles/20040621-en.asp</link>
</article>
<article lang="de">
<category>Kategorie 3</category>
<source>German-language publication</source>
<date pubdate="20041029">29/10/2004</date>
<art_title>Title of the third article in
German</art_title>
<firstpara>Text of the third article in
German.</firstpara>
<link>http://www.anyurl.com/articles/20041029-de.asp</link>
</article>
<article lang="fr">
<category>Catigorie 3</category>
<source>Publication in French</source>
<date pubdate="20030320">20/03/2003</date>
<art_title>Title of the third article in
French</art_title>
<firstpara>Text of the third article in
French.</firstpara>
<link>http://www.anyurl.com/articles/20030320-fr.asp</link>
</article>
<article lang="en">
<category>Category 2</category>
<source>English-language publication</source>
<date pubdate="20030512">12/05/2003</date>
<art_title>Title of the third article in
English</art_title>
<firstpara>Text of the third article in
English.</firstpara>
<link>http://www.anyurl.com/articles/20030512-en.asp</link>
</article>
<article lang="nl">
<category>Categorie 3</category>
<source>Dutch-language publication</source>
<date pubdate="20031017">17/10/2003</date>
<art_title>Title of the third article in
Dutch</art_title>
<firstpara>Text of the third article in
Dutch.</firstpara>
<link>http://www.anyurl.com/articles/20031017-nl.asp</link>
</article>
</articles>

The XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method ="html" encoding="ISO-8859-1" />
<xsl:key name ="articles-by-category" match ="article"
use ="category" />
<xsl:template match="articles">
<xsl:for-each select
="article[count(.|key('articles-by-category', 
category)[1])=1]">
<xsl:sort select="category" />
<h2><xsl:value-of select="category" /></h2><br/>
<xsl:for-each select="key('articles-by-category',
category)">
<xsl:sort select="date/@pubdate" order="descending"/>
<xsl:if test="position() &lt;3">
<i><xsl:value-of select="source"/> - <xsl:value-of
select="date" /></i><br/>
<h4><xsl:value-of select="art_title"/></h4>
<xsl:value-of select="firstpara"/> ..
<a><xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>read full article</a><br/><br/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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.