Declaring an Extension Function Namespace

In conformance with the XSLT specification, extension functions are accessed through a unique namespace. The namespace declaration can be in any of the following locations:

  • xsl:stylesheet tag
  • Element that contains the XPath expression that invokes the extension function
  • Ancestor of the element that contains the XPath expression that invokes the extension function

The XPath processor treats the namespace URI as a fully qualified class name. If the class name is preceded by class:, all calls are to static methods only. Otherwise, an instance of the class is created on first use and released when stylesheet processing is complete. Performance is better when you use a static method because creation and deletion of an instance of the class is not required.

You can separate package names with either a dot ( .) or a forward slash ( /). An sample namespace declaration might look like the following:

<xsl:stylesheet xmlns:Ext="NumberUtils">
       

    

The XPath processor resolves namespace prefixes in names of extension functions relative to the namespace declarations in the stylesheet.

 
Free Stylus Studio XML Training: