Stylesheet (XSL) web resources

Use Stylesheet (XSL) Web resources to transform XML data.

Capabilities of XSL Web resources

Use XSL Web resources to transform XML data used by your solution.

The following Web resources work together to render a page that displays a table using the data in the XML Web resource. The source files for these Web resources are part of the Import Web Resources sample under the filestoimport folder. Download the sample of Import files as web resources.

HTML Web resource: sample_/ImportWebResources/Content/ShowData.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">  
<script src="Script/Script.js" type="text/javascript"></script>  
<link href="CSS/Styles.css" rel="stylesheet" type="text/css" />  
<body onload="SDK.ImportWebResources.showData()">  
<div id="results" />  

XSL Web resource: sample_/ImportWebResources/XSL/Transform.xslt

<?xml version="1.0" encoding="utf-8"?>  
<xsl:stylesheet version="1.0"  
<xsl:output method="xml"  
<xsl:template match="@* | node()">  
  <xsl:apply-templates select="@* | node()"/>  
<xsl:template match="people">  
 <xsl:element name="table">  
  <xsl:element name="thead">  
   <xsl:element name="tr">  
    <xsl:element name="th">  
     <xsl:text>First Name</xsl:text>  
    <xsl:element name="th">  
     <xsl:text>Last Name</xsl:text>  
  <xsl:element name="tbody">  
   <xsl:apply-templates />  
<xsl:template match="person">  
 <xsl:element name="tr">  
  <xsl:element name="td">  
   <xsl:value-of select="@firstName"/>  
  <xsl:element name="td">  
   <xsl:value-of select="@lastName"/>  

XML Web resource: sample_/ImportWebResources/Data/Data.xml

<?xml version="1.0" encoding="utf-8" ?>  
<person firstName="Apurva"  
        lastName="Dalia" />  
<person firstName="Ofer"  
        lastName="Daliot" />  
<person firstName="Jim"  
        lastName="Daly" />  
<person firstName="Ryan"  
        lastName="Danner" />  
<person firstName="Mike"  
        lastName="Danseglio" />  
<person firstName="Alex"  
        lastName="Darrow" />  

Script Web resource: sample_/ImportWebResources/Script/Script.js

//If the SDK namespace object is not defined, create it.  
if (typeof (SDK) == "undefined")  
{ SDK = {}; }  
// Create Namespace container for functions in this library;  
SDK.ImportWebResources = {  
dataFile: "Data/Data.xml",  
transformFile: "XSL/Transform.xslt",  
showData: function () {  
 //Create an XML document from the Data.xml file  
 var dataXml = new ActiveXObject("Msxml2.DOMDocument.6.0");  
 dataXml.async = false;  
 //Create an XML document from the Transform.xslt file  
 var transformXSLT = new ActiveXObject("Msxml2.DOMDocument.6.0");  
 transformXSLT.async = false;  
 // Set the innerHTML of the results area to the output of the transformation.  
 var resultsArea = document.getElementById("results");  
 resultsArea.innerHTML = dataXml.transformNode(transformXSLT);  

CSS Web resource: sample_/ImportWebResources/CSS/Styles.css

   font-family: Calibri;  
   border: 1px solid gray;  
   border-collapse: collapse;  
   text-align: left;  
   border: 1px solid gray;  
   border: 1px solid gray;  

See also

Web Resources for Dynamics 365 Customer Engagement (on-premises)
Using Web Page (HTML) Web Resources
Using Style Sheet (CSS) Web Resources
Using Script (JScript) Web Resources
Using Data (XML) Web Resources
Using Image (JPG, PNG, GIF) Web Resources
Using Silverlight (XAP) Web Resources