Add the following template to the identity transform:
<xsl:template match="/*/*[position() < 11]"/>
How it works: The identity transform copies any node it matches to the result document, recursively. But the match criteria on the identity transform have the lowest possible priority; if a node is matched by any template with a higher priority, that template will be used instead. (The priority rules are obscure, but they re so well designed that you rarely need to know about them; generally speaking, if a node is matched by two templates, XSLT will select the template whose pattern is more specific.)
In this case, we re saying that if a node is an element that s a child of the top-level element (the top level element is the first element under the root, or /*
, and its child elements are thus /*/*
) and its position in that list of nodes is 11 or higher, it shouldn t be copied.
Edit:
Oof. Everything about the above is correct except for the most important thing. What I wrote will copy every child of the top-level element except for the first ten.
Here s a complete (and correct) version of the templates you ll need:
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*/*[position() > 10]"/>
That s it. The first template copies everything that s not matched by the second template. The second template matches all elements after the first 10 and does nothing with them, so they don t get copied to the output.