Tim Williams wrote:
On 6/7/05, Ross Gardler <[EMAIL PROTECTED]> wrote:

Tim Williams wrote:

On 6/6/05, Ross Gardler <[EMAIL PROTECTED]> wrote:


Tim Williams wrote:


On 6/6/05, Ross Gardler <[EMAIL PROTECTED]> wrote:



Tim Williams wrote:

...



<map:select type="exists">
   <map:when test="{project:content.xdocs}tabs.xml">
        <map:generate src="{project:content.xdocs}tabs.xml"/>
   </map:when>
   <map:when test="{lm:tabs.xml}">
        <map:generate src="{lm:tabs.xml}"/>
    </map:when>
</map:select>

This is interesting. Have you tested what happens when {lm:tabs.xml}
does not point to anything useful? That is, does the second <map:when> work?


:( Sadly, no.  It looks like {lm:tabs.xml} always evaluates to
existing.  Are locationmaps not usable in an exists selector for some
reason?


My guess is (there's another disclaimer, I haven't tested this yet)...

Since you are mapping the {lm:tabs.xml} to a http request a document is
always returned. It may be a 404 error, but it is still a document. To
confirm this we would need to look at the generator code and, if
necessary detect error conditions from the various repository types.


The problem or at least a symptom appears to be with the resolver
inside the select method of SourceExistsSelector.  Here's my
rationale:

o) LocationMapModule appears to properly be responding with null if a
particular hint is not found.

This is different from what I intended to ask above. I meant if the hint *does* resolve to something sensible in the locationmap (e.g. http://slide.domain.org:8080/page.xml) what happens.

What you appear to have tested is what happens if the locationmap does not have a match for the resource.

o) The empty string comes into SourceExistsSelector and for some weird
reason the resolver resolves it to
"file:/C:/src/apache-forrest-7-branch/main/webapp/" (for me, but you
get the idea).

This is not weird if one knows the internals of Cocoon. This location is the context root for your installation of Cocoon. This is were everything is relative to. So, since we have a null from the locaitonmap module we are looking in the root.

o) Obviously calling src.exists() on the above location returns true
causing the map:when to always evaluate to true even when no hint is
found in the locationmap.

This is an interesting point...

I've got a temporary hack in place by testing for an empty uri
parameter immediately before it even gets to the resolver.  This gets
me the behaviour I would expect in an exists selector test

Does it get the behaviour you expect. Have you tried having a valid match in the locationmap but not having the resource present at indicated location?

but I'm
thinking it'd be best if someone who knows exactly how the
resolver/SourceExistsSelector works took a look at it.  In the mean
time, I could use my little hack to keep moving.

I would have thought we can just check for a null in the SourceExistsSelector. However, this is a Cocoon component not a Forrest one so we need to take this to Cocoon. I don't have the time to follow it through just yet, maybe next week.

Could you provide a patch to the locationmap branch for the stuff that you have done so that we can both see the same code.

Make sense?

It certainly does, thanks.

Ross

Reply via email to