Team,
please have a look at this from cocoon-users.
Chris.
--- Begin Message ---
On 27.Nov.2001 -- 03:41 PM, Alexander Smirnoff wrote:
> Thanks Cris,
>
> Again you saved me, man. Thanks.
You're welcome :-)
> Approach with <map:parameter name="target" value="welcome"/> generates code
> in wrong place, which cause compilation error of sitemap. So I guess it
> could be treated as a BUG.
I tend to disagree here. There's no language element that allows
setting of sitemap parameters er, variables. They are usually the
result of sitemap components execution. More in particular, from those
components that are used to determine the actual pipeline from the
given fragments (matchers, actions; selectors return only true /
false).
<map:parameter/> is used to do runtime configuration of those
components. <map:redirect-to/> is no component but a control
statement and thus doesn't take runtime configuration.
I agree, though, that @target is probably not as clean as possible. A
better solution would be, to introduce some construct to set those
variables without the need of an action, like
<map:variables>
<map:parameter name="foo" value="xyz"/>
<map:parameter name="bar" value="uvw"/>
</map:variables>
that is translated by the following in sitemap.xsl (not tested!):
<xsl:template match="map:variables">
Map map = new HashMap(<xsl:value-of select="count(map:parameter)"/>);
<!-- actually, here we could as well use for-each since only
map:parameter would be allowed here. OTOH a common advice is
not to use for-each for performance reasons. See below for
alternative solution.
-->
<xsl:apply-templates/>
listOfMaps.add(map);
this.dumpParameters();
</xsl:template>
<xsl:template match="map:variables/map:parameter" priority="2">
map.put("<xsl:value-of select="@name"/>", substitute(listOfMaps, "<xsl:value-of
select="@value"/>"));
</xsl:template>
Or
<xsl:template match="map:variables">
Map map = new HashMap(<xsl:value-of select="count(map:parameter)"/>);
<xsl:for-each select="map:parameter">
map.put("<xsl:value-of select="@name"/>", substitute(listOfMaps, "<xsl:value-of
select="@value"/>"));
</xsl:for-each>
listOfMaps.add(map);
this.dumpParameters();
</xsl:template>
Team, shall we have a vote on this?
Chris.
--
C h r i s t i a n H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>
--- End Message ---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]