Christopher Schultz | 4 Aug 19:07 2010
Picon

"argument type mismatch" when using fn:replace


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):
(Continue reading)

Thomas Ernest | 4 Aug 23:09 2010
Picon

Re: "argument type mismatch" when using fn:replace

 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 :
(Continue reading)

Christopher Schultz | 5 Aug 18:57 2010
Picon

Re: "argument type mismatch" when using fn:replace


Thomas,

On 8/4/2010 5:09 PM, Thomas Ernest wrote:
> 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.

That would certainly explain the problem.

My Cocoon has Xalan-2.7.1, which only supports XSLT 1.0 and XPath 1.0.
It's odd that Xalan 2.7.1 is the latest version available. Is Xalan
dead? Does Saxon replace it?

> You should check which version of Xalan do you use and be sure this
> version implements XPath 1.0 only.

You were right, although I was thrown by the fact that changing the
stylesheet version to "2.0" allowed me to use the <xsl:analyze-string>
element, which is apparently not implemented. I guess anything not
implemented is ignored. Does that sound right?

For the time being, I implemented a manual search-and-replace which does
work with Cocoon 2.1.11.

I think my best option is to upgrade Cocoon. It's about time, anyway.
It's always so nerve-wracking to upgrade something so vital to your
product, though :)
(Continue reading)

Christopher Schultz | 5 Aug 19:07 2010
Picon

Re: "argument type mismatch" when using fn:replace


All,

On 8/5/2010 12:57 PM, Christopher Schultz wrote:
> On 8/4/2010 5:09 PM, Thomas Ernest wrote:
>> 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.
> 
> That would certainly explain the problem.
> 
> My Cocoon has Xalan-2.7.1, which only supports XSLT 1.0 and XPath 1.0.
> It's odd that Xalan 2.7.1 is the latest version available. Is Xalan
> dead? Does Saxon replace it?

It appears that no current version of Cocoon supports XSLT 2.0. Is that
correct?

Since neither Xalan nor Cocoon support XSLT/XPath 2.0 directly, is it
okay to simply replace Xalan with another XSLT processor like Saxon? I'm
unsure of what level of dependency Cocoon has on Xalan... hopefully,
everything is done using the JAXP interfaces and not
implementation-specific calls, but there may be some Xalan-specific
configuration that Cocoon provides in order to grease the wheels a bit.

Any suggestions that anyone has could be greatly appreciated.

Thanks,
(Continue reading)

Mark Eggers | 5 Aug 19:32 2010
Picon

Re: "argument type mismatch" when using fn:replace

I haven't used Cocoon in quite a while, but I remember that you can use Saxon 
instead of Xalan. A quick google search brings up the following old blog entry 
from Vadim:

http://blog.reverycodes.com/archives/000034.html

Maybe that's a good start?

/mde/


----- Original Message ----
From: Christopher Schultz <chris <at> christopherschultz.net>
To: users <at> cocoon.apache.org
Sent: Thu, August 5, 2010 10:07:26 AM
Subject: Re: "argument type mismatch" when using fn:replace

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

On 8/5/2010 12:57 PM, Christopher Schultz wrote:
> On 8/4/2010 5:09 PM, Thomas Ernest wrote:
>> 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.
> 
(Continue reading)

Christopher Schultz | 5 Aug 19:42 2010
Picon

Re: "argument type mismatch" when using fn:replace


Mark,

On 8/5/2010 1:32 PM, Mark Eggers wrote:
> I haven't used Cocoon in quite a while, but I remember that you can use Saxon 
> instead of Xalan. A quick google search brings up the following old blog entry 
> from Vadim:
> 
> http://blog.reverycodes.com/archives/000034.html
> 
> Maybe that's a good start?

Thanks for the tip: I'll start there.

It does look like switching from Xalan to Saxon is relatively painless,
and, if the performance claims in that post are accurate, I may even get
a faster product in the end.

Thanks,
-chris
florent andré | 6 Aug 22:39 2010

Re: "argument type mismatch" when using fn:replace

Hi Chris,

Good news, you don't have to switch all your cocoon app from xalan to 
saxon !!

You can easily have a pretty <map:transformer type="xslt2.0" 
src="path/to/my/xslt2.0.xsl"/>

For this, you just have to :
1) add this libs in your classpath : 
http://svn.4sengines.eu/modcontrib/xslt2.0/trunk/java/lib/

2) patch your cocoon.xconf with this 
http://svn.4sengines.eu/modcontrib/xslt2.0/trunk/config/cocoon-xconf/component-declaration.xconf
( just copy the "component" node into the )

3) declare a transformer in your sitemap : 
http://svn.4sengines.eu/modcontrib/xslt2.0/trunk/sitemap.xmap
( components/tranformer node)

4) Add... use it ! example also here 
http://svn.4sengines.eu/modcontrib/xslt2.0/trunk/sitemap.xmap into 
<map:match pattern="*">

Just use when you need it, no global impact, I use it many times with no 
problems and enjoy xslt2.0.

HTH
++

(Continue reading)

Stephen Rosman | 11 Aug 04:23 2010
Picon

<map:reader> can't find files with spaces in their names

I'm using cocoon 2.2.

Background:
I'm trying to build a cocoon presentation layer on top of an
subversion repository. A user makes a request and the cocoon
application checks to see if a directory index needs to be added, adds
menus and navigation trails, handles mobile formatting etc but does a
ci:includexml to get the content of the page from the subversion
repository.

Problem:
Some of the files in the subversion repository have spaces in the file
names (and it's not feasible to have a repository without any URL
encoding required characters) which are decoded (by the matcher?) and
then passed off to the reader which makes a request of the source
resolver without re-encoding the spaces (I think).

I assume this is what is happening because I get a FileNotFound error
when using <ci:includexml> with the src set stuff from the request
generator but it works when I use xslt to replace the spaces with
%20s.  I can fix the problem when constructing pages using xslt but
not for images and other stuff that needs to be <map:read>.

Am I going to have to write my own reader that does URL encoding?

--

-- 
Stephen Rosman
Christopher Schultz | 11 Aug 18:58 2010
Picon

Re: "argument type mismatch" when using fn:replace


André,

On 8/6/2010 4:39 PM, florent andré wrote:
> Good news, you don't have to switch all your cocoon app from xalan to
> saxon !!

Thanks for the tip! It's great to know that Xalan and Saxon can be used
in the same Cocoon instance. That will dramatically lessen the burden of
testing, since I'll only have to test the one stylesheet that requires
XSLT 2.0 and XPath 2.0.

Thanks!

-chris
Jimmy Zhang | 13 Aug 09:46 2010
Picon
Picon

[ANN]VTD-XML 2.9

VTD-XML 2.9, the next generation XML Processing API for SOA and Cloud computing, has been released. Please visit  https://sourceforge.net/projects/vtd-xml/files/ to download the latest version.
  • Strict Conformance
    • VTD-XML now fully conforms to XML namespace 1.0 spec
  • Performance Improvement
    • Significantly improved parsing performance for small XML files
  • Expand Core VTD-XML API 
    • Adds getPrefixString(), and toNormalizedString2()
  • Cutting/Splitting
    • Adds getSiblingElementFragment() 
  • A number of bug fixes and code enhancement including:
    • Fixes a bug for reading very large XML documents on some platforms
    • Fixes a bug in parsing processing instruction
    • Fixes a bug in outputAndReparse()

Gmane