RE: [xsl] Re: Date Parsing (Was: Document() question)

Subject: RE: [xsl] Re: Date Parsing (Was: Document() question)
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 12 Jun 2002 10:10:12 +0100
It's not at all clear from your posting where your problems lie. It
doesn't sound like a difficult problem, so there must be some simple
point that you have missed. Perhaps if you show us your stylesheet we
will be able to tell you where you are going wrong.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Jarkko.Moilanen@xxxxxx
> Sent: 12 June 2002 08:04
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Re: Date Parsing (Was: Document() question)
> 
> 
> 
> This is not what I ment. I ment that I need to read the 
> latest/newest values 
> from a different xml- file. To be more exact: while processing 
> 000000001001.xml I need the values mentioned before from file 
> TopicIndex.xml.
> 
> But thanks for the sorting, which I am familiar already =)
> 
> Jarkko
> 
> Lainaus Peter Davis <pdavis152@xxxxxxxxx>:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > On Tuesday 11 June 2002 22:33, Jarkko.Moilanen@xxxxxx wrote:
> > > I need to find the latest document from file TopicIndex.xml and 
> > > insert
> > the
> > > values to 000000001001.xml file. Values that I need are: 
> SignStatus, 
> > > DocType, Time, Sender, Subject. The result is shown in 
> html format.
> > 
> > So the hard part is really just finding the "latest" <Information> 
> > element. Fortunately, you're date and time formats are easily 
> > parseable, and more importantly, the parts of the date and time (1) 
> > begin with the most significant digits, and (2) are padded with 0's 
> > for numbers less than 10.
> > Those qualities mean that you can use <xsl:sort> to sort 
> the date and
> > time
> > alphabetically, and then select the latest one from the sorted list.
> > 
> > Once you sort the list of <Information> elements, you have 
> to choose 
> > the last one from the list.  The easiest way to do that is with the 
> > position() and
> > last() functions, which will let you test the position of each
> > <Information> 
> > element in the sorted list.  Finally, once you get the desired
> > <Information> 
> > element, you just copy the necessary child elements to the 
> result tree.
> > 
> > <xsl:template match="Document">
> >   <Result>
> >     <xsl:apply-templates select="Information">
> >       <!-- this stage is simple because your date and time 
> formats are 
> > already
> >         sortable; other formats might require additional 
> processing, 
> > since
> >         XPath does not have a build in date parser/sorter -->
> >       <xsl:sort select="Time"/>
> >       <!-- sort by Time (date) first, and then by the clock if two 
> > dates are
> >         the same -->
> >       <xsl:sort select="Clock"/>
> >     </xsl:apply-templates>
> >   </Result>
> > </xsl:template>
> > 
> > <xsl:template match="Information">
> >   <!-- if the current element is the last element in the 
> sorted list -->
> >   <xsl:if test="position() = last()">
> >     <xsl:copy-of select="SignStatus"/>
> >     <xsl:copy-of select="DocType"/>
> >     <xsl:copy-of select="Time"/>
> >     <xsl:copy-of select="Sender"/>
> >     <xsl:copy-of select="Subject"/>
> >   </xsl:if>
> > </xsl:template>
> > 
> > HTH
> > 
> > - --
> > Peter Davis
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.0.7 (GNU/Linux)
> > 
> > iD8DBQE9BvEqNSZCJx7tYycRAkVRAKCzbd8iuy1XyLDspP5azvyUTUg8fgCdGJGB
> > m1MKktmxDH86UycTCk2hnpk=
> > =PPzz
> > -----END PGP SIGNATURE-----
> > 
> > 
> 
> 
> 
> ******************************************************************
> Jarkko Moilanen         *You are wise, witty, and wonderful,     *
> Researcher/ ITCM        *but you spend too much time             *
> jm60697@xxxxxx          *reading this sort of trash.             *
> www.uta.fi/~jm60697     *                                        *
> GSM: +358 50 3766 927   *                                        *
> ******************************************************************
> * ITCM | Information Technology and Crisis Management            *
> * http://www.itcm.org                                            *
> ******************************************************************
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread