[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Unique headers
Thanks for the update but I did not want the grouping order to be changed
.... meaning that I did not want the 'General' type to be cateogrized. Only
those that are specific types like mystery, horror etc ... This is wherein
lies my problem. I apologize for not having clarified it better. Any
thought on this?
Kanthi
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
CC: kanthi_damodaran@xxxxxxxxxxx
Subject: Re: Unique headers
Date: Wed, 4 Apr 2001 21:21:20 -0700 (PDT)
Your desired output appears to treat General movies special in
that they are not categorized or indented:
> Chocolat
> Billy
> Mystery
> Ellen Brokovich
> Pelican Brief
> Horror
> Nightmare on Elm Street
> Blair Witch Project
> The Emperor's Groove
> Toy Story
I ignored this and additionally changed your MoviesList tag to
MovieList (double plural). This is a grouping problem solved
by the so called "Muenchian Method" (named after Steve Muench
who proposed it). You can serach the archives for a full
explanation of the technique. The output is simple text
with <br/> elements; you can html-ify it to your liking:
General
-Chocolat
-Billy
-The Emperor's Groove
-Toy Story
Mystery
-Ellen Brokovich
-Pelican Brief
Horror
-Nightmare on Elm Street
-Blair Witch Project
Regards,
Dan
************
File: MovieList.xml
<?xml-stylesheet type="text/xsl" href="MovieList.xsl"?>
<MovieList>
<Movie>
<Type>General</Type>
<Title>Chocolat</Title>
</Movie>
<Movie>
<Type>General</Type>
<Title>Billy</Title>
</Movie>
<Movie>
<Type>Mystery</Type>
<Title>Ellen Brokovich</Title>
</Movie>
<Movie>
<Type>Mystery</Type>
<Title>Pelican Brief</Title>
</Movie>
<Movie>
<Type>Horror</Type>
<Title>Nightmare on Elm Street</Title>
</Movie>
<Movie>
<Type>Horror</Type>
<Title>Blair Witch Project</Title>
</Movie>
<Movie>
<Type>General</Type>
<Title>The Emperor's Groove</Title>
</Movie>
<Movie>
<Type>General</Type>
<Title>Toy Story</Title>
</Movie>
</MovieList>
File: MovieList.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="MovieCategories" match="MovieList/Movie" use="Type"/>
<xsl:template match="/">
<xsl:for-each select="MovieList/Movie[Type and
generate-id(.)=generate-id(key('MovieCategories',Type))]">
<xsl:variable name="group" select="Type"/>
<xsl:value-of select="$group"/><br/>
<xsl:for-each select="/MovieList/Movie[Type=$group]">
-<xsl:value-of select="Title"/><br/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
> Chocolat
> Billy
> Mystery
> Ellen Brokovich
> Pelican Brief
> Horror
> Nightmare on Elm Street
> Blair Witch Project
> The Emperor's Groove
> Toy Story
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|