Wrapping the JAvaScript code in xsl:text
elements will help you to achieve the desired result.
<script type="text/javascript">
<xsl:text>var json = {data:[</xsl:text>
<xsl:for-each select="$Bar">
<xsl:text>{ID:</xsl:text>
<xsl:value-of select="@Baz"/>
<xsl:text>}</xsl:text>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
<xsl:text>]};</xsl:text>
</script>
It isn't the nicest piece of code, but I think it's still readable. Let me know if it works.