Changes specific to .NET
In SaxonCS, the broad structure of the API remains unchanged from the older .NET product, including some features retained for legacy reasons, but the detail has been modernized and made more consistent.
The interface XmlDestination
is renamed as IDestination,
firstly to use the standard naming convention for interfaces, and secondly to reflect the fact that the content
sent to an IDestination
is not always XML.
The class TextWriterDestination
is renamed as XmlWriterDestination to better reflect its purpose and usage.
The value of property XdmNode.NodeKind is now an
XdmNodeKind
, and the corresponding XmlNodeType
is obtained using the new XdmNode.NodeType property
(the need for both arises because there isn't an exact correspondence between node types in DOM and node
kinds in XDM.)
The method XdmItem.GetStringValue()
is replaced with a property XdmItem.StringValue.
There have been some changes to the API for declaring collections.
The classes Saxon.Api.Predicate
and Saxon.Api.IPredicate
have gone,
replaced by use of System.Predicate
. All the predicates obtained using the Saxon.Api.Predicates
factory class (e.g. Predicates.IsElement()
) remain available.
It's now possible to use a lambda expression wherever a predicate was expected,
e.g. as the argument to Step.Where()
or XdmNode.Children()
.
It's no longer possible to combine predicates using P.And(Q)
or P.Or(Q)
. Instead you can do
Predicates.AllOf(P, Q, R, ...)
or Predicates.AnyOf(P, Q, R, ...)
.
Also it's no longer possible to define a subclass of Saxon.Api.Predicate
,
but there's not much of a use case for doing that anyway.
The BaseUri
property of Saxon.Api.XPathCompiler and Saxon.Api.XQueryCompiler is now a Uri
rather than a
string
, bringing these classes into line with Saxon.Api.XsltCompiler.
A number of callbacks have been changed from interfaces to delegates, allowing them to be implemented more conveniently as lambda expressions. These include the ResultDocumentHandler, the CollectionFinder, the ErrorReporter, and the XQueryResolver (module resolver).
The classes SchemaValidator, XQueryCompiler, and XsltCompiler no
longer have an ErrorList
property. To accumulate error details in a list, change the declaration of
the error list to IList<Saxon.Api.Error>
, and replace compiler.ErrorList =
errorList;
by compiler.ErrorReporter = errorList.Add;
.
The class XmlProcessingError
is renamed as Error to avoid conflicts
with the s9api class XmlProcessingError.
The MessageListener
property of XsltTransformer and Xslt30Transformer is now a delegate in the form
Action<Message>
.
The ValidationFailure object which provides information about errors
detected during schema validation now delivers information about the error in the form of C# properties rather
than Java-like methods: for example ValidationFailure.LineNumber
replaces
ValidationFailure.GetLineNumber()
.
A number of getter and setter methods (such as ValidationFailure.GetLineNumber()
) have been changed
to properties: ValidationFailure.LineNumber
in this case.