You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jon Smirl <jo...@mediaone.net> on 2000/07/26 05:26:38 UTC

Xalan-C: Extension functions

I've been looking at the extension function sample and it's not clear to me
how to implement this function for Xalan. It not clear to me how the clone()
function is used.

XT implemented the concept of an opaque variable (this is allowed in the
spec according to JC). An opaque variable can't be used in the stylesheet,
but it can be passed back to extension functions.

So from XT I could do this:

public class Total {
  double sum = 0;
  public double runningTotal(double t) {
    sum += t;
    return sum;
  }
}
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:total="http://www.jclark.com/xt/java/net.px7.extension.Total"
version="1.0">

<xsl:variable name="total" select="total:new()" />
and later do this multiple times...
<xsl:with-param name="value" select="total:runningTotal($total,
number(mAmount))"/>

$total is an opaque variable that has no meaning to XSL but to Java it
became the 'this' pointer.

Jon Smirl
jonsmirl@mediaone.net