This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Q on <xsl:sort>
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Q on <xsl:sort>
- From: "Walter Torres" <walter at torres dot ws>
- Date: Tue, 1 May 2001 15:08:16 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
I have this snippet... (see below)
I have a four record sample set ( 1 record sample xml is below ).
Each record is different date/times.
My problem is that this sort is not sorting on what I thought it would.
It should display...
record 4
record 1
record 3
record 2
But it is...
record 4
record 3
record 2
record 1
It looks like it is displaying in reverse xml order not reverse timestamp
order.
any ideas?
Walter
===========================================================
<xsl:template match='callEvent/response/interaction_list'>
<xsl:apply-templates>
<xsl:sort select='./interaction/timestamp'
order='descending'
data-type='number' />
</xsl:apply-templates>
</xsl:template>
<!-- timestamp NODE Template -->
<xsl:template match="timestamp">
<!-- Pull the pieces apart -->
<xsl:variable name='datetime' select='.' />
<xsl:variable name='year' select='substring( $datetime, 0 , 5 )' />
<xsl:variable name='month' select='substring( $datetime, 6 , 2 )' />
<xsl:variable name='day' select='substring( $datetime, 9 , 2 )' />
<td valign='top'>
<!-- put the date together in American order -->
<xsl:value-of select="concat($month, '/', $day, '/', $year )" />
<!-- Seperate the date and Time -->
-
<!-- Display the Time -->
<xsl:value-of select='substring( $datetime, 12 , 9 )' />
</td>
</xsl:template>
===========================================================
-- sample record, 1 of 4 in my demo set --
-- the interaction NODE is repeated in this set --
<callEvent>
<response>
<interaction_list>
<interaction id='19766'>
<timestamp unix='987413416000'>2001-04-16T04:30:32</timestamp>
<media_type id='103'>Phone</media_type>
<channel id='1'>-</channel>
<ani></ani>
<dnis></dnis>
<route_type>I</route_type>
<events>
<call_event id='34757'>
<timestamp
unix='987413416000'>2001-04-16T04:30:32</timestamp>
<call_event_type id='98'>eMail</call_event_type>
<customer id='2124'>Harris</customer>
<curr_dest id='103'>Vincent</curr_dest >
<to_dest id='1'>-</to_dest>
<nav_code id='1'>-</nav_code>
<rule id='1'>-</rule>
<greeting id='1'>-</greeting>
<call_type id='1'>-</call_type>
<ext_call id='1'>-</ext_call>
<old_call_record id='1'>-</old_call_record>
<product id='1'>-</product>
<reason id='198'>Case Resolution</reason>
<detailed_comment>Closed issue about bad
check</detailed_comment>
</call_event>
</events>
</interaction>
</interaction_list>
</response>
</callEvent>
=====================================
eof
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list