cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Ernest <>
Subject Re: "argument type mismatch" when using fn:replace
Date Wed, 04 Aug 2010 21:09:42 GMT
 Hi Chris,

I remember having this problem, when I used the same version of Cocoon
one year ago.
I'm not 100% sure, but I mean fn:replace is a function belonging to
XPath 2.0 [1] and Cocoon 2.1.11 integrates a Xalan implementing XPath
1.0 only.
You should check which version of Xalan do you use and be sure this
version implements XPath 1.0 only.

I guess there are some ways to use a more up-to-date Xalan (implementing
XPath 2.0), but if I well remember I used another workaround. I'm no
more sure which one, but I guess you should find enough interesting
transformers [2].
It is not the best way, but it is possible to have a "heavy" two-passes
mechanism. At first xslt transformer adding JX instructions (like 'if
test' or 'set var' and variable instantiations) in the right places and
then a JX transformer evaluating JX instructions (like removing 'if
test' with a false condition or removing/evaluating 'set var' in order
to instance these variables in another places).

I hope it will help. Good luck.
Please give us your feedback about these ideas.



Le 04/08/2010 19:07, Christopher Schultz a écrit :
> All,
> I've been using Cocoon 2.1.11 successfully for quite some time, and I'm
> trying to add new capabilities to our product. I'm tripping-up when
> trying to use fn:replace with a regular expression.
> I'm on Debian Lenny with Debian's package-managed version of Sun JRE
> 1.6.0_20. I'm pretty sure I haven't messed with any of the libraries
> that ship with Cocoon (such as Xalan, etc.), so it should be a pretty
> stock install. I've packaged my own webapp rather than using the one
> that Cocoon can build for you. I can give details of that process if
> necessary.
> I tried to use <xsl:analyze-string> which gave me a "cannot use
> <xsl:analyze-string> here" error, so I tried changing my <xsl:stylesheet
> version="1.0"> to <xsl:stylesheet version="2.0"> which fixed that error,
> but didn't give me any output.
> At any rate, my current stylesheet header looks like this (with
> product-specific xmlns declarations removed for brevity:
> <?xml version="1.0" ?>
> <xsl:stylesheet version="2.0"
>     xmlns:xsl=""
>     xmlns:fn="">
> Specifically, my original function call attempt is this (trying to
> remove a query parameter form a query string):
>         <xsl:variable name="fixed-base-url">
>           <xsl:value-of select="$base-url" />
>           <xsl:text>?</xsl:text>
>           <xsl:value-of select="fn:replace($query-string,
> '(&amp;)?list_start=[0-9]+', '')" />
>         </xsl:variable>
> Executing this results in the following error:
> java.lang.IllegalArgumentException: argument type mismatch
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>     at java.lang.reflect.Method.invoke(
>     at
> org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(
>     at
> org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(
>     at
> org.apache.xalan.extensions.ExtensionsTable.extFunction(
>     at
> org.apache.xalan.transformer.TransformerImpl.extFunction(
>     at
> org.apache.xpath.functions.FuncExtFunction.execute(
>     at
> org.apache.xpath.Expression.executeCharsToContentHandler(
>     at
> org.apache.xalan.templates.ElemValueOf.execute(
>     at
> org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(
>     at
> org.apache.xalan.transformer.TransformerImpl.transformToRTF(
>         ...
>         (let me know if more of the stack trace would be helpful)
> I thought I might have some weird kind of data, so I tried something
> simpler, just to be sure:
>         <xsl:value-of select="fn:replace('abcabc', 'a', 'b')" />
> The above gives me the same error. Either commenting-out the entire
> <xsl:value-of> element or changing the select to select="''" removes the
> error.
> As for <xsl:analyze-string>, the following test resulted in no output:
> <xsl:analyze-string select="'abcabc'" regex="a">
> <xsl:matching-substring>
> A
> </xsl:matching-substring>
> <xsl:non-matching-substring>
> <xsl:value-of select="." />
> </xsl:non-matching-substring>
> </xsl:analyze-string>
> ... while I would have expected "AbcAbc" to be emitted. Perhaps I am
> misusing the <xsl:analyze-string> element.
> Can anyone offer any suggestions?
> Thanks,
> -chris

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message