"Returning" values from XSLT stylesheet

219 views Asked by At

I am using an XSLTCompiledTransform object as seen below to convert an XML report into an html report. I am using an XsltArgumentList to pass values from the C# code to the XSLT, but I also need to "return" values from the XSLT sheet to the C# code.

    XsltArgumentList argsList = new XsltArgumentList();
    argsList.AddParam("min_threshold", "", min_threshold);
    argsList.AddParam("max_threshold", "", max_threshold);
    argsList.AddParam("user", "", user);

    XslCompiledTransform writeHtml = new XslCompiledTransform(false);
    writeHtml.Load(userStyles);
    using (StreamWriter sw = new StreamWriter(pathHtml))
    {
    writeHtml.Transform(pathXml, argsList, sw);
    }

I have not been able to find anything documenting ways in which this can be done. I could use LINQ to obtain the values I need directly from the DataTable from which the XML was written, but I would prefer to pull them from the XSL. It would be less code, and I would avoid having to compute the same value in two separate places.

0

There are 0 answers