Search code examples
c#xsltxslcompiledtransform

Pick changes to XSLT file up in XslCompiledTransform


I have an XSLT file and I've made some minor amendments to it.

The changes in the XSLT don't appear to be getting picked up when compiling.

Not sure how this is supposed to work..is there something else you would need to write in this function in order to pick the new changes up?

    private static String TransformDocumentByType(Type type, XPathDocument xpathDoc, XsltArgumentList argsList)
    {
        XslCompiledTransform transform = new XslCompiledTransform();
        transform.Load(type);

        // Get the transformed result
        StringWriter sw = new StringWriter();
        XhtmlTextWriter tw = new XhtmlTextWriter(sw);
        transform.Transform(xpathDoc, argsList, tw);
        String result = sw.ToString();

        //remove the namespace attribute
        result = result.Replace("xmlns:asp=\"remove\"", "").Replace("xmlns:ant=\"remove\"", "");

        return result;
    }

Solution

  • I'm loading the type and not the string path to XSLT file.

    Will continue using the type later, but I suspect the DLL will need to be recompiled using XSLTC.exe.

    For now, will just use the string path.

    transform.Load("path_to_xslt_file");