cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: Flow
Date Thu, 02 Dec 2004 20:40:26 GMT
   Date: 2004-12-02T12:40:25
   Editor: HelmaVanDerLinden <h.vanderlinden@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''
+

Mime
View raw message