You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Boissé Denis <de...@umontreal.ca> on 2007/08/01 18:22:28 UTC

regexpUriMatcher

Hi,

 

I have Cocoon version 2.1.10

 

Do regexpUriMatcher work with Ungreedy Matching:

Example: <map:match type="regexp" pattern="^temp/(.*?)/$">   

 

Usually ungreedy matcher are in a form (.*?)  and suppose to match something like temp/hello/ or temp/hi/ 

but not matching something like temp/hello/dir/  (that's what happen to me)

 

Do Cocoon version  2.1.10 still use that link for regexp ?  (I saw that in mailing list archive 2005)

http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html

 

 

Denis


RE: regexpUriMatcher

Posted by Boissé Denis <de...@umontreal.ca>.

Thank for you're help:

You said:

^temp/(.*?)/  matches temp/hello/

Yes it's true

^temp/(.*?)/  will also matches temp/hello/dir/ , temp/hello/dir/dir1/, etc

It's the same behaviour for ^temp/(.*?)/$  (I notice that in my program)

Yes it make sense that Cocoon uses Java's builtin regexp classes



-----Message d'origine-----
De : Tobia Conforto [mailto:tobia.conforto@linux.it] 
Envoyé : 2 août 2007 08:50
À : users@cocoon.apache.org
Objet : Re: regexpUriMatcher

Boissé Denis wrote:
> Usually ungreedy matcher are in a form (.*?) and suppose to match
> something like temp/hello/ or temp/hi/ but not matching something like
> temp/hello/dir/ (that's what happen to me)

As Alfred said, you cannot use the 'greediness' of quantifiers to
control the matching of an anchored regexp, because they will always
grow as much as needed to match the string, if possible.

You tipically use them to give more weight to one piece of the regexp
with respect to another piece.  Compare:

^temp/(.*?)/(.*)/$

^temp/(.*)/(.*?)/$

They will match "temp/a/b/c/" as ("a", "b/c") and ("a/b", "c") resp.
What you described is true when the regexp is not anchored:

^temp/(.*?)/  matches temp/hello/
^temp/(.*)/   matches temp/hello/dir/


Anyways, I believe Cocoon uses Java's builtin regexp classes:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: regexpUriMatcher

Posted by Alfred Nathaniel <an...@apache.org>.
On Thu, 2007-08-02 at 14:49 +0200, Tobia Conforto wrote:
> 
> Anyways, I believe Cocoon uses Java's builtin regexp classes:
> 

Cocoon 2.1 still wants to be usable with JDK1.3.  Therefore regexp use

http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html

>>From the user's point of view that does not make much difference.

Cheers, Alfred.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: regexpUriMatcher

Posted by Tobia Conforto <to...@linux.it>.
Boissé Denis wrote:
> Usually ungreedy matcher are in a form (.*?) and suppose to match
> something like temp/hello/ or temp/hi/ but not matching something like
> temp/hello/dir/ (that's what happen to me)

As Alfred said, you cannot use the 'greediness' of quantifiers to
control the matching of an anchored regexp, because they will always
grow as much as needed to match the string, if possible.

You tipically use them to give more weight to one piece of the regexp
with respect to another piece.  Compare:

^temp/(.*?)/(.*)/$

^temp/(.*)/(.*?)/$

They will match "temp/a/b/c/" as ("a", "b/c") and ("a/b", "c") resp.
What you described is true when the regexp is not anchored:

^temp/(.*?)/  matches temp/hello/
^temp/(.*)/   matches temp/hello/dir/


Anyways, I believe Cocoon uses Java's builtin regexp classes:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: regexpUriMatcher

Posted by Boissé Denis <de...@umontreal.ca>.
Yes thank you for that point:

"... but as much as necessary to make the whole pattern succeed."

In fact what I want to match is something like that:
temp/foo/
temp/foo/index.html

and I find the solution with wildcard:

<map:match type="wildcard" pattern="temp/*/>
and 
<map:match type="wildcard" pattern="temp/*/index.html>


..but after what you said I did:
<map:match type="regexp" pattern="^temp/([^/]+)/(index.html)?$">



-----Message d'origine-----
De : Alfred Nathaniel [mailto:anathaniel@apache.org] 
Envoyé : 1 août 2007 20:08
À : users@cocoon.apache.org
Objet : Re: regexpUriMatcher

On Wed, 2007-08-01 at 12:22 -0400, Boissé Denis wrote:
> Hi,
> 
>  
> 
> I have Cocoon version 2.1.10
> 
>  
> 
> Do regexpUriMatcher work with Ungreedy Matching:
> 
> Example: <map:match type="regexp" pattern="^temp/(.*?)/$">   
> 
>  
> 
> Usually ungreedy matcher are in a form (.*?)  and suppose to match
> something like temp/hello/ or temp/hi/ 
> 
> but not matching something like temp/hello/dir/  (that's what happen
> to me)

Ungreedy means that it should match as little as possible but as much as
necessary to make the whole pattern succeed.

What you apparently want to achieve is pattern="^temp/[^/]+/$", or even
simpler <map:match type="wildcard" pattern="temp/*/"/>.

HTH, Alfred.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


JSP problem

Posted by Boissé Denis <de...@umontreal.ca>.


I have Cocoon version 2.1.10
I have tomcat version 6.0.10
I have Java version 1.6

I put these lines in the sitemap:

<map:match pattern="revue/testJSP.html">
  <map:read type="jsp" src="revue/testJSP.jsp" mime-type="text/html" />
</map:match>

The file testJSP.jsp only display "Hello World"  

When I type the URL "http://localhost:8080/cocoon/revue/testJSP.html"

I have the following error:

org.apache.jasper.JasperException: 
Impossible de compiler la classe pour la JSP  
(English: Not able to compile JSP classe)

If somebody knows something ?

Thanks for your help


Denis


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: regexpUriMatcher

Posted by Alfred Nathaniel <an...@apache.org>.
On Wed, 2007-08-01 at 12:22 -0400, Boissé Denis wrote:
> Hi,
> 
>  
> 
> I have Cocoon version 2.1.10
> 
>  
> 
> Do regexpUriMatcher work with Ungreedy Matching:
> 
> Example: <map:match type="regexp" pattern="^temp/(.*?)/$">   
> 
>  
> 
> Usually ungreedy matcher are in a form (.*?)  and suppose to match
> something like temp/hello/ or temp/hi/ 
> 
> but not matching something like temp/hello/dir/  (that’s what happen
> to me)

Ungreedy means that it should match as little as possible but as much as
necessary to make the whole pattern succeed.

What you apparently want to achieve is pattern="^temp/[^/]+/$", or even
simpler <map:match type="wildcard" pattern="temp/*/"/>.

HTH, Alfred.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org