I have an XML doc with <table> elements throughout mixed with lots of other elements, but I want to process it into an HTML file with the tables at the end. The code below works, but in addition to printing at the end, it still also prints them where they occur within the document.

<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//chapter//table">
<xsl:value-of select="table"/>
<div style="padding-bottom: 20">
<table width="100%" border="4" cellspacing="0" cellpadding="5" bordercolorlight="black" bordercolordark="white" frame="above">
<xsl:apply-templates/>
</table>
</div>
</xsl:for-each>

</body>
</html>
</xsl:template>

(all other templates)