XSLT <apply-templates> Element
We've already learned that the
<xsl:template> element allows us to select any node in our XML document and transform its contents. You'll probably be happy to learn that we can also use this element to work with the children of that node.
<xsl:apply-templates/> element allows us to determine where the content of its children appear on our transformed document.
Here, we are using two
<xsl:template> elements; one for the root node, and one for its children.
We have placed the
<xsl:apply-templates/> element within the
<xsl:template> element for the root node. Doing this applies the results of our other
So, by doing this, we can use other XSLT elements to retrieve data from the child elements, and pass it to the main template for display. In particular, the XSLT
<xsl:value-of/> element is useful for retrieving data from an XML element. We'll look at that element next.