From the course: XML Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Sorting data

Sorting data

- [Instructor] We can use xslt to sort our xml data. So, I'm going to open up the sorting xml and sorting xslt files. The sorting.xml file contains the same xml content we've been using. So, this is our product for Java code T. And you can see here in the sorting style sheet, this is the same xsl style sheet from the previous example where we had the choose and when tags. So, I've already got my for-each tag, and I have my choose, and so on. What I'm going to do is sort the data, and all I need to do this is use the xsl sort tag. And this is really easy, all I have to do is add it right below the for-each tag. So, I'm going to put in my xsl:sort, and then I need to select the data that we're going to sort on. In this case, I will sort on the available attribute. And I'm going to make the order="descending." And that's pretty (chuckling) much it. That's all I have to do. Okay, so I've got my xsl sort tag, I've got my attribute I want to sort on, and that's pretty much it. So, let's…

Contents