|
// Created by Noah Coad, coad.net/noah, noah@coad.net, 4/10/04
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Diagnostics;
namespace XSLTransform
{
class Transform
{
private Transform(string[] args)
{
// Make sure at least three command
// line arguments are specified
if (args.Length < 3) {ShowSyntax(); return;}
XslTransform xsl = new XslTransform();
// Attempt to load the XSL
try {xsl.Load(args[1]);}
catch (XmlException e) {Console.WriteLine("Could not load XSL transform: " + args[1] + "\n\n" + e.Message); return;}
catch (XsltException e) {Console.WriteLine("Could not process the XSL: " + args[1] + "\n\n" + e.Message + "\nOn line " + e.LineNumber + " @ " + e.LinePosition); return;}
// Attempt to transform the XML
try {xsl.Transform(args[0], args[2]);}
catch (XmlException e) {Console.WriteLine("Could not perform transform on: " + "\n\n" + e.Message); return;}
}
[STAThread]
static void Main(string[] args)
{ new Transform(args); }
private void ShowSyntax()
{ Console.Write("XSLTransform Xml-URL Xsl-URL Output.txt"); }
}
}
|