XmlWebPart.Xsl Property
Gets or sets the embedded XSLT that is used to transform the Web Part content if an XslLink is not supplied.
Namespace: Microsoft.SharePoint.WebPartPages
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
<RequiresDesignerPermissionAttribute> _
<WebPartStorageAttribute(Storage.Shared)> _
<ResourcesAttribute("", "Advanced", "Xsl")> _
Public Property Xsl As XmlElement
Get
Set
'Usage
Dim instance As XmlWebPart
Dim value As XmlElement
value = instance.Xsl
instance.Xsl = value
[RequiresDesignerPermissionAttribute]
[WebPartStorageAttribute(Storage.Shared)]
[ResourcesAttribute("", "Advanced", "Xsl")]
public XmlElement Xsl { get; set; }
Property Value
Type: System.Xml.XmlElement
System.Xml.XmlElement XSLT that is used to transform content for this Web Part.
Remarks
The Xsl property is read/write and is stored with the same value for all users (Storage.Shared). The value of this property is stored in the database. Embedded XSL can transform XML content specified through either the Xml or XmlLink properties. You cannot specify encoding in embedded XSL, because the Web Part Page passes the XSL through a string. The encoding value is not processed. This property and XslLink are similar to the embedded Xml and XmlLink properties. Web Part Pages first check to whether XslLink has a value. If it does, the Web Part Page uses the results of that link and ignores the Xsl property. If XslLink is not defined, the Web Part Page uses the contents of the Xsl property, however, if the XslLink is inaccessible or returns invalid XSL, an error appears in the part and the Xsl property is ignored. If neither property is defined, the content is rendered without any transformation.
Examples
The following code example shows how to set this property.
//Create a new XML Web Part
XmlWebPart xmlWebPart = new XmlWebPart();
//Create an XmlElement to hold the value of the Xsl property
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("MyElement");
xmlElement.InnerText = "XSL goes here";
//Set the Xsl property to the XmlElement
xmlWebPart.Xsl = xmlElement;
'Create a new XML Web Part
Dim xmlWebPart As New XmlWebPart()
'Create an XmlElement to hold the value of the Xsl property
Dim xmlDoc As New XmlDocument()
Dim xmlElement As XmlElement = xmlDoc.CreateElement("MyElement")
xmlElement.InnerText = "XSL goes here"
'Set the Xsl property to the XmlElement
xmlWebPart.Xsl = xmlElement