home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F17808_ConcatDDMMYYYY.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  3.9 KB  |  102 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Styelsheet:     ConcatDDMMYYYY.xsl
  4.   Category:       FilteringSorting
  5.   Sub-category:   Date Sorting - Concatenation with Substrings
  6.   Author:         David Silverlight
  7.                   HeadGeek@xmlpitstop.com
  8.   Created:        2001-05-16
  9.   Description:-
  10.     This stylsheet demonstrates how to use string functions to
  11.     sort date values.  As you might know, there is no built in
  12.     date sorting in XSLT.  In this example, we are using
  13.     substring and concatenation functions to elements in order
  14.     or Day, Month, Year
  15. ================================================================ -->
  16. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  17.   <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />
  18.   <xsl:template match="/">
  19.     <html>
  20.       <head>
  21.         <title>FilteringSorting - Date Sorting: Concatenation with Substrings</title>
  22.                 <style type="text/css">
  23.           H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  24.           H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  25.           .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  26.           .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  27.           .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  28.           TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  29.           TD {COLOR: darkblue; FONT-FAMILY: Arial}
  30.           TR { background-color: beige; }
  31.           BODY { background-color: beige; }
  32.                 </style>
  33.       </head>
  34.       <body>
  35.         <h1>Display of transactions in order of Day, Month, Year (DDMMYYYY)</h1>
  36.         <span class="subhead">Start Dates</span>
  37.         <table border="1">
  38.           <tr>
  39.             <th>Transaction Start Date</th>
  40.             <th>Description</th>
  41.             <th>Day</th>
  42.             <th>Month</th>
  43.             <th>Year</th>
  44.           </tr>
  45.           <xsl:for-each select="/transactions/transaction">
  46.             <xsl:sort order="ascending" select="concat(substring(@startdate, 9,2),substring(@startdate, 6,2),substring(@startdate, 1,4))" />
  47.             <tr>
  48.               <td>
  49.                 <xsl:value-of select="@startdate" />
  50.               </td>
  51.               <td>
  52.                 <xsl:value-of select="@description" />
  53.               </td>
  54.               <td>
  55.                 <xsl:value-of select="substring(@startdate, 9,2)" />
  56.               </td>
  57.               <td>
  58.                 <xsl:value-of select="substring(@startdate, 6,2)" />
  59.               </td>
  60.               <td>
  61.                 <xsl:value-of select="substring(@startdate, 1,4)" />
  62.               </td>
  63.             </tr>
  64.           </xsl:for-each>
  65.         </table>
  66.         <br />
  67.         <br />
  68.         <span class="subhead">End Dates</span>
  69.         <table border="1">
  70.           <tr>
  71.             <th>Transaction End Date</th>
  72.             <th>Description</th>
  73.             <th>Day</th>
  74.             <th>Month</th>
  75.             <th>Year</th>
  76.           </tr>
  77.           <xsl:for-each select="/transactions/transaction">
  78.             <xsl:sort order="ascending" select="concat(substring(@enddate, 9,2),substring(@enddate, 6,2),substring(@enddate, 1,4))" />
  79.             <tr>
  80.               <td>
  81.                 <xsl:value-of select="@enddate" />
  82.               </td>
  83.               <td>
  84.                 <xsl:value-of select="@description" />
  85.               </td>
  86.               <td>
  87.                 <xsl:value-of select="substring(@enddate, 9,2)" />
  88.               </td>
  89.               <td>
  90.                 <xsl:value-of select="substring(@enddate, 6,2)" />
  91.               </td>
  92.               <td>
  93.                 <xsl:value-of select="substring(@enddate, 1,4)" />
  94.               </td>
  95.             </tr>
  96.           </xsl:for-each>
  97.         </table>
  98.       </body>
  99.     </html>
  100.   </xsl:template>
  101. </xsl:stylesheet>
  102.