(Just a side note: in the example configuration provided there will be no problem, as gzip_static will not be enabled in location /foo/bar/test/. Additionally, it won't process XML files by default. I've changed the example to one actually affected.)
The problem here is that xslt filter knows nothing about previous request processing. In particular, it can't influence the decision of the gzip_static module to return compressed content. This is a limitation of the design used.
As a workaround, you can tell nginx to don't use gzip_static for XML files in the location with xslt filter enabled, either by disabling gzipping of text/xml in the location completely using the gzip_types directive: