I don't know if this is where you want to be heading but if you define a xsl:variable to be the Java object you are interested in.
then create an extension element where you look for an attribute where the value of the attribute is the name of the xsl variable.


Once you have the name, you can fetch its value from the expression context with this code from an extension element

XObject value = (XObject) context.getTransformer().getXPathContext().getVarStack().getVariableOrParam()
I think, haven't actually used it.


or from an extension function, as I do in the SQL code, org.apache.xalan.lib.sql.SQLQueryProcessor.java
XObject value = (XObject)ctx.getVariableOrParam(new QName(parm.getName()));


-JG


Joseph Shraibman wrote:



John Gentilin wrote:

Joe,
Are you trying to write an extension element or an extension function.

I figured out the function, not the element.

Extension Elements:
If you look at the source code for the Redirect extension, it is short and to the point
piece of code to see how extensions work. With Extension Functions, I don't think you
can pass in objects although that may be incorrect.


You can, though it is a bit non-intuitive.

You do:
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
        xmlns:java="http://xml.apache.org/xslt/java";
        exclude-result-prefixes="java"
        version="1.0">

... then

<xsl:param name="myparam"  />

... then <xsl:value-of select="java:methodname($myparam, $othervar)" />

Go to http://xml.apache.org/xalan-j/extensions.html#java-namespace and scroll down to the example.

<xsl:value-of select="java:format($formatter, $date)"/> does the same thing, where format is the method name and $formatter is the stf that format() is called on.

But what I really want to figure out is how do have the extention element operate on a passed in java object.



-- -------------------------------------- John Gentilin Eye Catching Solutions Inc. 18314 Carlwyn Drive Castro Valley CA 94546

   Contact Info
[EMAIL PROTECTED]
Ca Office 1-510-881-4821
NJ Office 1-732-422-4917




Reply via email to