You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Chris P. McCabe" <ch...@choicehotels.com> on 2000/10/11 20:05:37 UTC

Passing non-String objects as stylesheet parameters

I would like to pass a Java object as a parameter to my stylesheet, and
then call a method on that object in the stylesheet, but I can't get it
to work.  Here is an example of what I am doing:

In the Java code:
processor.setStylesheetParam("MyObject", new XObject(new Foo()));

assume Foo has a method:  String get(String key)

In the stylesheet:
<xsl:param name="MyObject"/>
<xsl:value-of select="java:get($MyObject, 'thekey')"/>

I get the following error:
Call to extension function failed: method call/new failed:
java.lang.NoSuchMethodException:
org.apache.xalan.xslt.ResultTreeFrag.get(class java.lang.String) -- no
signature match

Converting the ResultTreeFrag to a NodeList gives the same sort of
error:
Call to extension function failed: method call/new failed:
java.lang.NoSuchMethodException:
org.apache.xalan.xpath.MutableNodeListImpl.get(class java.lang.String)
-- no signature match

Is there any way to get this to work?

Chris

--
Chris P. McCabe  - Senior Software Systems Architect
Choice Hotels International - Information Technology
chris_mccabe@choicehotels.com



Re: Passing non-String objects as stylesheet parameters

Posted by "Chris P. McCabe" <ch...@choicehotels.com>.
Sorry, false alarm.  It works fine.  There was an obscure bug in my code
that was causing that parameter to not be set just as you suspected.

Thanks,
Chris

Gary L Peskin wrote:

> "Chris P. McCabe" wrote:
> >
> > I would like to pass a Java object as a parameter to my stylesheet,
> > and then call a method on that object in the stylesheet, but I can't
> > get it to work.  Here is an example of what I am doing:
> >
> > In the Java code:
> > processor.setStylesheetParam("MyObject", new XObject(new Foo()));
> >
> > assume Foo has a method:  String get(String key)
> >
> > In the stylesheet:
> > <xsl:param name="MyObject"/>
> > <xsl:value-of select="java:get($MyObject, 'thekey')"/>
> >
> > I get the following error:
> > Call to extension function failed: method call/new failed:
> > java.lang.NoSuchMethodException:
> > org.apache.xalan.xslt.ResultTreeFrag.get(class java.lang.String) -- no
> > signature match
>
> Chris --
>
> Can you insert
>
> <debug>
> <xsl:value-of select="$MyObject"/>
> </debug>
>
> I have a feeling that MyObject is not making it as a parameter to the
> stylesheet or to the template invoking your xsl:value-of, if it's in a
> template.  Can you post the entire stylesheet along with a sample of the
> input file and then we can recreate the problem.
>
> HTH,
> Gary

--
Chris P. McCabe  - Senior Software Systems Architect
Choice Hotels International - Information Technology
chris_mccabe@choicehotels.com



Re: Passing non-String objects as stylesheet parameters

Posted by Gary L Peskin <ga...@firstech.com>.
"Chris P. McCabe" wrote:
> 
> I would like to pass a Java object as a parameter to my stylesheet,
> and then call a method on that object in the stylesheet, but I can't
> get it to work.  Here is an example of what I am doing:
> 
> In the Java code:
> processor.setStylesheetParam("MyObject", new XObject(new Foo()));
> 
> assume Foo has a method:  String get(String key)
> 
> In the stylesheet:
> <xsl:param name="MyObject"/>
> <xsl:value-of select="java:get($MyObject, 'thekey')"/>
> 
> I get the following error:
> Call to extension function failed: method call/new failed:
> java.lang.NoSuchMethodException:
> org.apache.xalan.xslt.ResultTreeFrag.get(class java.lang.String) -- no
> signature match

Chris --

Can you insert

<debug>
<xsl:value-of select="$MyObject"/>
</debug>

I have a feeling that MyObject is not making it as a parameter to the
stylesheet or to the template invoking your xsl:value-of, if it's in a
template.  Can you post the entire stylesheet along with a sample of the
input file and then we can recreate the problem.

HTH,
Gary