title: How to Debug Extended Functions in XSLT Using Saxon?
body: <p>I have been reading through programming blogs about how to use Extended Functions with XSLT and Saxon, and can't seem to reference external Java functions in the XSLT successfully.  I am getting the following error whenever I run the transform:</p>
  
  <pre><code>Cannot find a matching 0-argument function named {come.acme.javaxslt.business.CarBusiness}getModel()
    at xsl:apply-templates (file:/C:/Users/Dave/workspace/acme-javaXSLT-demo/cars.xsl#18)
       processing /cars/car[1]/model[1]
    in built-in template rule
    at xsl:apply-templates (file:/C:/Users/Dave/workspace/acme-javaXSLT-demo/cars.xsl#10)
       processing /cars
  EXCEPTION: net.sf.saxon.trans.XPathException: Cannot find a matching 0-argument function named {com.acme.javaxslt.business.CarBusiness}getModel()
  ; SystemID: file:/C:/Users/Dave/workspace/acme-javaXSLT-demo/cars.xsl; Line#: 30; Column#: -1
  net.sf.saxon.trans.XPathException: Cannot find a matching 0-argument function named {com.acme.javaxslt.business.CarBusiness}getModel()
      at net.sf.saxon.expr.ErrorExpression.evaluateItem(ErrorExpression.java:58)
      at net.sf.saxon.expr.ErrorExpression.iterate(ErrorExpression.java:71)
      at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:180)
  ...
  </code></pre>
  
  <p><strong>Referenced Java Class:</strong></p>
  
  <pre><code>package com.acme.javaxslt.business;
  
  public class CarBusiness {
  
      public static String getModel(){
          return "/";
      }
  }
  </code></pre>
  
  <p><strong>XSLT:</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:cars="com.acme.javaxslt.business.CarBusiness"&gt;
  
  &lt;xsl:template match="/"&gt;
    &lt;html&gt;
    &lt;body&gt;
    &lt;h2&gt;My Car Collection&lt;/h2&gt;  
    &lt;xsl:apply-templates/&gt;  
    &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="car"&gt;
    &lt;p&gt;
      &lt;xsl:apply-templates select="make"/&gt;  
      &lt;xsl:apply-templates select="model"/&gt;
    &lt;/p&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="make"&gt;
    Make: &lt;span style="color:#ff0000"&gt;
    &lt;xsl:value-of select="."/&gt;&lt;/span&gt;
    &lt;br /&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="model"&gt;
    Artist: &lt;span style="color:#00ff00"&gt;
    &lt;xsl:value-of select="cars:getModel()"/&gt;&lt;/span&gt;
    &lt;br /&gt;
  &lt;/xsl:template&gt;
  
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p><strong>Use of Saxon in Java:</strong></p>
  
  <pre><code>TransformerFactory tfactory = TransformerFactory.newInstance();
  Transformer transformer = tfactory.newTransformer(new StreamSource(new File(xslID)));
  transformer.transform(new StreamSource(new File(sourceID)), new StreamResult(new File("html/report.html")));
  </code></pre>
  
  <p>As soon as the above is run, the errors occur.</p>
  
  <p>Even if I substitute my custom Java class for an inbuilt java method in the XSLT, I get the same error.  So it's obvious that the XSLT is not hooking up with Java.</p>
  
  <p>The recommended approach is to add -TJ to the JVM options, or do something with FeatureKeys.TRACE_EXTERNAL_FUNCTIONS, but I've searched high and low on the web to find out more information on how to do this so that I can see why my XSLT is not hooking up with external Java functions, to no avail.</p>
  
  <p>Please, can someone help me figure out what my problem is?</p>
  
  <p>This is happening for Saxon PE and HE, I haven't tried other versions yet.</p>
  
  <p>Thanks!</p>