Inside Xslt
Altering Document Structure Based on Input
So far, the templates Ive created have been based on somewhat rigid skeletons, specifying exactly what should go into the output document, and in what order. But you can use XSLT elements such as <xsl:element> , <xsl:attribute> , <xsl:text> , and so on to create new nodes on the fly, based on what you find in the input document.
Youve already had a little experience in this area, because I used attribute value templates in Chapter 3. As you recall, you can use attribute value templates to set an attribute to the value of an XPath expression, if you enclose that expression in curly braces, { and }. For example, to set the NAME attribute to the string value of a <DESCRIPTION> element that is a child of the context node, you could assign that value like this: NAME={DESCRIPTION} . However, now its time to dig deeper into the whole topic of creating new elements and attributes on the fly, starting with <xsl:element> .