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. Thomas. [1] http://www.w3.org/TR/xpath-functions/#func-replace [2] http://cocoon.apache.org/2.1/userdocs/transformers.html 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="http://www.w3.org/1999/XSL/Transform" > xmlns:fn="http://www.w3.org/2005/xpath-functions"> > > 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, > '(&)?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(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:404) > at > org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:440) > at > org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:222) > at > org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:473) > at > org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:208) > at > org.apache.xpath.Expression.executeCharsToContentHandler(Expression.java:313) > at > org.apache.xalan.templates.ElemValueOf.execute(ElemValueOf.java:274) > at > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400) > at > org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1988) > ... > (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: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org