I’d like to get an HTML code of the XSLT rendering on a non-Sitecore site remotely. Is it possible to execute XSLT on a non-Sitecore site?
To execute XSLT on a non-Sitecore site, you need to create the WebService which renders a given XSLT rendering and returns the HTML code. For example:
using Sitecore;
using Sitecore.Web.UI.WebControls;
namespace _3_061102.layouts
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string ExecuteXslt(string XslFile)
{
XslFile xsl = new XslFile();
xsl.Path = XslFile;
xsl.DataSource = "/sitecore/content/home";
string htmlOutput = xsl.RenderAsText();
return htmlOutput;
}
}
}
_3_061102.localhost.WebService1 serv = new WebService1();
serv.Timeout = 600000;
string txtHtml = serv.ExecuteXslt(@"D:\Inetpub\Sitecore\SITECORE_ALLSITES\5.3.0 Build 061102\xsl\sample rendering.xslt");
Response.Write(txtHtml);