Xslt Class

MSBuild

A task to merge and transform a set of xml files.


Namespace: MSBuild.Community.Tasks
Assembly: MSBuild.Community.Tasks (in MSBuild.Community.Tasks.dll)

Syntax

Visual Basic (Declaration)
Public Class Xslt
    Inherits Task
C#
public class Xslt : Task
C++
ref class Xslt : Task
J#
public class Xslt extends Task
JScript
public class Xslt extends Task

Example

This example for generating a report from a set of NUnit xml results:

 Copy Code
<ItemGroup>
    <nunitReportXslFile Include="$(MSBuildCommunityTasksPath)\$(nunitReportXsl)">
        <project>$(project)</project>
        <configuration>$(configuration)</configuration>
        <msbuildFilename>$(MSBuildProjectFullPath)</msbuildFilename>
        <msbuildBinpath>$(MSBuildBinPath)</msbuildBinpath>
        <xslFile>$(MSBuildCommunityTasksPath)\$(nunitReportXsl)</xslFile>
    </nunitReportXslFile>
</ItemGroup>

<Target Name="test-report" >
    <Xslt Inputs="@(nunitFiles)"
        RootTag="mergedroot"
        Xsl="@(nunitReportXslFile)" 
        Output="$(testDir)\TestReport.html" />
</Target>
This examples shows all available task attributes:
 Copy Code
<Time Format="yyyyMMddHHmmss">
    <Output TaskParameter="LocalTimestamp" PropertyName="buildDate" />
</Time>

<Xslt
     Inputs="@(xmlfiles)"
     RootTag="mergedroot"
     RootAttributes="foo=bar;date=$(buildDate)"
     Xsl="transformation.xsl"
     Output="report.html"
/>

Remarks

The xml files of parameter Inputs are merged into one xml document, wrapped with a root tag RootTag

If only one input file is provided, merging and wrapping can be omitted by setting RootTag to an empty string.

The root tag can be given any number of attributes by providing a list of semicolon-delimited name/value pairs to parameter RootAttributes. For example:

 Copy Code
RootAttributes="foo=bar;date=$(buildDate)"

Parameter RootAttributes defaults to one attribute with a name specified by CREATED_ATTRIBUTE, and a local time stamp as value. To suppress the default value, an empty parameter

 Copy Code
RootAttributes=""
must be specified explicitely.

The xsl transformation file specified by parameter Xsl is applied on the input.

The ITaskItemXsl can be given any number of metadata, which will be handed to the xsl transformation as parameters.

The output is written to the file specified by parameter Output.

Inheritance Hierarchy

System.Object
   Microsoft.Build.Utilities.Task
      MSBuild.Community.Tasks.Xslt

Thread Safety

Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

See Also

Syntax based on .NET Framework version 2.0.
Documentation version 1.0.0.0.