Built-In Modules

A guide to built-in modules in XmlPrime.

This topic contains the following sections.

Overview

XmlPrime contains a number of built in modules. These modules comprise functions that are available in various W3C specifications but are not available by default in XPath 2.0.

These modules are made available by adding the modules to the library set. Note that the libraries which provide functions in the http://www.w3.org/2005/xpath-functions namespace do not need to be imported into the query, because this namespace is imported by default.

Unlike other modules, if the same function exists in more than one imported built in module then there is no error. This is since if two built in functions have the same name and same signature then they are necessarily the same function.

XPath and XQuery Functions and Operators 3.0

Whilst XmlPrime 2.x does not implement XQuery 3.0/XPath 3.0, the full set of functions defined in XPath and XQuery Functions and Operators 3.0 is available. Note that this is still a working draft, and the behaviour of some functions has already changed since the release of this document.

Functions in the XPath functions namespace are made available by the XdmModule.XQuery30FunctionsXdmModule.XQuery30FunctionsXdmModule::XQuery30Functions property.

Those functions in the XPath math namespace are made available by the XdmModule.XPathMathFunctionsXdmModule.XPathMathFunctionsXdmModule::XPathMathFunctions property.

 
            
using XmlPrime;

// Create the XQuerySettings instance.
XQuerySettings settings = new XQuerySettings();

// Make XPath and XQuery Functions and Operators 3.0 available.
settings.ImportModule(XdmModule.XQuery30Functions);

// Compile a query using a function newly defined in XPath and XQuery Functions and Operators 3.0.
XQuery q = XQuery.Compile("fn:path(.)", settings);

        
 

XSLT 2.0 Additional Functions

XSLT 2.0 defines some additional functions in the http://www.w3.org/2005/xpath-functions namespace which are not part of Functions and Operators 1.0. These functions are specified in XSL Transformations (XSLT) Version 2.0.

These functions are contained in a module accessed via the XdmModule.XsltFunctionsXdmModule.XsltFunctionsXdmModule::XsltFunctions property. Note that most of these functions are now available in XPath and XQuery Functions and Operators 3.0.

XmlPrime Extension Functions

XmlPrime provides a small number of mathematical functions which have not been adopted in XPath and XQuery Functions and Operators 3.0. These functions are in the http://www.xmlprime.com/xpath-functions namespace.

  • xp:e() as xs:double
  • xp:sinh($arg as xs:double?) as xs:double?
  • xp:cosh($arg as xs:double?) as xs:double?
  • xp:tanh($arg as xs:double?) as xs:double?
 
            
using XmlPrime;

// Create the XsltSettings instance.
XsltSettings settings = new XsltSettings();

// Make XmlPrime extension functions available.
settings.ImportModule(XdmModule.XQuery30Functions);

// Compile a transformation using an XmlPrime extension function.
var xslt = Xslt.Compile("transform-using-extension.xsl", settings);