{"action":"opened","issue":{"url":"https://api.github.com/repos/isaacs/sax-js/issues/152","labels_url":"https://api.github.com/repos/isaacs/sax-js/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/isaacs/sax-js/issues/152/comments","events_url":"https://api.github.com/repos/isaacs/sax-js/issues/152/events","html_url":"https://github.com/isaacs/sax-js/issues/152","id":74536950,"number":152,"title":"source xml chunks are also emitted to down stream","user":{"login":"yinso","id":697837,"avatar_url":"https://avatars.githubusercontent.com/u/697837?v=3","gravatar_id":"","url":"https://api.github.com/users/yinso","html_url":"https://github.com/yinso","followers_url":"https://api.github.com/users/yinso/followers","following_url":"https://api.github.com/users/yinso/following{/other_user}","gists_url":"https://api.github.com/users/yinso/gists{/gist_id}","starred_url":"https://api.github.com/users/yinso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yinso/subscriptions","organizations_url":"https://api.github.com/users/yinso/orgs","repos_url":"https://api.github.com/users/yinso/repos","events_url":"https://api.github.com/users/yinso/events{/privacy}","received_events_url":"https://api.github.com/users/yinso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-09T00:09:56Z","updated_at":"2015-05-09T00:09:56Z","closed_at":null,"body":"In the `SaxStream.write` function, it includes `this.emit(\"data\", data)`: \r\n\r\n    SAXStream.prototype.write = function (data) {\r\n      if (typeof Buffer === 'function' &&\r\n          typeof Buffer.isBuffer === 'function' &&\r\n          Buffer.isBuffer(data)) {\r\n        if (!this._decoder) {\r\n          var SD = require('string_decoder').StringDecoder\r\n          this._decoder = new SD('utf8')\r\n        }\r\n        data = this._decoder.write(data);\r\n     }\r\n    \r\n      this._parser.write(data.toString())\r\n      this.emit(\"data\", data)\r\n      return true\r\n    }\r\n\r\nThat means the source data also get emitted to down stream in piping mode, like: \r\n\r\n    saxStream = sax.createStream()\r\n    // code to transform xml to json omitted.\r\n    fs.createReadStream('test.xml')\r\n      .pipe(saxStream)\r\n      .pipe(fs.createWriteStream('out.json'))\r\n\r\nThe final out.json will include both the transformed json text as well as the source xml chunks.\r\n\r\nIs this the expected behavior? It seems a transformation stream should not be a pass through stream at the same time. \r\n\r\n"}}