You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/12/02 21:40:26 UTC

[Cocoon Wiki] Updated: Flow

   Date: 2004-12-02T12:40:25
   Editor: HelmaVanDerLinden <h....@mi.unimaas.nl>
   Wiki: Cocoon Wiki
   Page: Flow
   URL: http://wiki.apache.org/cocoon/Flow

   adding information on how to pass flowparameters to the sitemap

Change Log:

------------------------------------------------------------------------------
@@ -103,3 +103,53 @@
   *See also: {{{logkit.xconf}}}
 
 ''The info regarding how the flow functions were named (using {{{js*}}}) in Rhino has been retired. Check the Wiki diffs if you still need this info, but you probably won't.  -- TonyCollen''
+
+== Q: How do I pass flowscript parameters to the sitemap? ==
+== A: Accessing flowscript parameters in the sitemap: ==
+
+You create an object of class PipelineUtil and pass the parameters to this object along with the match pattern of the pipeline.
+
+In the pipeline you access the parameter using <map:parameter name="flowparameter" value="{flow-attribute:urn}"/>
+
+Here is an example:
+
+----flowscript---------------------------------------------------------------------
+{{{
+function enricheXML(urnforthexml){
+   var enrichedXML = java.io.ByteArrayOutputStream();
+   var pipeutil = cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.PipelineUtil);
+   pipeutil.processToStream("enricheXML", {"urn":urnforthexml}, enrichedXML);
+   return enrichedXML.toString();
+}
+}}}
+----sitemap----------------------------------------------------------------------
+{{{
+<!-- ==Pattern for the XMLenrichement ====================================== -->
+   <map:match pattern="enricheXML">
+      <map:generate src="{request-param:uploadfile}" />
+      <map:transform src="xsl/enrichement.xsl" >
+         <map:parameter name="url" value="{request-param:uploadurl}" />
+         <map:parameter name="urn" value="{flow-attribute:urn}" />
+      </map:transform>
+      <map:serialize type="xml" />
+   </map:match>
+}}}
+----stylesheet------------------------------------------------------------------
+{{{
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+   <xsl:output method="xml"/>
+   <xsl:param name="urn" />
+   <xsl:param name="url" />
+
+   <xsl:template match="/">
+      <enriched>
+         <URL><xsl:value-of select="$url"/></URL>
+         <URN><xsl:value-of select="$urn"/></URN>
+         <xsl:copy-of select="/"/>
+      </enriched>
+   </xsl:template>
+</xsl:stylesheet>
+}}}
+
+''Thanks to Jan Hinzmann''
+