[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Processing and sorting non-military time
Subject: Re: [xsl] Processing and sorting non-military time From: "Andrew Fraser" <scenedance@xxxxxxxxx> Date: Fri, 17 Aug 2007 12:06:57 -0500 |
I was able to make some modifications to this and get it working. Thank you so much! I think I was misusing keys earlier. At any rate, this has given me quite a bit of insight into a different way to attack the problem. On 8/17/07, christoph.naber@xxxxxxxxxxxxxxxxxxx <christoph.naber@xxxxxxxxxxxxxxxxxxx> wrote: > Some little typo caused the problem that the keys didn't work. Here is the > corrected stylesheet, should work right away... > > <?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="xml" indent="yes"/> > > <!-- should select all events for a given date --> > <xsl:key name="events-by-date" match="event" > use="substring(occurrences/occurrence/start,1,10)" /> > > <!-- should only select the events where > substring(occurrences/occurence/start, 12, 2) != '12' --> > <xsl:key name="events-by-date-main" > match="event[not(substring(occurrences/occurrence/start/text(), 12, 2) = > '12')]" use="substring(occurrences/occurrence/start,1,10)" /> > > <!-- should only select the events where > substring(occurrences/occurrence/start, 12, 2) == '12' and > substring(occurrences/occurence/start, 18, 2) == 'AM'--> > <xsl:key name="events-by-date-12am" > match="event[(substring(occurrences/occurrence/start/text(), 18, 2) = > 'AM') and (substring(occurrences/occurrence/start/text(), 12, 2) = '12')]" > use="substring(occurrences/occurrence/start,1,10)" /> > > <!-- should only select the events where > substring(occurrences/occurence/start, 12, 2) == '12' and > substring(occurrences/occurence/start, 18, 2) == 'PM'--> > <xsl:key name="events-by-date-12pm" > match="event[(substring(occurrences/occurrence/start/text(), 18, 2) = > 'PM') and (substring(occurrences/occurrence/start/text(), 12, 2) = '12')]" > use="substring(occurrences/occurrence/start,1,10)" /> > > <xsl:template match="events"> > <root> > <xsl:apply-templates select="event[count(. | key('events-by-date', > substring(occurrences/occurrence/start,1,10))[1]) = 1]"> > <xsl:sort select="substring(occurrences/occurrence/start,1,10)" /> > </xsl:apply-templates> > </root> > </xsl:template> > > <!-- this template should process all events with the same date as the > current event --> > <xsl:template match="event" > > > <xsl:comment>selected by 12pm</xsl:comment> > <xsl:apply-templates select="key('events-by-date-12pm', > substring(occurrences/occurrence/start,1,10))" mode="sorted"> > <xsl:sort select="substring(occurrences/occurrence/start,15,2)" /> > </xsl:apply-templates> > > <xsl:comment>selected by main</xsl:comment> > <xsl:apply-templates select="key('events-by-date-main', > substring(occurrences/occurrence/start,1,10))" mode="sorted"> > <xsl:sort order="ascending" > select="substring(occurrences/occurrence/start,18,2)" /> > <xsl:sort order="ascending" > select="substring(occurrences/occurrence/start,12,2)" /> > <xsl:sort order="ascending" > select="substring(occurrences/occurrence/start,15,2)" /> > </xsl:apply-templates> > > <xsl:comment>selected by 12am</xsl:comment> > <xsl:apply-templates select="key('events-by-date-12am', > substring(occurrences/occurrence/start,1,10))" mode="sorted"> > <xsl:sort order="ascending" > select="substring(occurrences/occurrence/start,15,2)" /> > </xsl:apply-templates> > </xsl:template> > > <xsl:template match="event" mode="sorted"> > <!-- ... --> > </xsl:template> > > </xsl:stylesheet> > > > Hope this helps > Christoph > > > If you are not the intended addressee, please inform us immediately that you have received this e-mail by mistake and delete it. We thank you for your support.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Processing and sorting no, christoph . naber | Thread | [xsl] Ranking Random Nodes from Top, J. Zhang |
Re: [xsl] Entity Problems..., Abel Braaksma | Date | [xsl] Iterate through variable in X, yun Wu |
Month |