cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Björn Lütkemeier <>
Subject Bug with context and subsitemaps
Date Mon, 14 Apr 2003 07:34:32 GMT

we noticed a bug that occurs when working with nested subsitemaps. Lets have
a look at the following sitemap (I know its an abstract example, but I think
it is therefore easy to understand ;-)):

	<map:mount src="sub/sitemap.xmap" uri-prefix="sub"/> <!-- mount1 -->

	<map:mount src="sub/sitemap.xmap" uri-prefix="sub"/> <!-- mount2 -->
	<map:match pattern="**">
		<map:generate src="any.xml"/>

	<map:match pattern="blah2">

Now when you call http://.../cocoon/sub/sub/blah1 Cocoon will step down to
the sub/sub/sitemap, but find no match in it. Therefore it continues after
mount2 and executes pipeline **. Now the generator throws an exception
because file any.xml cannot be found. Why that?
The problem can be found within the code of class AbstractEnvironment:

public void setContext(String prefix, String uri) {
	this.setContext(getRootContext()); /* WRONG!!! */

This method is called within class MountNode in the following way:

String oldPrefix = env.getURIPrefix();
String oldURI    = env.getURI();
try {
	env.changeContext(resolvedPrefix, resolvedSource);
	... // process subsitemap
} finally {
	// Restore context
	env.setContext(oldPrefix, oldURI);

It is of cause wrong, because setContext() must not set the context to the
root context, which corresponds to the root sitemap, but to the one, that
has been active before changeContext(..). Therefore file any.xml will be
searched in the root directory, so its now clear why it cannot be found.

We propose to add a method setContext(String prefix, String uri, URL
context) to interface Environment and perhaps to deprecate the old/wrong
one, so MountNode can reset the context correctly.

Any comments / other ideas to fix the bug?


Klingender Str. 5
D-33100 Paderborn
phone:    05251 / 1581-35

View raw message