function transform(file,e,next){ var self = this; if(file.isNull()){ self.push(file); return next(); } if(file.isStream()){ self.emit('error',new PluginError('gulp-saxon','stream not supported')); return next(); } var xslt = saxon(opts.jarPath,opts.xslPath,{timeout:opts.timeout}); var path = file.path; fs.createReadStream(path).pipe(xslt) .on('data',function(cont){ file.contents = cont; file.path = gutil.replaceExtension(file.path,opts.outputType); self.push(file); next(); }).on('error',function(err){ self.emit('error', new PluginError('gulp-saxon',err)); next(); }); };
return Q.promise(function(resolve,reject) { var xslt = saxon(saxonPath, xslPath, { timeout: 5000 }); nfs.createReadStream(filepath, { encoding: 'utf-8' }) .pipe(xslt) .on('error', function(err) { console.log('xslt error:',err); reject(err); }) .pipe(nfs.createWriteStream(dest)) .on('error', function(err) { console.log('write error:',err); reject(err); }) .on('finish', function() { console.log('done'); resolve(); }); });