You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ferdinand Soethe <fe...@apache.org> on 2006/05/17 09:09:22 UTC
Why two different matchers for project root and subdirectories?
I'm sorry if this a really silly question but I found no explanation
searching the archives and the net.
I keep stumbling across the the problem with WildcardURI-Matcher that
need to catch a resource in the project root directory or a subdirectory.
A pattern like
<map:match pattern="**/*">
seems to catch calls for all files in subdirectories, but will not apply
to files in the project root even though docs say that 'Matches zero
or more characters including the slash ('/') character'.
So to catch files on the project root it seems like you have to create
a second matcher like
<map:match pattern="*">
in a second pipeline.
Since I've seen the same technique used in Forrest pipelines I'm
begging to wonder if there isn't a better way of doing that with just
one matcher.
Any ideas?
--
Ferdinand Soethe
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Why two different matchers for project root and subdirectories?
Posted by Ferdinand Soethe <fe...@apache.org>.
Thorsten Scherler wrote:
> Remember what I said about the pattern "cocoon:/{1}/tab-{2}.html " that
> they cause problems? The above is one example for this.
OK, but what is exactly the problem and - if it is a bug - why is it
not being fixed rather then everybody creating ingenious work-arounds?
After all, it seems like a very common use-case.
> The solution
> might be to use the regexp matcher.
> Have a look at
> http://eris.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/themes.xmap?view=annotate
> at line 97 to see a basic usage example. There are some other plugin
> which contain some other examples.
I considered that. But then I thought I was throwing pretty big stones
at a pretty small problem.
> Happy regexp coding.
Will do while following up on this.
Thanks for the example.
--
Ferdinand Soethe
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Why two different matchers for project root and subdirectories?
Posted by Thorsten Scherler <th...@apache.org>.
Ferdinand Soethe schrieb:
>
>
>
>
>
>
>
> Andrew Stevens wrote:
>
>
>> How about just matching on "**" rather than "**/*"?
>>
>
> That might work in some cases, but sometimes I need the filename on
> its own, for example to do a <map:select
> type="resource-exists">-cascade through the given directory and all
> parents.
>
> Or when need to split path from filename for something like (Forrest)
>
> <map:match pattern="*.html">
> <map:aggregate element="site">
> <map:part src="cocoon:/skinconf.xml"/>
> <map:part src="cocoon:/build-info"/>
> <map:part src="cocoon:/tab-{0}"/>
> <map:part src="cocoon:/menu-{0}"/>
> <map:part src="cocoon:/body-{0}"/>
> </map:aggregate>
>
> and
>
> <map:match pattern="**/*.html">
> <map:aggregate element="site">
> <map:part src="cocoon:/skinconf.xml"/>
> <map:part src="cocoon:/build-info"/>
> <map:part src="cocoon:/{1}/tab-{2}.html"/>
> <map:part src="cocoon:/{1}/menu-{2}.html"/>
> <map:part src="cocoon:/{1}/body-{2}.html"/>
> </map:aggregate>
> <map:call resource="skinit">
> <map:parameter name="type" value="site2xhtml"/>
> <map:parameter name="path" value="{0}"/>
> </map:call>
> </map:match>
>
> --
> Ferdinand Soethe
>
Remember what I said about the pattern "cocoon:/{1}/tab-{2}.html " that
they cause problems? The above is one example for this. The solution
might be to use the regexp matcher.
Have a look at
http://eris.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/themes.xmap?view=annotate
at line 97 to see a basic usage example. There are some other plugin
which contain some other examples.
Happy regexp coding.
HTH
>
> ---------------------------------------------------------------------
> 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: Why two different matchers for project root and subdirectories?
Posted by Ferdinand Soethe <fe...@apache.org>.
Andrew Stevens wrote:
> How about just matching on "**" rather than "**/*"?
That might work in some cases, but sometimes I need the filename on
its own, for example to do a <map:select
type="resource-exists">-cascade through the given directory and all
parents.
Or when need to split path from filename for something like (Forrest)
<map:match pattern="*.html">
<map:aggregate element="site">
<map:part src="cocoon:/skinconf.xml"/>
<map:part src="cocoon:/build-info"/>
<map:part src="cocoon:/tab-{0}"/>
<map:part src="cocoon:/menu-{0}"/>
<map:part src="cocoon:/body-{0}"/>
</map:aggregate>
and
<map:match pattern="**/*.html">
<map:aggregate element="site">
<map:part src="cocoon:/skinconf.xml"/>
<map:part src="cocoon:/build-info"/>
<map:part src="cocoon:/{1}/tab-{2}.html"/>
<map:part src="cocoon:/{1}/menu-{2}.html"/>
<map:part src="cocoon:/{1}/body-{2}.html"/>
</map:aggregate>
<map:call resource="skinit">
<map:parameter name="type" value="site2xhtml"/>
<map:parameter name="path" value="{0}"/>
</map:call>
</map:match>
--
Ferdinand Soethe
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Why two different matchers for project root and subdirectories?
Posted by Andrew Stevens <at...@hotmail.com>.
>From: Ferdinand Soethe <fe...@apache.org>
>Date: Wed, 17 May 2006 09:09:22 +0200
>
>
>I'm sorry if this a really silly question but I found no explanation
>searching the archives and the net.
>
>I keep stumbling across the the problem with WildcardURI-Matcher that
>need to catch a resource in the project root directory or a subdirectory.
>
>A pattern like
>
> <map:match pattern="**/*">
>
>seems to catch calls for all files in subdirectories, but will not apply
>to files in the project root even though docs say that 'Matches zero
>or more characters including the slash ('/') character'.
The "**" may match zero or more characters, but the "/" in there will only
match a slash. Hence the final "*" must be a file in a subdirectory.
>So to catch files on the project root it seems like you have to create
>a second matcher like
>
> <map:match pattern="*">
>
>in a second pipeline.
>
>Since I've seen the same technique used in Forrest pipelines I'm
>begging to wonder if there isn't a better way of doing that with just
>one matcher.
How about just matching on "**" rather than "**/*"?
Andrew.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org