You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Volkm@r" <pl...@arcor.de> on 2004/05/18 14:40:21 UTC

Exclude String from RegexpHostMatcher

How can I exclude a certain character string from a match?
I am using the RegexpHostMatcher for redirecting virtual hosts to their 
own directories. No problem so far.

Now, in order to keep Cocoon's samples and docs in $Cocoon-Home, I want 
to exclude "cocoon" from this match.

I searched for a suitable expression [1] and tried the following

================================
<map:match pattern="(.*(?!cocoon)):(.*)" type="regexphost">
   <map:mount check-reload="yes" src="/srv/www/{1}/" uri-prefix=""/>
</map:match>
================================

But I am only getting this error message:

   org.apache.avalon.framework.component.ComponentException:
   Invalid pattern '(.*(?!cocoon)):(.*)' for matcher at line ...

That's what I don't understand. How can I fix it?

Thanks for your attention

[1] <http://www.zvon.org/other/PerlTutorial/Output/example23.html>
-- 
volkm@r


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


Re: Exclude String from RegexpHostMatcher

Posted by "Volkm@r" <pl...@arcor.de>.
Joerg Heinicke wrote:
> On 18.05.2004 15:11, Volkm@r wrote:
> 
>>> so <map:match type="regexp" > should work.
>>
>>
>>      <map:match type="regexphost" > indeed works (for other expressions)
> 
> 
> The working of different expressions depend on the regexp implementation 
> in use. In Cocoon it's either Apache Jakarta RegExp, Apache Jakarta Oro 
> or Sun JDK RegExp.
> 
> For the matcher the Jakarta RegExp package is in use:
> http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java?rev=1.4&view=markup 
> 
> 
>> [1] <http://www.zvon.org/other/PerlTutorial/Output/example23.html> 
> 
> 
> While Jakarta Oro claims Perl5 compatibility Jakarta RegExp does not.
> 
> If you need Perl5 compatibility you probably have to write your own 
> matcher.
> 

Thanks a lot for clarification. I guess I will stick to the standards.


-- 
volkm@r


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


Re: Exclude String from RegexpHostMatcher

Posted by Joerg Heinicke <jo...@gmx.de>.
On 18.05.2004 15:11, Volkm@r wrote:

>> so <map:match type="regexp" > should work.
> 
>      <map:match type="regexphost" > indeed works (for other expressions)

The working of different expressions depend on the regexp implementation 
in use. In Cocoon it's either Apache Jakarta RegExp, Apache Jakarta Oro 
or Sun JDK RegExp.

For the matcher the Jakarta RegExp package is in use:
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java?rev=1.4&view=markup

> [1] <http://www.zvon.org/other/PerlTutorial/Output/example23.html> 

While Jakarta Oro claims Perl5 compatibility Jakarta RegExp does not.

If you need Perl5 compatibility you probably have to write your own matcher.

> <map:match pattern="(.*(?!cocoon)):(.*)" type="regexphost">
>   <map:mount check-reload="yes" src="/srv/www/{1}/" uri-prefix=""/>
> </map:match> 

On the other hand if it is just one match you want to exclude, just add 
a matcher before the one above, that matches on cocoon. This works 
because the first matcher matching the expression wins.

Joerg

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


Re: Exclude String from RegexpHostMatcher

Posted by Jorg Heymans <jh...@domek.be>.
Volkm@r wrote:

> 
> Do I have to change the "src" attribute to "factory"? I can't see this 
> anywhere in Cocoon's sitemap.
not sure, got that snippet from the docs
> 
>>
>> so <map:match type="regexp" > should work.
> 
> 
>      <map:match type="regexphost" > indeed works (for other expressions)
it does look like you regexp is wrong then. I don't know what regex 
syntax is allowed though, try the j2se one.

> 
> What is a "POJO"? Any url for me where i can do this test?
sorry POJO is plain old java object.
Just test your regexp in a normal class to see if it does what you 
expect it to do.

> 
> Thanks for your help.
HTH
Jorg
> 


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


Re: Exclude String from RegexpHostMatcher

Posted by "Volkm@r" <pl...@arcor.de>.
Jorg Heymans wrote:
> Did you switch the map:match to use regexp instead of wildcard?

No. But to "regexphost" instead. I added the following line to the 
<map:matchers/> section:

<map:matcher logger="sitemap.matcher.host" name="regexphost" 
src="org.apache.cocoon.matching.RegexpHostMatcher"/>

> 
> <map:matchers default="wildcard">
>  <map:matcher name="wildcard" 
> factory="org.apache.cocoon.matching.WildcardURIMatcher"/>
>  <map:matcher name="regexp" 
> factory="org.apache.cocoon.matching.RegexpURIMatcher"/>
> </map:matchers>

Do I have to change the "src" attribute to "factory"? I can't see this 
anywhere in Cocoon's sitemap.

> 
> so <map:match type="regexp" > should work.

      <map:match type="regexphost" > indeed works (for other expressions)
> 
> 
> I've never actually used this but this is how i would expect it to work. 
> If it still fails then you should test your regexp first outside of 
> cocoon in a POJO

What is a "POJO"? Any url for me where i can do this test?

Thanks for your help.

-- 
volkm@r


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


Re: Exclude String from RegexpHostMatcher

Posted by Jorg Heymans <jh...@domek.be>.
Did you switch the map:match to use regexp instead of wildcard?

<map:matchers default="wildcard">
  <map:matcher name="wildcard" 
factory="org.apache.cocoon.matching.WildcardURIMatcher"/>
  <map:matcher name="regexp" 
factory="org.apache.cocoon.matching.RegexpURIMatcher"/>
</map:matchers>

so <map:match type="regexp" > should work.


I've never actually used this but this is how i would expect it to work. 
If it still fails then you should test your regexp first outside of 
cocoon in a POJO


Volkm@r wrote:

> How can I exclude a certain character string from a match?
> I am using the RegexpHostMatcher for redirecting virtual hosts to their 
> own directories. No problem so far.
> 
> Now, in order to keep Cocoon's samples and docs in $Cocoon-Home, I want 
> to exclude "cocoon" from this match.
> 
> I searched for a suitable expression [1] and tried the following
> 
> ================================
> <map:match pattern="(.*(?!cocoon)):(.*)" type="regexphost">
>   <map:mount check-reload="yes" src="/srv/www/{1}/" uri-prefix=""/>
> </map:match>
> ================================
> 
> But I am only getting this error message:
> 
>   org.apache.avalon.framework.component.ComponentException:
>   Invalid pattern '(.*(?!cocoon)):(.*)' for matcher at line ...
> 
> That's what I don't understand. How can I fix it?
> 
> Thanks for your attention
> 
> [1] <http://www.zvon.org/other/PerlTutorial/Output/example23.html>


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