[xsl] Re: opinions on ease of use with EXSLT for .NET

Subject: [xsl] Re: opinions on ease of use with EXSLT for .NET
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 18 Dec 2003 08:34:49 +0100
<kakridge@xxxxxxxxxxxxx> wrote in message
> How difficult is it to use EXSLT for .NET.  Right now, I have a lot of
> code in place already for handling translations.  This isn't like the
> non-.NET EXSLT where you can just import a template/function?

You do not understand what EXSLT really is. Its idea is to be implemented by
the vendors of XSLT processors (as it is done in the majority of cases -- 
e.g. Saxon, Xalan, JD, xsltProc, etc...) or by third parties, so that the
programmer only has to declare the necessary EXSLT namespace and use the
EXSLT functions in XPath expressions.

Recently EXSLT has been implemented for .Net xsltTransform and partially
(the Common and Sets modules) for MSXML4.

No importing of templates is necessary and in fact nothing should be

The xslt stylesheets provided at the EXSLT site are to be used only with
XSLT processors, for which there is no other known implementation. Often
these stylesheets do not implement all functions or implement them with
limited capabilities.

> Do I have
> to rebuild some of the classes that handle my transformations?

You just install EXSLT.Net.Read the MSDN articles on EXSLT:

"EXSLT: Enhancing the Power of XSLT"


"EXSLT Meets XPath"

 To use EXSLT.Net one typically writes the following code (which is almost
identical to the code when EXSLT is not used). This code snippet is copied
from the first article above:

using System.IO;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Xml;
using Exslt;
using System;

public class Test{

  private const String filename = "test.xml";
  private const String stylesheet = "test.xsl";

  public static void Main(string[] args){


      //Create the XslTransform and load the stylesheet.
      ExsltTransform exslt = new ExsltTransform();

      //Load the XML data file.
      XPathDocument doc = new XPathDocument(filename);

      //Create an XsltArgumentList.
      XsltArgumentList xslArg = new XsltArgumentList();

      //Create an XmlTextWriter to output to the console.
      XmlTextWriter writer = new XmlTextWriter(Console.Out);

      //Transform the file.
      exslt.Transform(doc, xslArg, writer);

     }catch(Exception e){
      Console.WriteLine("UNEXPECTED ERROR: " + e.ToString());

While just testing the transformation one may use tools like XSelerator or
XML SPY and integrate the Nxslt.exe commad-line utility -- then running .Net
xsltTransform is just a one-click job.

Hope this helped.

Dimitre Novatchev,
FXSL developer

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread