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="/">
<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">


(all other templates)