… then fill it with data

Once we have the output tree, we need to fill it with the content of the input tree. As you may have guessed, the <xsl:apply-templates> element allows us to do precisely this. Think of it as a conduit from the input tree to the output tree. It instructs the stylesheet to replicate the content of the input tree within the output tree that you have created in your stylesheet. In this case, it grabs the content of the matched <paragraph>, Hello, World!, and puts it in the appropriate place in the output tree (in the HTML <p> element).

The processor works much like the dog playing fetch in this slide. The <xsl:templates> instructs the processor to fetch the content (in this case, text).

We can imagine more complex examples, where the content of <paragraph> is not only text, but additional elements that one may want to process in some way. A more complex example like this will be covered in the next slide.

A Gentle Introduction to XSLT slide 04 of 8
© 2012 Syd Bauman, Julia Flanders, and the Women Writers Project This TEI-encoded XML file is available under the terms of the Creative Commons Attribution-ShareAlike 3.0 (Unported) license.