Subject: Re: [xsl] Combine two diff xmls - Sorting by date From: sudheshna iyer <sudheshnaiyer@xxxxxxxxx> Date: Tue, 27 May 2008 12:58:36 -0700 (PDT) |
As an extension to the below one, I need to combine feeds from two diff sources and sort on date though the feeds have diff elements: File1.xml: <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:aaa="http://www.aaa.org/bbb/aaa_Spec/"> <channel> <title>Title1</title> <link>link1</link> <description>Description 1</description> <language>en-us</language> <item> <title>item 1</title> <description>item desc 1</description> <SortDate>Wed, 18 Feb 2008 11:18:41 -0000</SortDate> <link>item link1</link> <guid>item guid1 </guid> <aaa:modelDate>Sat, 15 Mar 2008 12:18:41 -0000</aaa:modelDate> </item> <item> <title>item 2</title> <description>item desc 2</description> <SortDate>Wed, 19 Feb 2008 11:18:41 -0000</SortDate> <link>item link1</link> <guid>item guid1 </guid> <aaa:modelDate>Sat, 16 Mar 2008 12:18:41 -0000</aaa:modelDate> </item> </channel> </rss> File2.xml <?xml version="1.0" encoding="UTF-8"?> <Annoucements> <announcement> <anc_date>2008-03-11</anc_date> <anc_title>Annoucement Title1</anc_title> </announcement> <announcement> <anc_date>2008-07-14</anc_date> <anc_title>Annoucement Title2</anc_title> </announcement> </Annoucements> I should be able to combine File12.xml and File2.xml, sort them by date in desc order and display the output in the following format. Output format: Annoucement Title2 14 Jul 2008 Annoucement Title1 11 Mar 2008 item 1 19 Feb 2008 item 2 18 Feb 2008 How can achieve this? --- sudheshna iyer <sudheshnaiyer@xxxxxxxxx> wrote: > Excellent! Thank you very much for your help. > > --- Martin Honnen <Martin.Honnen@xxxxxx> wrote: > > > sudheshna iyer wrote: > > > I am using xsl:stylesheet version="1.0". > > > > Here is an XSLT 1.0 stylesheet that produces the > > result you described. > > You only need to complete the "translation table" > > for the months: > > > > <xsl:stylesheet > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > xmlns:dt="http://example.com/2008/data" > > version="1.0"> > > > > <xsl:output method="text"/> > > > > <data xmlns="http://example.com/2008/data"> > > <month s="Jan" n="01"/> > > <month s="Feb" n="02"/> > > <month s="Mar" n="03"/> > > <month s="Apr" n="04"/> > > <!-- add other months here --> > > </data> > > > > <xsl:template match="/"> > > <xsl:apply-templates > select="rss/channel/item"> > > <xsl:sort data-type="number" > > order="descending" > > select="concat(substring(SortDate, 13, > 4), > > document('')/xsl:stylesheet/dt:data/dt:month[@s = > > substring(current()/SortDate, 9, 3)]/@n, > > substring(SortDate, 6, 2))"/> > > </xsl:apply-templates> > > </xsl:template> > > > > <xsl:template match="item"> > > <xsl:value-of > > select="concat(substring(SortDate, 13, 4), '-', > > document('')/xsl:stylesheet/dt:data/dt:month[@s = > > substring(current()/SortDate, 9, 3)]/@n, '-', > > substring(SortDate, 6, 2), > > ' > ', title, ' > > ')"/> > > </xsl:template> > > > > </xsl:stylesheet> > > > > > > -- > > > > Martin Honnen > > http://JavaScript.FAQTs.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorting by date, sudheshna iyer | Thread | Re: [xsl] Combine two diff xmls - , Martin Honnen |
Re: [xsl] Sorting by date, sudheshna iyer | Date | [xsl] Getting average, Chaudhary, Harsh |
Month |