Originally posted by Mike Kay:
Eight tips for how to use XSLT efficiently:
- Keep the source documents small. If necessary split the document first.
- Keep the XSLT processor (and Java VM) loaded in memory between runs
- If you use the same stylesheet repeatedly, compile it first.
- If you use the same source document repeatedly, keep it in memory.
- If you perform the same transformation repeatedly, don't. Store the result instead.
- Keep the output document small. For example, if you're generating HTML, use CSS.
- Never validate the same source document more than once.
- Split complex transformations into several stages.
Eight tips for how to write efficient XSLT:
- Avoid repeated use of "//item".
- Don't evaluate the same node-set more than once; save it in a variable.
- Avoid <xsl:number> if you can. For example, by using position().
- Use <xsl:key>, for example to solve grouping problems.
- Avoid complex patterns in template rules. Instead, use <xsl:choose> within the rule.
- Be careful when using the preceding[-sibling] or following[-sibling] axes. This often indicates an algorithm with n-squared performance.
- Don't sort the same node-set more than once. If necessary, save it as a result tree fragment and access it using the node-set() extension function.
- To output the text value of a simple #PCDATA element, use <xsl:value-of> in preference to <xsl:apply-templates>.
This bunch of useful tips was found there.