XmlTransformationAlias.

XmlTransform(ICakeContext, string, string, XmlTransformationSettings) Method

Summary

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

Syntax

[CakeMethodAlias]
public static string XmlTransform(this ICakeContext context, string xsl, string xml, XmlTransformationSettings settings)

Examples

This example code will convert specific part of xml to plaintext using XmlTransform alias.
 string xsl = @"<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
   <xsl:output method=""text"" omit-xml-declaration=""yes"" indent=""no""/>
   <xsl:strip-space elements=""*""/>
   <xsl:template match=""pastery/cake""><xsl:value-of select=""@price""/></xsl:template>
 </xsl:stylesheet>";

 string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
 <pastery>
     <cake price=""1.62"" />
 </pastery>";

 var text = XmlTransform(xsl, xml, new XmlTransformationSettings {
     ConformanceLevel = System.Xml.ConformanceLevel.Fragment, Encoding = Encoding.ASCII });

Attributes

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

Parameters

Name Type Description
context ICakeContext The context.
xsl string XML style sheet.
xml string XML data.
settings XmlTransformationSettings Optional settings for result file xml writer.

Return Value

Type Description
string Transformed XML string.