XSLT

XSLT stands for Extensible Stylesheet Language Transformations.

It is an XML language that describes how to transform one XML language into another.

Consider the following XML file:

 
        <customer>
            <firstname>Jim</firstname>
            <lastname>Bo</lastname>
        </customer>
  

The following XSLT file describes such a transformation:

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <html>
        <p><xsl:value-of select="//firstname"/></p>
        <p><xsl:value-of select="//lastname"/></p>
    </html>
    </xsl:template>
</xsl:stylesheet>
  

The output is as follows:

 
    <html>
        <p>Jack</p>
        <p>Smith</p>
    </html>
  

The System.Xml.Xsl.XslCompiledTransform transform class efficiently performs

XLST transforms. It renders XmlTransform obsolete. XmlTransform works very simply:


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml;

using System.Xml.Xsl;
using System.Xml.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main()
    {

        XslCompiledTransform transform = new XslCompiledTransform();
        transform.Load("test.xslt");
        transform.Transform("input.xml", "output.xml");

    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.