views:

213

answers:

1

I have an XSLT transform that I developed in VS. It works great when I use VS to run it (via XML->Show Xslt Output). However, when I execute it via the MsBuildCommunityTasks Xslt task I get wildly different results.

Specifically, the output is only the contents of a handful of elements I don't even reference in my XSLT. I guess the default transform is picking them up.

My task declaration couldn't get any simpler:

<Xslt 
  Inputs="BuildLo​gs\partcover-result​s.xml" 
  Xsl="ExtTools\​xslt\partcover.asse​mbly.report.xsl​" 
  RootTag="" 
  RootAttributes="" 
  Output="partcov​er.assembly.report.h​tml" 
/>

Perhaps msbuildtasks is using a different XSLT engine than VS uses internally? Any guidance would be appreciated.

A: 

I also spent some time on trying to get this Xslt-task working, fiddling with the RootTag and Attributes. After some 2 hours i gave up and instead wrote my own task to get this done, which worked on my first try..

public override bool Execute()
{
    bool result = true;

    Log.LogMessage("Transforming from {0} to {1} using {2}",
        XmlFile, OutputFile, XsltFile);

    XmlWriter xmlWriter = null;

    try
    {
        XslCompiledTransform xslTransform = GetXslTransform(XsltFile);
        XmlReader xmlReader = GetXmlReader(XmlFile);
        xmlWriter = GetXmlWriter(OutputFile);
        xslTransform.Transform(xmlReader, xmlWriter);
    }
    catch (Exception e)
    {
        Log.LogErrorFromException(e);
        result = false;
    }
    finally
    {
        if (xmlWriter != null)
        {
            xmlWriter.Flush();
            xmlWriter.Close();
        }
    }

    return result;
}
Bart Janson