[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: setting TopLevel variables externally with XT

Subject: Re: setting TopLevel variables externally with XT
From: "Jon Smirl" <jonsmirl@xxxxxxxxxxxx>
Date: Wed, 28 Jul 1999 19:16:16 -0400
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.