EXSLT.NET library is an implementation of EXSLT extensions to XSLT for .NET platform. EXSLT.NET implements the following EXSLT modules: Dates and Times, Common, Math,Regular Expressions, Sets and Strings. In addition EXSLT.NET provides own set of useful extension functions. See full list of supported extension functions and elements in "Extension Functions and Elements" section.
EXSLT.NET is designed as a component for .NET Framework and actually doesn't require installation. You can use GotDotNet.Exslt.dll assembly as is in your application by referencing it in Visual Studio.NET. If you want to install the dll into GAC, run Exslt\install.cmd script. To uninstall the dll, run Exslt\uninstall.cmd script.
EXSLT.NET source distribution contains four Visual Studio 2002 projects: Exslt, which is core EXSLT implementation, ExsltTest - test command line utility for testing EXSLT in XSL transfomation, ExsltXPathTest - test command line utility for testing XPath-only EXSLT and MethodRenamer - auxiliary command line utility for EXSLT.NET assembly building.
Due to implementation details we are using custom Makefile build scripts to build these projects (although they all can be compiled in VS.NET 2002). To build any of them, run command prompt (use Visual Studio .NET Command Prompt or make sure csc.exe, ildasm.exe and ilasm.exe are in your PATH), change directory to a project directory and run nmake.
Typically you are using EXSLT.NET library in your application via GotDotNet.Exslt.ExsltTransform
class, which encapsulates EXSLT implementation under the guise of standard XslTransform
class (ExsltTransform class completely duplicates XslTransform API
you are familiar with). So the rules of the ExsltTransform usage are
simple: just use it instead of standard XslTransform class:
using GotDotNet.Exslt;
using System.Xml.XPath;
using System.IO;
public class ExsltTest2 {
public static void Main(string[] args) {
XPathDocument doc = new XPathDocument("foo.xml");
ExsltTransform xslt = new ExsltTransform();
xslt.Load("foo.xsl");
xslt.Transform(doc, null, new StreamWriter("result.html"));
}
}
Additionally ExsltTransform class has two properties, which
allow you to control which features should be supported, for
instance you can define that you need all extension function modules, but
not multiple output support (the default settings) by setting
SupportedFunctions and MultipleOutput properies in the code before the call to
Transform() method:
xslt.SupportedFunctions = ExsltFunctionNamespace.All; xslt.MultiOutput = false;
It's also possible to use EXSLT.NET in XPath-only environment. For doing that
one makes use of GotDotNet.Exslt.ExsltContext class:
XPathExpression expr = nav.Compile("set:distinct(//author)");
expr.SetContext(new ExsltContext(doc.NameTable));
XPathNodeIterator authors = nav.Select(expr);
while (authors.MoveNext())
Console.WriteLine(authors.Current.Value);
See full list of extension functions EXSLT.NET supports in Exslt\doc\Functions.xml document. Here is HTML version.
Note: For compatibility, some extension functions (such as date:date-time()) have camelCased alias names, e.g. date:dateTime(). Both forms are equivalent names, referring to the same function implementation, although beware that alias names are non-standard ones, so most likely they won't be recognized by other EXSLT implementations.
The only extension element supported is exsl:document element. See "Multiple Output" section for more info.
EXSLT.NET partially supports exsl:document extension element. Not all exsl:document attributes and their values are supported in this version. The supported subset of attributes and values is as follows:
<exsl:document
href = { uri-reference }
method = { "xml" | "text" }
encoding = { string }
standalone = { "yes" | "no" }
doctype-public = { string }
doctype-system = { string }
indent = { "yes" | "no" } >
<-- Content: template -->
</exsl:document>
exsl:document extension element is not supported when transformation is done to XmlReader or XmlWriter. In the latter case use overloaded Transform() method, which accepts instance of MultiXmlTextWriter class to transform to.
exsl:document
extension element is supported through postprocessing of transformation
result using customized XmlTextWriter class. This unconditionally assumes the
transformation is always done in XML, so actually there is no way to produce
real HTML (not XHTML) result documents. More specifically, main result document
is always XML, but subsidiary result documents may be written either as XML or
as text, depending on the method attribute value of the appropriate
exsl:document element.
Moreover, the xsl:output element is
ignored. That only affects outputting of the main result document
though, because the xsl:output element does not affect
outputting of subsidiary result documents. It's completely controlled by the
exsl:document element. Instead, you can get some control over
outputting of the main result document using the MultiXmlTextWriter properties
inherited from the XmlTextWriter class, particularly with
encoding and
indentation.
The disabling of output escaping feature is ignored as always when XSL transformation is performed to an XmlWriter.
For more info about how it's implemented see "Producing Multiple Outputs from an XSL Transformation" article at MSDN Online.
Credits due to EXSLT.NET team and EXSLT supporters.
EXSLT.NET
: License
All content in this Workspace is subject to the following license:
GOTDOTNET WORKSPACES COMMERCIAL DERIVATIVES LICENSE
Copyright (C) 2003 Microsoft Corporation
You can use this Software for any commercial or noncommercial purpose,
including distributing derivative works.
In return, we simply require that you agree:
1. Not to remove any copyright notices from the Software.
2. That if you distribute the Software in source code form you do so only
under this License (i.e. you must include a complete copy of this License
with your distribution), and if you distribute the Software solely in
object form you only do so under a license that complies with this License.
3. That the Software comes "as is", with no warranties. None whatsoever. This
means no express, implied or statutory warranty, including without
limitation, warranties of merchantability or fitness for a particular
purpose or any warranty of noninfringement. Also, you must pass this
disclaimer on whenever you distribute the Software.
4. That neither Microsoft nor any contributor to the Software will be liable
for any of those types of damages known as indirect, special, consequential,
or incidental related to the Software or this License, to the maximum extent
the law permits, no matter what legal theory it’s based on. Also, you must
pass this limitation of liability on whenever you distribute the Software.
5. That if you sue anyone over patents that you think may apply to the
Software for a person's use of the Software, your license to the Software
ends automatically.
6. That the patent rights, if any, licensed hereunder only apply to the
Software, not to any derivative works you make.
7. That your rights under this License end automatically if you breach it in
any way.