Re: can't find files with spaces in their names

2010-08-15 Thread Thomas Ernest
 Hello Stephen,
> 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.
>
It seems very interesting :-)
> 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  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 .
>
> Am I going to have to write my own reader that does URL encoding?
>From my point of view, you don't have to write a reader to handle you
data/link. Because the (right) way to communicate with a server it with
URL, which involves URL encoding. It seems that you want to communicate
with your server, as with a standard file system. Since it isn't a file
system, you have to adapt you to web and web server requirements, i.e.
URL encoding.

I guess you use svn list to know what contains your svn repository.
(Please give us more details about this part) It must be interpreted via
a BASH at some point. So you should also use this BASH to translate your
listing into a "URL encoded" listing. I saw that sed with a file
urlencode.sed [1] can be very useful to reach this goal : svn list | sed
-f urlencode.sed

Finally, you should find a way before using , so that you
provide your server with data respecting web requirements/rules. There
are several ways :
1/ Encode URL via your BASH and the command sed.
2/ Use a XSLT style sheet to transform every occurrence of char
forbidden in URL string.
3/ Use EncodeURLTransformer. I'm not sure it releases what you want, but
its name seems to be interesting ;-) [2]
4/ Use POST data, because they likely don't require URL encoding.
5/ ... ?

There are many ways to fix your problem and I haven't provide you with a
exact fix, sorry. Whatever I wrote, I hope you understand that you have
to provide your server with URL encoded URLs. I mean the solution isn't
in developing a reader, but more in using or developing a transformer to
encode you URL or even in providing your system with URL encoded data
since the beginning.

Good luck.

Thomas.

[1] urlencode.sed
s/%/%25/g
s/ /%20/g
s/ /%09/g
s/!/%21/g
s/"/%22/g
s/#/%23/g
s/\$/%24/g
s/\&/%26/g
s/'\''/%27/g
s/(/%28/g
s/)/%29/g
s/\*/%2a/g
s/+/%2b/g
s/,/%2c/g
s/-/%2d/g
s/\./%2e/g
s/\//%2f/g
s/:/%3a/g
s/;/%3b/g
s//%3e/g
s/?/%3f/g
s/@/%40/g
s/\[/%5b/g
s/\\/%5c/g
s/\]/%5d/g
s/\^/%5e/g
s/_/%5f/g
s/`/%60/g
s/{/%7b/g
s/|/%7c/g
s/}/%7d/g
s/~/%7e/g
s/  /%09/g

[2] http://cocoon.apache.org/2.1/userdocs/encodeurl-transformer.html


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

2010-08-04 Thread Thomas Ernest
 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  which gave me a "cannot use
>  here" error, so I tried changing my  version="1.0"> to  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:
>
> 
>
>  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):
>
> 
>   
>   ?
>   
> 
>
> 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:
>
> 
>
> The above gives me the same error. Either commenting-out the entire
>  element or changing the select to select="''" removes the
> error.
>
> As for , the following test resulted in no output:
>
> 
> 
> A
> 
> 
> 
> 
> 
>
> ... while I would have expected "AbcAbc" to be emitted. Perhaps I am
> misusing the  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