In XSLT 2.0 you can simply create a variable with the required content and then apply templates to that directly, e.g.
<xsl:variable name="snippet">
<el att1="c"/>
</xsl:variable>
and then
<xsl:apply-templates select="$snippet/el" />
This doesn't work in 1.0, but you can use a trick with the document
function with an empty string argument to refer to the XSLT stylesheet itself as an XML tree.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="snippet">
<el att1="c"/>
</xsl:variable>
<xsl:template match="root">
<xsl:apply-templates select="el"/>
<xsl:apply-templates
select="document('')/*/xsl:variable[@name='snippet']/el"/>
</xsl:template>
<xsl:template match="el">
<xsl:value-of select="@att1"/>
</xsl:template>
</xsl:stylesheet>
In both cases though you need to be aware that because the node(s) you're processing are not in the main input XML tree, then /
may not mean what you think it does. A /
refers to the root node of the tree that contains the current context node, so for the XSLT 2.0 example that would be the root node of a temporary tree, which has the el
as a direct child, and in the XSLT 1.0 version it would be the root of the stylesheet tree, with the xsl:stylesheet
as its child.