API Examples for .NET

The samples/cs directory contains an example application written in C#, designed to illustrate use of the Saxon API available in the Saxon.Api namespace. The application is named Examples.cs; it shows various ways of invoking XSLT, XQuery, XPath, and schema validation. 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 getting started.

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.

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-resources download.

  • -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.