PageRenderTime 29ms CodeModel.GetById 20ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/tags/jsdoc_toolkit-1.3.3/app/Transformer.js

http://jsdoc-toolkit.googlecode.com/
JavaScript | 14 lines | 12 code | 1 blank | 1 comment | 0 complexity | 156e723e32b5654ae5849462f1e70a39 MD5 | raw file
 1/** @class Use a style sheet to transform XML. Requires Rhino. */
 2function Transformer(xsl) { //like: var t = new Transformer("data/teststyle.xsl");
 3	var xsltFile = new Packages.java.io.File(xsl);
 4	var xsltSource = new Packages.javax.xml.transform.stream.StreamSource(xsltFile);
 5	this.transformer = Packages.javax.xml.transform.TransformerFactory.newInstance().newTransformer(xsltSource);
 6}
 7
 8Transformer.prototype.transform = function(xml, out) { //like: t.transform("data/testdata.xml", "data/testout.txt");
 9	var xmlFile = new Packages.java.io.File(xml);
10	var resFile = new Packages.java.io.File(out);
11	var xmlSource = new Packages.javax.xml.transform.stream.StreamSource(xmlFile);
12	var result = new Packages.javax.xml.transform.stream.StreamResult(resFile);
13	this.transformer.transform(xmlSource, result);
14}