Re: [xsl] grouping and discarding duplicates

Subject: Re: [xsl] grouping and discarding duplicates
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Thu, 1 Jul 2004 17:05:57 +0100
Hi Nathan,
I cant completely write your XSL. infact I havent even looked at your XSL
code.
What I have done will take you in the direction ...
I have written an xsl that will eliminate duplicate
<xcal:vevent>
with the same <obprcal:eventid> value

in other words, if there are more than one
<xcal:vevent> with the same value for <obprcal:eventid>,
then only one of them will be selected.

Following is the code...

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:obprcal="http://spaceresearch.nasa.gov/calendar";
xmlns:xcal="http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-
01.txt" xmlns="http://spaceresearch.nasa.gov/calendar";>
 <xsl:key match="/obprcal:top/xcal:vcalendar/xcal:vevent" name="events"
use="obprcal:eventid"/>
 <xsl:template match="/">
  <!-- get unioe-nodes -->
  <xsl:for-each
select="/obprcal:top/xcal:vcalendar/xcal:vevent[generate-id(.) =
generate-id(key('events',obprcal:eventid)[1])]">
   <xsl:sort order="ascending" data-type="number" select="obprcal:eventid"/>
   <xsl:value-of select="obprcal:eventid"/>
<!--

you can add your code here,, I have just printed the value of
obprcal:eventid, so that you see the result ..
-->
   <br/>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

First Run this xsl as is against your XML and see if you are happy ..

Let me know if  thaz not what you want

Hope this helps
Vasu Chak


----- Original Message ----- 
From: "Nathan Shaw" <n8_shaw@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, July 01, 2004 4:03 PM
Subject: [xsl] grouping and discarding duplicates


> Hi all. I have an XSLT that sorts and groups on date
> per category. However, the client has changed the
> specs and now wants multiple categories and an All
> Categories page. This means that I have to shed
> duplicate events that appear in different categories
> and group the categories for display. I have spent a
> day and a half trying to figure out how to do this
> without much luck.
>
> What I want to end up with is a record like this:
>
> <DataTableRow>
>   <DataTableRowCell><strong>HOLIDAY - Labor
> Day</strong></DataTableRowCell>
> </DataTableRow>
> <DataTableRow>
>   <DataTableRowCell>September 06, 2004 08:00
> AM-September 06, 2004 05:00 PM (All
> Day)</DataTableRowCell>
> </DataTableRow>
> <DataTableRow>
>   <DataTableRowCell>Categories: Education Events,
> External Technical Meetings, General Interest, Public
> Outreach Events, Industry</DataTableRowCell>
> <DataTableRow>
>   <DataTableRowCell> </DataTableRowCell>
> </DataTableRow>
>
> Can someone lend a hand? The XML and XSLT files are
> too large to include, but can be downloaded here, in
> the XML-XSLT folder:
>
> http://briefcase.yahoo.com/n8shaw
>
> Thanks a bunch in advance!
>
> --Nathan
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
>
> --+------------------------------------------------------------------
> 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@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
>
>

Current Thread