Using Asp Objects in .NET - Maximum Compatibility

I have some deprecated XSLT scripts that include VBScript in them. They run on the old system, and I cannot change this system.

I need to make changes to XSLT in order to convert the file differently now.

I built a simple .NET project to test my XSLT transformation:

    [STAThread]
    public static void Main(string[] args)
    {
        var transform = new XslCompiledTransform(true);
        //foreach (var file in System.Reflection.Assembly
        //    .GetExecutingAssembly().GetManifestResourceNames()
        //    )
        //{
        //    Console.WriteLine(file);
        //}
        //Console.ReadKey();


        transform.Load(XmlTextReaderFromEmbeddedResource("MyXSLTFile"),
            new XsltSettings() { EnableDocumentFunction = true, EnableScript = true }, new XmlUrlResolver());
        transform.Transform(
            XmlTextReaderFromEmbeddedResource("MySourceXML"),
            ToXmlTextWriter("MyOutput.xml"));

    }

    private static XmlTextReader XmlTextReaderFromEmbeddedResource(string resourceName)
    {
        var resource = typeof(Transform)
            .Assembly.GetManifestResourceStream
            (resourceName);
        return new XmlTextReader(resource);
    }

    private static XmlTextWriter ToXmlTextWriter(string fileName)
    {
        return new XmlTextWriter(fileName, Encoding.UTF8);
    }

it works, procedurally. However, XSLT scripts that are VBScript do not work well with .NET. In particular, I have a segment:

dim gRegEx
set gRegEx = New RegExp

which bombs the transformation as follows:

Type 'RegExp' is not defined.

There are many articles on how to convert this to a .NET object, but for this you need to revert to an outdated machine that will expect VBScript.

How can I write this so that it works in both environments?

+3
1

XslCompiledTransform. COM-Interop MSXML3 MSXML6 . , , , .NET, , ASP.

Edit

.

# Windows Console

COM "Microsoft XML, v3.0".

: -

class Program
{
    static void Main(string[] args)
    {
        try
        {
            var dom = new MSXML2.DOMDocument30();
            dom.async = false;
            dom.load(args[0]);

            var xslt = new MSXML2.DOMDocument30();
            xslt.async = false;
            xslt.load(args[1]);

            File.WriteAllText(args[2], dom.transformNode(xslt));

            Console.WriteLine("Done");

        }
        finally
        {
            Console.ReadKey();
        }
    }

}

"" , XML, XSLT, .

.NET, XSL, ASP Classis / MS script.

+2

All Articles