1. The xsl file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:proc="java:process.processor">
<xsl:template match="/">
.........
        <td><xsl:value-of select="proc:processor.format()"/></td>
.........
</xsl:template>
</xsl:stylesheet>
 
2. The processor.java is:
package process;
public class processor
{
public static String format()
{
return "test";
}
}
 
3. The XsltDemo.java is:
   ......
   System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
   TransformerFactory tfactory = TransformerFactory.newInstance();
   Transformer transformer = tfactory.newTransformer(new StreamSource(xsltFile));
   transformer.transform(new StreamSource(xmlFile), new StreamResult(System.out));
   ......
 
4. The files and directory are as the following
e:\work4\
|--XsltDemo.java
|--test.xml
|--test.xsl
|--process\
    |--processor.java
 
5. But the following error occured.
e:\work4\>java -cp E:\work4\process\processor.class;E:\work4\saxonb9-1-0-8j\saxon9.jar; XsltDemo
Error on line 18 of test.xsl:
  Cannot find a matching 0-argument function named {java:process.processor}processor.format()
Exception in thread "main" ; SystemID: file:/E:/work4/./test.xsl; Line#: 18; Column#: -1
net.sf.saxon.trans.XPathException: Cannot find a matching 0-argument function named {java:process.processor}processor.format()
 
6. Help me please, thanks.
 
 
 
 
2011-05-17

dba03