XSLT 1.0: Sorting by concating portions of date string

Posted by dscl on Stack Overflow See other posts from Stack Overflow or by dscl
Published on 2011-01-14T17:50:52Z Indexed on 2011/01/14 17:54 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

I'm trying to take XML data and sort elements by their data attribute. Unfortunately the dates come over in mm/dd/yyyy format and are not static lengths. (Jan = 1 instead of 01) So I believe the string will have to be parsed into three components and the month padded. The newly concated value (yyyymmdd) then sorted descending.

Problem is I have no idea how to do this. Here is an example of the data

<content date="1/13/2011 1:21:00 PM">
    <collection vo="promotion">
        <data vo="promotion" promotionid="64526" code="101P031" startdate="1/7/2011 12:00:00 AM"/>
        <data vo="promotion" promotionid="64646" code="101P026" startdate="2/19/2011 12:00:00 AM"/>
        <data vo="promotion" promotionid="64636" code="101P046" startdate="1/9/2011 12:00:00 AM"/>
    </collection>
</content>

Also can anyone please recommend a good book on learning XSLT?

Thanks!

© Stack Overflow or respective owner

Related posts about Xml

Related posts about datetime