xsl-list
[Top] [All Lists]

Sorting based on string length in an element

2005-07-22 15:14:24
Hello XSLT experts,

I have the following kind of content:

<bookshelf>
  <book><desc>description AAAA</desc></book>
  <book><desc>description AA</desc></book>
  <book><desc>description AAA</desc></book>
  <book><desc>description A</desc></book>
</bookshelf>

I am looking for one stylesheet that sorts the booklist in descending order
depending on the length of the <desc> element. The result would look like
this:

<bookshelf>
  <book><desc>description AAAA</desc></book>
  <book><desc>description AAA</desc></book>
  <book><desc>description AA</desc></book>
  <book><desc>description A</desc></book>
</bookshelf>

Also I would like to have a slight modification of that which cuts the list
at a certain position (e.g. pos = 2) which would give me this result:

<bookshelf>
  <book><desc>description AAAA</desc></book>
  <book><desc>description AAA</desc></book>
</bookshelf>

How would this modified stylesheet look like assuming that it should also
work properly in case the list is shorter than pos?

Kind Regards,
Karl

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse f�r Mail, Message, More +++

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>