You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Harald Hett <h....@gis-systemhaus.de> on 2000/11/13 12:31:01 UTC
[Xalan 1.2J] Parameters in extension functions
Hello!
Can anyone give me a hint, how to get the values of top-level parameters
inside a java extension function for Xalan 1.2?
Thank you!
--
Harald Hett <h....@gis-systemhaus.de>
Gesellschaft für integrierte Systemplanung
Re: [Xalan 1.2J] Parameters in extension functions
Posted by Gary L Peskin <ga...@firstech.com>.
Harald Hett wrote:
>
> Meanwhile I have encountered another possibility that works with the
> first statement ("myext:init($filename)") as well:
>
> public String init (ResultTreeFrag frag)
> {
> Node node = frag.getFirstChild();
> return "set a parameter to " + node.getNodeValue();
> }
Harry --
This may work for you. However, in the general case, the string value
of a DocumentFragment is the concatenation of the string values of all
of the text node descendants in document order. That's all descendants,
not just children, and may require a deep navigation below the
DocumentFragment. This is a little more code so I just recommended the
shortcut of string(...) in XSLT so that Xalan was doing all of the tree
walking work.
Gary
Re: [Xalan 1.2J] Parameters in extension functions
Posted by Harald Hett <h....@gis-systemhaus.de>.
Meanwhile I have encountered another possibility that works with the
first statement ("myext:init($filename)") as well:
public String init (ResultTreeFrag frag)
{
Node node = frag.getFirstChild();
return "set a parameter to " + node.getNodeValue();
}
Harry
Re: [Xalan 1.2J] Parameters in extension functions
Posted by Harald Hett <h....@gis-systemhaus.de>.
Great!
Now it works.
I had tried that before with "String($filename)", which did not work
because of the upper case.
Thank you!
Harry.
Gary L Peskin wrote:
>
> Harald Hett wrote:
> > But if I try to use a Parameter like this:
> >
> > <xsl:value-of select="myext:init($filename)"/>
> >
> > xalan searches for a method with the following signature
> >
> > public String init (ResultTreeFrag frag);
> >
> > And now I have no idea, how I could get the value from frag.
>
> The best way to do this in XalanJ1 is:
>
> <xsl:value-of select="myext:init(string($filename))"/>
>
> which should look for the method with the string argument.
>
> Gary
Re: [Xalan 1.2J] Parameters in extension functions
Posted by Gary L Peskin <ga...@firstech.com>.
Harald Hett wrote:
> But if I try to use a Parameter like this:
>
> <xsl:value-of select="myext:init($filename)"/>
>
> xalan searches for a method with the following signature
>
> public String init (ResultTreeFrag frag);
>
> And now I have no idea, how I could get the value from frag.
The best way to do this in XalanJ1 is:
<xsl:value-of select="myext:init(string($filename))"/>
which should look for the method with the string argument.
Gary
Re: [Xalan 1.2J] Parameters in extension functions
Posted by Harald Hett <h....@gis-systemhaus.de>.
Thank you Gary,
but I have allready tried that. For instance a method like
public String init (String aParameter)
{
return "set a parameter to " + aParameter;
}
defines an extension function for the namespace 'myext'.
This works fine if a call from inside the XSL-Script looks like this:
<xsl:value-of select="myext:init('out.log')"/>
But if I try to use a Parameter like this:
<xsl:value-of select="myext:init($filename)"/>
xalan searches for a method with the following signature
public String init (ResultTreeFrag frag);
And now I have no idea, how I could get the value from frag.
Harry
Gary L Peskin wrote:
>
> Harald Hett wrote:
> >
> > Hello!
> > Can anyone give me a hint, how to get the values of top-level parameters
> > inside a java extension function for Xalan 1.2?
>
> Harald --
>
> You'll need to pass those parameters in as parameters of the extension
> function call.
>
> Gary
Re: [Xalan 1.2J] Parameters in extension functions
Posted by Gary L Peskin <ga...@firstech.com>.
Harald Hett wrote:
>
> Hello!
> Can anyone give me a hint, how to get the values of top-level parameters
> inside a java extension function for Xalan 1.2?
Harald --
You'll need to pass those parameters in as parameters of the extension
function call.
Gary