tags:

views:

40

answers:

1

Hi

I have many nodes I wish to sort. - They all have a create date. - Some have an edit date to.

(update) Since no ansers I will add an example of en xml document to search

<page>
 <createdate>2010-01-05</createdate>
 <editdate>2010-01-07</editdate>
</page>
<page>
 <createdate>2010-01-06</createdate>
 <editdate></editdate>  (do not know is this row is there at all)
</page>
<page>
 <createdate>2010-01-07</createdate>
 <editdate>2010-01-10</editdate>
</page>

I would like a sort that order by "createdate and use "editdate" if it exist.

Can this be done in XSLT 1.0?

BR. Anders

UPDATE: SOLVED by solution given below

A: 

How about using a concatenation of editdate and createdate as the selection for the xsl:sort? like

 <xsl:for-each select="page">
   <xsl:sort select="concat(editdate, createdate)"/>
   <!-- do stuff -->
 </xsl:for-each>
Ledhund
Thant was a great idea! Never thought of it. Will try it out and get back with result. I guess it should work
Tillebeck
Otherwise I came across this links that might be the base for another solution with a temp result based on both dates that then is sorted further: http://stackoverflow.com/questions/1017423/xslt-1-0-sorting-between-multiple-documents
Tillebeck
It works as expected. Thanks again
Tillebeck