XSLT (Extensible StyleSheet Language Transformations)

XSL stands for Extensible StyleSheet Language, and is a style sheet language for XML documents. XSLT stands for XSL Transformations. XSL = Style Sheets for XML.XSL consists of three parts:
  • XSLT - a language for transforming XML documents
  • XPath - a language for navigating in XML documents
  • XSL-FO - a language for formatting XML documents
XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XPath is a language for navigating in XML documents.

Implement Style on xml data:
*********************** Sample: Sample1.xml ************************
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="Sample1.xslt"?>
<FirstName>Lakhan Pal Garg</FirstName>

********************* XSLT Sample: Sample1.xslt ************************
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<b>Author: </b><xsl:value-of select="SqlData/Table/FirstName" /><br/>
<b>Email ID:</b><xsl:value-of select="SqlData/Table/UserName" /><br/>
<b>Blog:</b><xsl:value-of select="SqlData/Table/Blog" />

Code to implement stylesheet on xml document:
XmlDocument docXML = new XmlDocument();
XslTransform docXSL = new XslTransform();
Xml1.Document = docXML;
Xml1.Transform = docXSL;

Author: Lakhan Pal Garg
Email ID:lakhangarg@gmail.com


Anonymous said...

How do you print the value ??

Lakhan Pal Garg said...

<asp:Xml ID="Xml1" runat="server"></asp:Xml>

Use the Above XMl Control to Render the Output