Declaring an XSLT Extension Function

Extension functions must have one of the following signatures:

public Object FxnName()
public Object FxnName(Type1 var1, Type2 var2,...)
public static Object FxnName()
public static Object FxnName(Type1 var1, Type2 var2,...)


A class that contains an extension function might look like the following:

import org.w3c.dom.*;
import java.lang.Double;
public class NumberUtils
  public Object Average(NodeList nl)
    double nSum = 0;
  for (int i = nl.getLength() - 1; i >= 0; i--)
    nSum += 
  return new Double(nSum / nl.getLength());


Free Stylus Studio XML Training:
W3C Member