We are trying to sort a column, where each row populates the column with the
value of one of two fields (after checking the value of a third field). If
the value of the third field <LockIndicator> is equal to 3, then the value
of <LockCode> is displayed. If it is not equal to 3, the value of
<LockDate> is displayed.
When the column is sorted, we want to show all the rows with dates first,
then the rows with words. The dates should be sorted earliest to most
recent. The words should be sorted alphabetically. For example, the
sorting should display:
06/24/99
05/12/00
Counter
Locked
Example XML returned:
<Lock>
<LockDate>12-May-2000</LockDate>
<LockCode>Floating</LockCode>
<LockIndicator>2</LockIndicator>
</Lock>
<Lock>
<LockDate>10-May-2002</LockDate>
<LockCode>Locked</LockCode>
<LockIndicator>3</LockIndicator>
</Lock>
<Lock>
<LockDate>18-Jan-1999</LockDate>
<LockCode>Counter</LockCode>
<LockIndicator>3</LockIndicator>
</Lock>
<Lock>
<LockDate>24-Jun-1999</LockDate>
<LockCode>Locked</LockCode>
<LockIndicator>1</LockIndicator>
</Lock>
This is the xsl we tried to sort the xml with.
<xsl:when test="$column = 'RateLockExp'">
<xsl:apply-templates select="LoanSet/Loan">
<xsl:sort select="LockCode"/>
<xsl:sort select="substring( LockDate, 8, 4 )" data-type="number"/>
<xsl:sort
select="format-number((string-length(substring-before('JanFebMarAprMayJunJulAugSepOctNovDec',
substring( LockDate, 4, 3 )) ) div 3 + 1), '00' )">
<xsl:sort select="substring( LockDate, 1, 2 )" data-type="number"/>
</xsl:apply-templates>
</xsl:when>
Using the XSL above, sorting works when testing with XT (all the rows with
dates are displayed first, then the rows with words. The dates are sorted
earliest to most recent. The words are sorted alphabetically), but not with
Xalan (all the rows with dates are displayed first, then the rows with
words. The dates, however, are displayed correctly in terms of month and
day, but the years sort incorrectly, displaying in descending order, so that
the most recent years are displayed first. The rows with words are sorted
correctly, in alphabetical order) .
The result is:
05/12/00
06/24/99
Counter
Locked
Does anyone have suggestions how to sort the column correctly using Xalan.
_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list