public virtual void doit() { /* * make a dvsl */ NVelocity.Dvsl.Dvsl dvsl = new NVelocity.Dvsl.Dvsl(); /* * register the stylesheet */ dvsl.SetStylesheet(new StringReader(dvslstyle)); /* * render the document as a Reader */ StringWriter sw = new StringWriter(); dvsl.Transform(new StringReader(input), sw); if (!sw.ToString().Equals("Hello from element! Foo")) Assertion.Fail("Result of first test is wrong : " + sw.ToString()); /* * now test if we can pass it a Document */ XmlDocument document = new XmlDocument(); document.Load(new StringReader(input)); sw = new StringWriter(); dvsl.Transform(document, sw); if (!sw.ToString().Equals("Hello from element! Foo")) Assertion.Fail("Result of second test is wrong : " + sw.ToString()); }
protected void xExecuteTask() { int fileCount = fileset.FileNames.Count; Log.WriteLine(LogPrefix + "processing {0} files", fileCount); foreach (string filename in fileset.FileNames) { FileInfo file = new FileInfo(filename); if (file.Exists) { String outfile = filename.Substring(0, filename.Length - file.Extension.Length) + ".html"; dvsl = new NVelocity.Dvsl.Dvsl(); if (stylesheet == null) { System.Console.Out.WriteLine("usage :need to specify a stylesheet. "); System.Console.Out.WriteLine("Dvsl.exe -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]"); return; } else { dvsl.SetStylesheet(stylesheet.FullName); } if (toolboxFile != null) { ExtendedProperties p = new ExtendedProperties(); Stream fis = new FileStream(toolboxFile.FullName, FileMode.Open, FileAccess.Read); p.Load(fis); fis.Close(); dvsl.Toolbox = p; } TextReader reader = new StreamReader(filename); TextWriter writer = new StreamWriter(outfile); long time = dvsl.Transform(reader, writer); writer.Flush(); reader.Close(); writer.Close(); } } }
public virtual void doit() { /* * make a dvsl */ NVelocity.Dvsl.Dvsl dvsl = new NVelocity.Dvsl.Dvsl(); /* * register the stylesheet */ dvsl.SetStylesheet(new StringReader(dvslstyle)); /* * render the document as a Reader */ StringWriter sw = new StringWriter(); dvsl.Transform(new StringReader(input), sw); if (!sw.ToString().Equals("Hello from element! Foo")) { Assertion.Fail("Result of first test is wrong : " + sw.ToString()); } /* * now test if we can pass it a Document */ XmlDocument document = new XmlDocument(); document.Load(new StringReader(input)); sw = new StringWriter(); dvsl.Transform(document, sw); if (!sw.ToString().Equals("Hello from element! Foo")) { Assertion.Fail("Result of second test is wrong : " + sw.ToString()); } }
public static void Main(String[] args) { Dvsl dvsl = new Dvsl(); TextReader reader = System.Console.In; String infile = null; String style = null; String outfile = null; TextWriter writer = System.Console.Out; String toolfile = null; for (int i = 0; i < args.Length; i++) { if (args[i].Equals("-IN")) infile = args[++i]; else if (args[i].Equals("-OUT")) outfile = args[++i]; else if (args[i].Equals("-STYLE")) style = args[++i]; else if (args[i].Equals("-TOOL")) toolfile = args[++i]; } if (style == null) { System.Console.Out.WriteLine("usage :need to specify a stylesheet. "); System.Console.Out.WriteLine("Dvsl.exe -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]"); return; } if (style != null) dvsl.SetStylesheet(style); if (toolfile != null) { ExtendedProperties p = new ExtendedProperties(); Stream fis = new FileStream(toolfile, FileMode.Open, FileAccess.Read); p.Load(fis); dvsl.Toolbox = p; } if (infile != null) reader = new StreamReader(infile); if (outfile != null) writer = new StreamWriter(outfile); long time = dvsl.Transform(reader, writer); writer.Flush(); }
public static void Main(String[] args) { Dvsl dvsl = new Dvsl(); TextReader reader = Console.In; String infile = null; String style = null; String outfile = null; TextWriter writer = Console.Out; String toolfile = null; for (int i = 0; i < args.Length; i++) { if (args[i].Equals("-IN")) { infile = args[++i]; } else if (args[i].Equals("-OUT")) { outfile = args[++i]; } else if (args[i].Equals("-STYLE")) { style = args[++i]; } else if (args[i].Equals("-TOOL")) { toolfile = args[++i]; } } if (style == null) { Console.Out.WriteLine("usage :need to specify a stylesheet. "); Console.Out.WriteLine("Dvsl.exe -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]"); return; } if (style != null) { dvsl.SetStylesheet(style); } if (toolfile != null) { ExtendedProperties p = new ExtendedProperties(); Stream fis = new FileStream(toolfile, FileMode.Open, FileAccess.Read); p.Load(fis); dvsl.Toolbox = p; } if (infile != null) { reader = new StreamReader(infile); } if (outfile != null) { writer = new StreamWriter(outfile); } long time = dvsl.Transform(reader, writer); writer.Flush(); }
protected void xExecuteTask() { int fileCount = fileset.FileNames.Count; Log.WriteLine(LogPrefix + "processing {0} files", fileCount); foreach (string filename in fileset.FileNames) { FileInfo file = new FileInfo(filename); if (file.Exists) { String outfile = filename.Substring(0,filename.Length-file.Extension.Length) + ".html"; dvsl = new NVelocity.Dvsl.Dvsl(); if (stylesheet == null) { System.Console.Out.WriteLine("usage :need to specify a stylesheet. "); System.Console.Out.WriteLine("Dvsl.exe -STYLE stylesheeet [-IN infile] [-OUT outfile] [-TOOL toolboxname]"); return; } else { dvsl.SetStylesheet(stylesheet.FullName); } if (toolboxFile != null) { ExtendedProperties p = new ExtendedProperties(); Stream fis = new FileStream(toolboxFile.FullName, FileMode.Open, FileAccess.Read); p.Load(fis); fis.Close(); dvsl.Toolbox = p; } TextReader reader = new StreamReader(filename); TextWriter writer = new StreamWriter(outfile); long time = dvsl.Transform(reader, writer); writer.Flush(); reader.Close(); writer.Close(); } } }
protected override void ExecuteTask() { if (stylesheet == null) { throw new BuildException("no stylesheet specified", Location); } /* * make a DVSL and set validation */ dvsl = new NVelocity.Dvsl.Dvsl(); dvsl.ValidatingParser = validatingParser; /* * If a logfile attribute was specified, use that for the log file name, * TODO: otherwise use a NVelocity to NAnt logging adapter. */ if (logFile != null) { dvsl.LogFile = logFile; } else { //dvsl.setLogSystem(new AntLogSystem(this)); } /* * now the stylesheet */ try { Log.WriteLine(LogPrefix + "Loading stylesheet " + stylesheet.FullName); dvsl.SetStylesheet(stylesheet); } catch (System.Exception ex) { Log.WriteLine(LogPrefix + "Failed to read stylesheet " + stylesheet.FullName); throw new BuildException(ex.ToString()); } /* * now, if we were given a toolbox, set that up too */ toolboxProps = new ExtendedProperties(); try { if (toolboxFile != null) { toolboxProps.Load(toolboxFile.OpenRead()); } /* * Overlay any parameters */ // for (Enumeration e = toolAttr.elements(); e.hasMoreElements();) { // Tool p = (Tool)e.nextElement(); // toolboxProps.setProperty(p.getName(), p.getValue()); // } dvsl.Toolbox = toolboxProps; } catch(System.Exception ee) { throw new BuildException("Error loading the toolbox : " + ee); } /* * if we have an in file and out then process them */ if (inFile != null && outFile != null) { Process(inFile, outFile, stylesheet); return; } /* * if we get here, in and out have not been specified, we are * in batch processing mode. */ /* * make sure Source directory exists... */ if (destDir == null) { throw new BuildException("destdir attributes must be set!"); } Log.WriteLine(LogPrefix + "Transforming into "+destDir); /* * Process all the files marked for styling */ // get the base directory from the fileset - needed to colapse ../ syntax DirectoryInfo di = new DirectoryInfo(fileset.BaseDirectory); // get a list of files to work on foreach (string filename in fileset.FileNames) { String relativeFilename = filename.Substring(di.FullName.Length+1); FileInfo file = new FileInfo(filename); if (file.Exists) { Process(di, file, destDir, stylesheet); } } }
protected override void ExecuteTask() { if (stylesheet == null) { throw new BuildException("no stylesheet specified", Location); } /* * make a DVSL and set validation */ dvsl = new NVelocity.Dvsl.Dvsl(); dvsl.ValidatingParser = validatingParser; /* * If a logfile attribute was specified, use that for the log file name, * TODO: otherwise use a NVelocity to NAnt logging adapter. */ if (logFile != null) { dvsl.LogFile = logFile; } else { //dvsl.setLogSystem(new AntLogSystem(this)); } /* * now the stylesheet */ try { Log.WriteLine(LogPrefix + "Loading stylesheet " + stylesheet.FullName); dvsl.SetStylesheet(stylesheet); } catch (System.Exception ex) { Log.WriteLine(LogPrefix + "Failed to read stylesheet " + stylesheet.FullName); throw new BuildException(ex.ToString()); } /* * now, if we were given a toolbox, set that up too */ toolboxProps = new ExtendedProperties(); try { if (toolboxFile != null) { toolboxProps.Load(toolboxFile.OpenRead()); } /* * Overlay any parameters */ // for (Enumeration e = toolAttr.elements(); e.hasMoreElements();) { // Tool p = (Tool)e.nextElement(); // toolboxProps.setProperty(p.getName(), p.getValue()); // } dvsl.Toolbox = toolboxProps; } catch (System.Exception ee) { throw new BuildException("Error loading the toolbox : " + ee); } /* * if we have an in file and out then process them */ if (inFile != null && outFile != null) { Process(inFile, outFile, stylesheet); return; } /* * if we get here, in and out have not been specified, we are * in batch processing mode. */ /* * make sure Source directory exists... */ if (destDir == null) { throw new BuildException("destdir attributes must be set!"); } Log.WriteLine(LogPrefix + "Transforming into " + destDir); /* * Process all the files marked for styling */ // get the base directory from the fileset - needed to colapse ../ syntax DirectoryInfo di = new DirectoryInfo(fileset.BaseDirectory); // get a list of files to work on foreach (string filename in fileset.FileNames) { String relativeFilename = filename.Substring(di.FullName.Length + 1); FileInfo file = new FileInfo(filename); if (file.Exists) { Process(di, file, destDir, stylesheet); } } }