|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: setting TopLevel variables externally with XT
I just got this working. I figured it out by looking at how extension
functions are supported.
my servlet uses...
xsl.setGlobal("browser", "string('" + s + "')");
xsl.setGlobal("response", res);
stylesheet refers to $response with...
<xsl:value-of select="logon:redirect($response)"/>
to implement in XT SheetImpl add....
public void setGlobal(String variable, Object value) throws XSLException {
Name var = nameTable.createName(variable);
variableExprTable.put(var, new ExternalObjectExpr(value));
}
in xsl/epr add a new class...
package com.jclark.xsl.expr;
import com.jclark.xsl.om.*;
public class ExternalObjectExpr extends ConvertibleVariantExpr {
private final Object obj;
public ExternalObjectExpr(Object obj) {
this.obj = obj;
}
public Variant eval(Node node, ExprContext context) throws XSLException
{
if (obj instanceof String)
return new StringVariant((String)obj);
if (obj instanceof Number)
return new NumberVariant(((Number)obj).doubleValue());
if (obj instanceof Boolean)
return new BooleanVariant(((Boolean)obj).booleanValue());
if (obj instanceof NodeIterator)
return new NodeSetVariant((NodeIterator)obj);
if (obj instanceof Node)
return new NodeSetVariant(new SingleNodeIterator((Node)obj));
if (obj instanceof Variant)
return (Variant)obj;
return new ObjectVariant(obj);
}
}
According to the spec there should be an <xsl:param name="response" /> Then
I wouldn't use createName on response I would check instead to make sure it
had been declared.
Jon Smirl
jonsmirl@xxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








