XmlTransformationAlias.

XmlTransform(ICakeContext, FilePath, FilePath, FilePath, XmlTransformationSettings) Method

Summary

Performs XML XSL transformation.
Namespace
Cake.Common.Xml
Containing Type
XmlTransformationAlias

Syntax

[CakeMethodAlias]
public static void XmlTransform(this ICakeContext context, FilePath xslPath, FilePath xmlPath, FilePath resultPath, XmlTransformationSettings settings)

Examples

This example code will convert the Cake nuspec into html using the XmlTransform alias,
specifying that result should be indented and using Unicode encoding.XML stylesheet:
<?xml version="1.0" ?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:p="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
  exclude-result-prefixes="p"
  >
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
  <xsl:template match="/">
    <html lang="en" class="static">
      <head>
        <title>
          <xsl:for-each select="package/p:metadata">
              <xsl:value-of select="p:id"/>
          </xsl:for-each>
        </title>
      </head>
      <body>
          <xsl:for-each select="package/p:metadata">
            <h1>
              <xsl:value-of select="p:id"/>
            </h1>
            <h2>Description</h2>
            <i><xsl:value-of select="p:description"/></i>
          </xsl:for-each>
        <h3>Files</h3>
        <ul>
          <xsl:for-each select="package/files/file" >
            <li><xsl:value-of select="@src"/></li>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XmlTransform usage:

XmlTransform("./nuspec.xsl", "./nuspec/Cake.nuspec", "./Cake.htm",
    new XmlTransformationSettings { Indent = true, Encoding = Encoding.Unicode});

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.

Parameters

Name Type Description
context ICakeContext The context.
xslPath FilePath Path to xml style sheet.
xmlPath FilePath Path xml data.
resultPath FilePath Transformation result path.
settings XmlTransformationSettings Optional settings for result file xml writer.

Return Value

Type Description
void