> "Having written an integrated extension function, it must be registered with Saxon so that calls on the function are recognized by the parser. This is done using the registerExtensionFunction method available on the Configuration class, and also on the s9api Processor class. It can also be registered via an entry in the configuration file. The function can be given any name, although names in the fn:, xs:, and saxon: namespaces are strongly discouraged and may not work.
It is also possible to register integrated extension functions under XQJ, using the SaxonXQStaticContext class which implements the XQStaticContext interface."

 > Because I intend to use standard XML APIs for this implementation, I have a few questions: 
 
You won't be able to stick entirely to standard APIs, because this extension function mechanism is specific to Saxon.
 
 >  - using the first method ( i.e. Configuration.registerExtensionFunction() ), in the Configuration javadoc, it says:
   "This class holds details of user-selected configuration options for a set of transformations and/or queries. When running XSLT, the preferred way of setting configuration options is via the JAXP TransformerFactory interface, but the Configuration object provides a finer level of control. As yet there is no standard API for XQuery, so the only way of setting Configuration information is to use the methods on this class directly."  
    -- Does this mean that I can register an XSLT integrated extension function through one of the TransformerFactory methods? If yes, can you please specify the call with some sample arguments? 
 
You can set simple string-valued configuration options using TransformerFactory.setAttribute(), the options being identified by constants in the Saxon class FeatureKeys. But you can't register extension functions using this mechanism. You'll have to cast the TransformerFactory to an instance of net.sf.saxon.TransformerFactoryImpl, and then call getConfiguration() to get the underlying Configuration object.
 
    -- Is there another way of calling Configuration.registerExtensionFunction() when using the javax.xml.transform?
 - using the last methos ( i.e. XQStaticContext interface ), how should such a registration be accomplished? 
 
The documentation is inaccurate here, I'm afraid. The method in question is SaxonXQDataSource.registerExtensionFunction(). SaxonXQDataSource is Saxon's implementation of the XQJ XQDataSource object. (However, your earlier questions were about XSLT interfaces, whereas this is an XQuery interface.)
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

 
 

Thank you in advance for your help,
M.