| When you create result trees, you may not be sure when to use xsl:apply-templates , xsl:copy , xsl:copy-of , xsl:value-of , and other XSLT instructions inside your template rules. The following guidelines can help you decide what to do: -
Use xsl:apply-templates when you want to return the content and text nodes of the current element and its children, but not the surrounding element tags. -
Use xsl:copy to preserve the current nodes start and end tags during processing, but not its children or attributes. Content inside the tags is included only if you add an xsl:apply-templates instruction inside the xsl:copy element. -
Use xsl:copy-of when you want to copy the whole kit n caboodlethe current nodes tags, content, attributes, and children. This instruction copies all the nodes returned from its required select attribute. -
Use xsl:value-of when you want to convert the result to text. The conversion process removes all tags and elements. If the result is a single node, its content is converted to text. If the result is a node set, the first node in the set is used in the conversion. I explain these instructions fully in Chapter 4. |