This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Saxon custom extensions problem
- To: "XSL List" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Saxon custom extensions problem
- From: "Gustaf Liljegren" <gustaf dot liljegren at xml dot se>
- Date: Tue, 16 Oct 2001 12:13:47 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Finally upgraded to Saxon 6.4.3. :-)
Now I have some questions on the documentation for custom extensions to
Saxon, namely the extensibility.html document:
'With the short-cut technique, the URI for the namespace identifies
the class where the external function will be found. The namespace
URI must either be "java:" followed by the fully-qualified class
name (for example xmlns:date="java:java.util.Date"), [...] The class
must be on the classpath.'
Okay, here's my custom Java extension function:
class ReverseString {
public static String reverseIt(String source) {
int i, len = source.length();
StringBuffer dest = new StringBuffer(len);
for (i = (len - 1); i >= 0; i--) {
dest.append(source.charAt(i));
}
return dest.toString();
}
}
I can take Java syntax, but I'm not so familiar with terminology like
"fully-qualified class name". I have no class library, just a single
function, and in the same directory as the stylesheet. So if I want to use
it as an extension for an FO transformation, I guess I should write:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:my="java:ReverseString">
And later on, I use it like this:
<xsl:value-of select="my:reverseIt(.)"/>
Something is clearly wrong, and it seems to happen at the namespace
declaration already:
The URI java:ReverseString does not identify an external Java class
Transformation failed: run-time errors were reported
For the future, it would be helpful to include two tiny (but complete)
examples in the documentation: one for importing, and another for exporting
content from the stylesheet to a Java application.
Gustaf Liljegren
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list