>why do i get a dump of data inn the middle of my output xml file
Almost certainly because you are doing an apply-templates that selects nodes for which you have not defined any processing rules (template rules). A good coding practice is to catch these with a fallback template:
Code:
<xsl:template match="*">
<xsl:message>Warning: no template rule defined for element <xsl:value-of select="name()"/></xsl:message>
</xsl:template>