list4xt : Mailing list for the XT users community.
[list4xt] Re: Extension functions question
Subject: [list4xt] Re: Extension functions question
User: Website From: Mike Brown (mike@skew.org)
Date: 24/04/2001 - 20:07
4xtnews internet wrote:
> The constructor gets called without any problem. However, when I add a call
> to the method changeFormat, I get the error at the DOS prompt:
> changeFormat: no method with 3 arguments.
Assuming changeFormat() is an instance method, you need to tell XT which
object to call it on.
From http://www.jclark.com/xml/xt.html ...
A call to a function ns:foo where ns is bound to a namespace of the form
http://www.jclark.com/xt/java/className is treated as a call of the
static method foo of the class with fully-qualified name className.
[...]
A non-static method is treated like a static method with the this object
as an additional first argument.
SAXON works the same way.
In the end, it means that your class will not change. That is, you still
keep your instance method changeFormat() with 3 arguments. You just call
it with 4 arguments, the first one being the object that was returned by
the constructor.
So instead of:
<xsl:template match='/'>
<xsl:value-of select="d:new()" />
<xsl:value-of select="d:changeFormat('aa', 'bb', 'cc')" />
</xsl:template>
You want:
<xsl:template match='/'>
<xsl:variable name="MyObject" select="d:new()" />
<xsl:value-of select="d:changeFormat($MyObject, 'aa', 'bb', 'cc')" />
</xsl:template>
- Mike
_____________________________________________________________________________
mike j. brown, software engineer at | xml/xslt: http://skew.org/xml/
webb.net in denver, colorado, USA | personal: http://hyperreal.org/~mike/
--
Mailing list for the XT users community. (http://wabr.org)
(mailto:list4xt-request@4xt.org?Subject=unsubscribe to unsubscribe)
Archive générée par hypermail 2b28 le 01/06/2001 - 09:01 CEST
webmaster@4xt.org
|