Rob DiNardo - Web Development Tips

Home

XSLT

warning: Creating default object from empty value in /var/www/robdinardo.com/public_html/modules/taxonomy/taxonomy.pages.inc on line 34.

How to sort XSL output in order of custom string list or arbitrary strings

Rob — November 5, 2010 - 10:00

Have you ever wanted to sort the output of XSL using a custom string list or arbitrary text? Well, I came across such a situation with one of my clients where the order of nodes in an XML feed did not match the order that my client wanted. The answer is to use XPATH to test if the iterator is at the node you want (testing for a true or false), then use that boolean value and multiply by the intended position. Let's demonstrate this with an example.

The following is an example XML feed that we can use to demonstrate XSL arbitrary text sorting in action.

  • coding
  • xml
  • XSLT
  • Rob's blog
  • Read more
Syndicate content

User login

  • Request new password

Code

  • WordPress Plugins