Chapter 11: XPath Data Types and Functions

xslt for dummies
Chapter 11 - XPath Data Types and Functions
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002

In This Chapter

The very first words I could read as a child were free inside. Those were the dear words that appeared on the front of cereal boxes and told kids like me what cool toy I could find when I ate the cereal. I remember caring far less about the cereal inside than the prize that was at the bottom of the box.

Everyone likes to get something for free, and with XSLT, you get a host of built-in functions for free inside XPath and XSLT. These functions give you a power boost that you can use when you create stylesheets.

Most of the built-in functions are categorized by the kind of data that they work with. The four primary data types in XSLT are: node sets, strings, numbers , and booleans. In this chapter, you find out all about the major built-in functions for these data types and about some general-purpose functions.

Throughout the chapter, I refer to the following menu.xml source document in Listing 11-1 to demonstrate the use of built-in functions.

Listing 11-1: menu.xml
start example
 <?xml version="1.0"?> <menu> <entree name="Sunburnt Chicken"> <diet>false</diet> <fatgrams>23</fatgrams> <features>Salad, Vegetables, Baked Potato, and Dessert</features> <description>Chicken prepared so hot by our master chef Georgio Faucher, you'll need a gallon of soda to wash it down. Bring sunscreen!</description> </entree> <entree name="Filet Mig's None"> <diet>true</diet> <fatgrams>0</fatgrams> <features>Soup, Vegetables, Baked Potato, and Dessert</features> <description>Our master chef Mig prepares a uniquely no- fat filet mignon. You won't believe how great it tastes!</description> </entree> <entree name="Chicken Parmashaun"> <diet>false</diet> <fatgrams>20</fatgrams> <features>Soup, Pasta, Baked Potato, and Dessert</features> <description>Our award-winning Chicken Parmesan prepared especially for you by our master chef Shaun.</description> </entree> <entree name="Eggs Benelux"> <diet>false</diet> <fatgrams>35</fatgrams> <features>Bacon, Sausage, and Toast</features> <description>No matter the time of day, enjoy our scrumptous breakfast cooked by our famous Belgian and Dutch master chefs.</description> </entree> <entree name="Jerk Chicken"> <diet>true</diet> <fatgrams>5</fatgrams> <features>Soup, Vegetables, and Dessert</features> <description>A delicious hot Jamaican dish prepared by our most obnoxious master chef.</description> </entree> <entree name="Gusto Spaghetti"> <diet>false</diet> <fatgrams>55</fatgrams> <features>Soup, Salad, and Dessert</features> <description>Our famous master chef Boyd Ardee prepares a succulent dish of spaghetti with zesty gusto!</description> </entree> </menu> 
end example
2000-2002    Feedback

XSLT For Dummies
XSLT for Dummies
ISBN: 0764536516
EAN: 2147483647
Year: 2002
Pages: 148

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: