Subject: [xsl] Re: Re: Node Selection From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Fri, 15 Jun 2001 10:46:29 -0700 (PDT) |
Jeni Tennison wrote: > > I am using Xalan for xsl transformations. I have some xml with > > multiple <Activity> nodes in it for each part that is processed. The > > activity nodes are not sorted in any way in the xml. I want to > > select only the latest activity (by Date, Time) to process in the > > transform for my output to show the last activity scan on this part > > and ignore all other activity scans. > > The easiest way to do this is to sort the Activity elements by their > Date and Time (in descending order), and then choose the first one > only to go on and process: > > <xsl:template match="Part"> > <xsl:for-each select="Activity"> > <xsl:sort select="Date" order="descending" /> > <xsl:sort select="Time" order="descending" /> > <xsl:if test="position() = 1"> > <xsl:apply-templates select="." /> > </xsl:if> > </xsl:for-each> > </xsl:template> > > I hope that helps, > > Jeni This is one of the most inefficient ways to find a maximum and Jeni must know it. In case there are thousands of nodes to be sorted, the unnecessary wait will be due exactly to following such an advice. I hope this really helped. Cheers, Dimitre Novatchev. __________________________________________________ Do You Yahoo!? Spot the hottest trends in music, movies, and more. http://buzz.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: Passing node sets as para, Michael Kay | Thread | Re: [xsl] Re: Re: Node Selection, Jeni Tennison |
[xsl] text or call-template inside , Daniel Bauke | Date | Re: [xsl] text or call-template ins, Jeni Tennison |
Month |