You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Guoliang Cao <ca...@ispsoft.com> on 2000/12/26 22:42:17 UTC

About extension in Xalan 2.0D05.

To those who are contributing to Xalan and this mailing list:

Merry  Christmas !
Happy New Year !


I'm calling a extension function like this:

              <xsl:copy-of
select="ext-security:getAccessInfo('auth1','a','b')/*"/>

It is totally ok with xalan 2.0D01.  But reports error message if using
xalan 2.0D05.   I've checked the classpath and the parameter type. They
are correct. What problem can this be?  Thanks for your help.

java.lang.NoSuchMethodException: For extension function, could not find
method java.lang.String.getAccessInfo([ExpressionContext,] #STRING,
#STRING).
 at
org.apache.xalan.extensions.MethodResolver.getMethod(MethodResolver.java:307)

 at
org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:373)

 at
org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:254)

 at
org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:137)

 at org.apache.xpath.XPath.execute(XPath.java:243)
 at org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:158)
 at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2019)

 at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:680)

 at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:515)

 at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:191)

 at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:515)

 at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:191)

 at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:515)

 at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:191)

 at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:515)

 at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:191)

 at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2019)

 at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:680)

 at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2019)

 at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:1917)

 at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1105)



Java method declaration:
public static Document getAccessInfo(String authToken,  String acctId,
String deviceId)

xsl file:
......
  xmlns:ext-security="http://www.ispsoft.com/xslt/Security"
  extension-element-prefixes="ext-security"
......
  <lxslt:component  prefix="ext-security"
    functions="getAccessInfo">
    <lxslt:script lang="javaclass"
      src="com.abc.XSLTExtension"/>
  </lxslt:component>
......


Moreover, in xalan 2.0D01  I can skip the param definition in a template
and use it directly, but now Xalan will report an error when it finds an
un-defined variable/param.
<xsl:apply-templates select="a">
  <xsl:with-param name="param_b" select="b"/>
</xsl:apply-templates>

<xsl:template select="a">
<b><xsl:value-of select="$param_b"/></b>
...
</xsl:template>

ERROR:
VariableReference given for variable out of context or without
definition!  Name = param_b


Re: About extension in Xalan 2.0D05.

Posted by Gary L Peskin <ga...@firstech.com>.
Guoliang Cao wrote:
> I'm calling a extension function like this:
> 
>               <xsl:copy-of
> select="ext-security:getAccessInfo('auth1','a','b')/*"/>
> 
> It is totally ok with xalan 2.0D01.  But reports error message if using
> xalan 2.0D05.   I've checked the classpath and the parameter type. They
> are correct. What problem can this be?  Thanks for your help.

Guoliang --

The most likely cause for this is that com.abc.XSLTExtension is not on
your CLASSPATH.  Can you double check this and see if this is the
problem?

In the meantime, I'll try to recreate the situation here and see if I
can reproduce the problem.

> Moreover, in xalan 2.0D01  I can skip the param definition in a template
> and use it directly, but now Xalan will report an error when it finds an
> un-defined variable/param.
> <xsl:apply-templates select="a">
>   <xsl:with-param name="param_b" select="b"/>
> </xsl:apply-templates>
> 
> <xsl:template select="a">
> <b><xsl:value-of select="$param_b"/></b>
> ...
> </xsl:template>
> 
> ERROR:
> VariableReference given for variable out of context or without
> definition!  Name = param_b

I think that this behavior is correct and that the .D01 behavior was in
error.  Try adding a

  <xsl:param name="param_b">

just after the xsl:template.  This should allow you to "receive" the
passed parameter.  The XSLT Recommendation section 11.6 states "It is
not an error to pass a parameter x to a template that does not have an
xsl:param element for x; the parameter is simply ignored."  I think
that's what Xalan is doing.

Gary