You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Michael Wechner <mi...@wyona.com> on 2004/01/08 14:01:06 UTC

resource-exists selector: test path relative to sitemap

I would like to propose to change the default behaviour of the
resource-exists selector re testing the path relative to the sitemap 
from it's being called.

Let me give an example:
Let's say we have a sitemap and from there another sub-sitemap mounted 
within some directory,

context (e.g. cocoon)
  |
  +-- sitemap.xmap
  |
  +-- foo
       |
       +-- sub-sitemap.xmap
       |
       +-- bar
            |
            +-- file1.xml
            |
            +-- file2.xml


Currently to test files from within the *sub-sitemap* requires the 
following sitemap snippet


<map:select type="resource-exists">
   <map:when test="foo/bar/file1.xml">

but wouldn't it make more sense to have

<map:select type="resource-exists">
   <map:when test="bar/file1.xml">

which means the path is relative to the actual sitemap?
Or am I overlooking something?

WDYT?


Michi



-- 
Michael Wechner
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com              http://cocoon.apache.org/lenya/
michael.wechner@wyona.com                        michi@apache.org


Re: resource-exists selector: test path relative to sitemap

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Nicola Ken Barozzi wrote:

> Michael Wechner wrote:
>
>> I would like to propose to change the default behaviour of the
>> resource-exists selector re testing the path relative to the sitemap 
>> from it's being called.
>
...

>
> Sub-sitemaps can be anywhere and not necessarily work with a sub-dir 
> scenario in mind. Forrest is a good example of this, as we use several 
> subsitemaps, all in the same dir.
>
> What IMHO would make more sense, instead, is something like:
>
>  <map:select type="resource-exists" base="foo/">
>    <map:when test="bar/file1.xml">
>    ....


Done. ResourceExistsSelector.java:

 * <p>
 * A parameter 'prefix',
 * <pre>
 *   &lt;map:parameter src="prefix" value="<code>some/path</code>"/&lt;
 * </pre>
 * may be supplied to the selector instance.  This prefix is prepended 
to all
 * test expressions before evaluation.  The default prefix is '' (empty 
string),
 * meaning that all expressions are relative to the current sitemap, unless
 * explicitly overridden.


Vadim




Re: resource-exists selector: test path relative to sitemap

Posted by Michael Wechner <mi...@wyona.com>.
Nicola Ken Barozzi wrote:

>>
>> <map:select type="resource-exists">
>>   <map:when test="bar/file1.xml">
>>
>> which means the path is relative to the actual sitemap?
>> Or am I overlooking something?
> 
> 
> Sub-sitemaps can be anywhere

you mean referenced by absolute paths?

  and not necessarily work with a sub-dir
> scenario in mind. Forrest is a good example of this, as we use several 
> subsitemaps, all in the same dir.

i need to check that

> 
> What IMHO would make more sense, instead, is something like:
> 
>  <map:select type="resource-exists" base="foo/">
>    <map:when test="bar/file1.xml">

and "base" as optional attribute?


>    ....
> 


-- 
Michael Wechner
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com              http://cocoon.apache.org/lenya/
michael.wechner@wyona.com                        michi@apache.org


Re: resource-exists selector: test path relative to sitemap

Posted by Nicola Ken Barozzi <ni...@apache.org>.
Michael Wechner wrote:

> I would like to propose to change the default behaviour of the
> resource-exists selector re testing the path relative to the sitemap 
> from it's being called.
> 
> Let me give an example:
> Let's say we have a sitemap and from there another sub-sitemap mounted 
> within some directory,
> 
> context (e.g. cocoon)
>  |
>  +-- sitemap.xmap
>  |
>  +-- foo
>       |
>       +-- sub-sitemap.xmap
>       |
>       +-- bar
>            |
>            +-- file1.xml
>            |
>            +-- file2.xml
> 
> 
> Currently to test files from within the *sub-sitemap* requires the 
> following sitemap snippet
> 
> <map:select type="resource-exists">
>   <map:when test="foo/bar/file1.xml">
> 
> but wouldn't it make more sense to have
> 
> <map:select type="resource-exists">
>   <map:when test="bar/file1.xml">
> 
> which means the path is relative to the actual sitemap?
> Or am I overlooking something?

Sub-sitemaps can be anywhere and not necessarily work with a sub-dir 
scenario in mind. Forrest is a good example of this, as we use several 
subsitemaps, all in the same dir.

What IMHO would make more sense, instead, is something like:

  <map:select type="resource-exists" base="foo/">
    <map:when test="bar/file1.xml">
    ....

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


Re: resource-exists selector: test path relative to sitemap

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Michael Wechner wrote:

> I would like to propose to change the default behaviour of the
> resource-exists selector re testing the path relative to the sitemap 
> from it's being called.


Done! Long time ago. status.xml:

   <action dev="VG" type="update">
     ResourceExistsSelector now works the same way as 
ResourceExistsAction does.
     It can now detect existence of any Cocoon resource, not only files
in context.
     Default value for prefix was changed from '/' to ''. For old
behavior, use prefix
     'context://'.
   </action>


ResourceExistsSelector.java:

* <p><b>NOTE:</b>
* Provided resource URI is resolved as Source, relative to the current
* sitemap, which differs from behavior of selector in previous versions.
* To resolve resource paths relative to the context root, provide prefix
* parameter:
* <pre>
*   &lt;map:parameter name="prefix" value="context://"/&lt;
* </pre>


Vadim