cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@dvs1.informatik.tu-darmstadt.de>
Subject [VOTE] directly setting variables in sitemap
Date Mon, 03 Dec 2001 10:03:47 GMT
Team, shall we have a vote on this?

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).

When using <map:resources/> to hold common parts of pipelines, it is
often desirable that they depend on some values determined further up
the pipeline. 

Often, an action or matcher already exists, that has the functionality
required, but additional parameters need to be set for the processing
in a resource. <map:parameter/> is used to do runtime configuration of
components. <map:redirect-to/> is no component but a control statement
and thus doesn't take runtime configuration.

Thus the only solution today is, to modify an existing component to
set additional parameters, or to write a custom action that just sets
some parameters.

<map:redirect-to resource=""/> does have @target which 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>

Please voice your opinion on introducing a <map:variables/> construct
as described above.

Obviously, I'm +1

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message