Configuration using Saxon.Api (C#)

In the Saxon.Api interface in SaxonCS, the root API object is the Saxon.Api.Processor object. This is a wrapper around a Saxon.Hej.Configuration object, which should not normally be used directly (though it's exposed as public, just in case you need to). There are two ways to set configuration properties:

  • processor.SetProperty(Saxon.Api.Feature<bool>.TIMING, true)

  • processor.SetProperty("", "true");

There are also two GetProperty() in the same vein.

The first form is recommended for type-safety (it is also faster, though this is rarely going to make a difference). The second form may be needed when the property name is not known statically, for example if it is being read from a configuration file of some kind.

The Saxon.Api Processor object also has a constructor new Processor(stream) which allows the underlying Configuration to be built from a supplied configuration file, which must have the format described in Configuration file.

In many cases with the Saxon.Api interface it is more appropriate to set options at a finer level of granularity than the Processor. For example, options that affect XSLT stylesheet compilation can be set on the XsltCompiler object, and options that affect XQuery compilation on the XQueryCompiler.