Example applications for .NET
samples/cs directory contains some sample applications written in C#,
designed to illustrate use of the Saxon API available in the
namespace. In particular there are three programs
ExamplesEE.cs relevant to Saxon-HE,
Saxon-PE, and Saxon-EE respectively; each shows various ways of invoking XSLT, XQuery,
XPath, and schema validation where appropriate. The idea is that you should be able to
cut and paste a suitable fragment of code into your own application as a quick way of
The main value of these samples is in reading the source code rather than in actually
running them; however, running them is also a good check that your installation has been
set up correctly. A quick look at the comments in the source should enable you to see
how they are executed. Note that they all require the environment variable
SAXON_HOME to be set to the directory where Saxon is installed: this is
used to find the sample data files.
The example applications can be run from the command line (executables are found in the
samples/cs/bin directory). They take the following arguments:
-dir:samples - provides the name of the samples directory from the
saxon-resourcesdownload. The default uses the SAXON_HOME environment variable - but it's normally best to supply this parameter explicitly.
-ask:yes|no - with ask:yes (the default), the application prompts after each test to ask if you want to continue.
-test:testname - supplies the name of the test you want to run, or "all" (the default) to indicate all tests.
Also in the same directory is an application
TestRunner which is a
test harness for running the XSLT, XQuery, and XSD test suites published by W3C (in the
case of XSLT, the test data is available to W3C members only); and an application
XPathExample which illustrates the use of Saxon's JAXP XPath API from C#
(see Shakespeare Example for more