Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Does the actual transform
        /// </summary>
        /// <param name="inFile"></param>
        /// <param name="outFile"></param>
        /// <returns></returns>
        private long Transform(FileInfo inFile, FileInfo outFile)
        {
            TextWriter writer = new StreamWriter(outFile.FullName);
            long       time   = dvsl.Transform(inFile, writer);

            writer.Close();
            return(time);
        }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
        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();
                }
            }
        }
Ejemplo n.º 5
0
	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();
        }
Ejemplo n.º 7
0
	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();
		}
	    }
	}