# S9API

A new method `Processor.writeXdmValue(XdmValue, Destination)` has been added, allowing any XDM value (for example, a document node) to be written to any `Destination` (for example, a `Serializer`, a `Validator`, or a `Transformer`). For usage examples, see the S9APIExamples demonstration program.

A new constructor has been added to `XdmValue` allowing an `XdmValue` to be constructed from a sequence of items.

A new interface `MessageListener` is available. A user-written implementation of `MessageListener` may be registered with the `XsltTransformer` to receive notification of `xsl:message` output. The class has a single method `message()`, which is called once for each message; the parameters include the message content (as an XML document), a boolean indicating whether `terminate="yes"` was requested, and a `SourceLocator` to distinguish which `xsl:message` instruction generated the output.

New methods have been added to `ItemTypeFactory` to allow creation of ItemTypes and XdmAtomicValues representing external Java objects, which can be passed to a stylesheet or query for use in conjunction with external functions (extension functions). An example of how to achieve this has been added to the sample application `S9APIExamples.java` (test QueryF).

New methods are provided on the `XQueryCompiler` allowing the query to be supplied as a `File`, as a `Reader`, or as an `InputStream`. Methods are also provided to specify the encoding of the query source text.

New methods are available on classes `XQueryEvaluator` and `XsltTransformer` to allow the output from the `trace()` function to be directed to a specified output stream, or to be discarded.

A new method is available on the `XPathCompiler` class to import a schema namespace for reference within the body of the expression.

New methods are available on `XQueryExecutable` and `XPathExecutable` to obtain the result type of the query or expression, as determined by static analysis.

New methods are available on `ItemType` and `OccurrenceIndicator` to determine whether one type subsumes another.

These methods make it easier to write application code that can handle query results when the type of the result is not known a priori.

A new method is available on `XPathCompiler` allowing XSLT patterns to be compiled. A pattern is treated as an expression that returns true if the pattern matches the context node, false otherwise.

A new method is available on `XPathSelector` to return the effective boolean value of the XPath expression.

Next