Subject: Trying to call a single-parameter Java method from XSL
From: Ed Simon <ed.simon@xxxxxxxxxxx>
Date: Wed, 28 Apr 1999 11:17:36 -0400
|
Hi,
I seem to have a syntax error that I just can't resolve so I would
appreciate your help.
I'm using James Clark's XT processor.
Here's the XSL source:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns="http://www.w3.org/TR/REC-html40"
result-ns="">
<xsl:template name="callme">
<xsl:param-variable name="contents">Contents</xsl:param-variable>
<xsl:param-variable name="file">file.out</xsl:param-variable>
<xsl:param-variable name="str">Hello World</xsl:param-variable>
<xsl:value-of select="w:write($contents,string($file))"
xmlns:w="http://www.jclark.com/xt/java/com.jclark.xsl.sax.TextFileWriter" />
<xsl:value-of select="myjava:callme2()"
xmlns:myjava="http://www.jclark.com/xt/java/TestMyJava"/>
<xsl:value-of select="myjava:callme(string($str))"
xmlns:myjava="http://www.jclark.com/xt/java/TestMyJava"/>
</xsl:template>
<xsl:template match="/">
<xsl:call-template name="callme"/>
</xsl:template>
</xsl:stylesheet>
Here's the Java program with callme(String) and callme2():
import java.lang.*;
public class TestMyJava {
public static String callme(String text) {
return "*** " + text + " ***";
}
public static String callme2() {
return "*** $$$$$$$ ***";
}
}
Of course, any XML file (eg. "<test></test>") can be used as input.
Note: the write() method is in one of James Clark's classes.
With the call to the callme() method commented out, I do indeed get a file
with named "file.out" containing "Contents" as well as the result of calling
callme2() which is:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">*** $$$$$$$
***
With the call to the callme() method NOT commented out, I get the syntax
error:
file:/D:/MyWork/test/test.xsl:15: unrecognized operator name
when what I really want is the previous file output and the line
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">*** Hello
World ***
Can someone show me the error of my ways?
Thanks in advance, Ed
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|