SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
| Introduction
| Writing extension functions in Java
| Converting Arguments to Java Extension Functions
| Converting the Result of a Java Extension Function
| Writing extension functions for .NET
» | Converting Arguments to .NET Extension Functions
| Converting the Result of a .NET Extension Function
| Writing XSLT extension instructions
| Customizing Serialization
| Implementing a collating sequence
| Localizing numbers and dates
| Adding an output encoding
| Writing a URI Resolver for Input Files
| Writing a URI Resolver for Output Files
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# Converting Wrapped .NET Objects

Saxon allows an extension function to be return an arbitrary .NET object. This will then be wrapped as an XPath item, so that it can be held in a variable and passed subsequently as an argument to another extension function. This second extension function will see the original Java object minus its wrapper, provided it is declared to expect the appropriate Java class.

A wrapped .NET object may be converted to another data type as follows.

- It is converted to a string by using its ToString() method; if the object is null, the result is the empty string "".

- It is converted to a boolean as follows: if it is null, the result is false, otherwise it is converted to a string and the result is true if and only if the string is non-empty.

The type of a wrapped Java object may be declared in a variable declaration or function signature using a type name whose namespace URI is "http://saxon.sf.net/.net-type", and whose local name is the fully qualified name of the .NET class, with any "$" signs replaced by hyphens. For example, the `sql:connection` extension function returns a value of type `{http://saxon.sf.net/clitype}System.Data.SQlClient.SqlConnection`.

Next