XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – round two / Summary and exercises / Exercises
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 2.)
The following exercises are based on the file aufgaben/kap02/buchhandel.xsl. We begin with a few simple exercises that can mostly be solved with xsl:apply-templates and a path expression with a predicate.
The solutions are available under Solutions to the exercises.
Exercise 1: Filtering and sorting
Output all computing books published before 2000, sorted by publication year in ascending order.Exercise 2: Filtering and sorting
Output all books published after 1998 or belonging to the category »reisen«, sorted by author. There is a small detail to watch out for in this sorting!Exercise 3a: Filtering, counting and summing
Output the books from Berg Verlag and Ozean Verlag. Calculate their total and average prices. How can you determine the number of these books?Exercise 3b: Filtering and calculating
Output the books priced in dollars. Convert their prices to euros for output using the fictional exchange rate 1.00 Dollar = 0.68054 Euro. Round and/or format the prices to two decimal places.Exercise 4: conditions
Output the books sorted by title. Prefix books published after 2006 with »Neu erschienen:«. For books published before 1975, display »Vergriffen!« instead.Exercise 5: Grouping and numbering
Group the books by publication year and output them in ascending order, oldest first. Number the books within each year. It is sufficient to output the group’s year and each book title preceded by its number.
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn