shannon 2002/07/10 11:49:22 Modified: src/documentation/xdocs/faq faq-generators.xml Log: Added new faq about dynamic sources for generators thanks to Chris Haul's post on cocoon-users. Revision Changes Path 1.2 +50 -0 xml-cocoon2/src/documentation/xdocs/faq/faq-generators.xml Index: faq-generators.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/faq/faq-generators.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- faq-generators.xml 30 May 2002 17:33:07 -0000 1.1 +++ faq-generators.xml 10 Jul 2002 18:49:21 -0000 1.2 @@ -31,10 +31,60 @@ </answer> </faq> +<faq> + <question> + How can I dynamically specify the source for my generator? + </question> + <answer> + <p>For example, I want the <generate>'s src attribute to be defined based on a request. + </p> + <p> +Here are two solutions (depending on your version of Cocoon): + </p> + <p> +(1) RequestParamAction (2.0.x + 2.1) + </p> +<source><![CDATA[ + <map:match pattern="tba/*"> + <map:act type="request"> + <map:parameter name="parameters" value="true"/> + <map:generate src="{page}"/> + <map:transform src="docs/samples/tba/redirect.xsl"/> + <map:serialize type="html"/> + </map:act> + <!-- else ? --> + </map:match> +]]></source> + <p> +Adding <map:act type="request"> and +<map:parameter name="parameters" value="true"/> makes it +possible to get the page request attribute. +Then, you can define the src attribute by using the value of the page attribute +like this: <map:generate src="{page}"/>. + </p> + + <p> +(2) InputModules (2.1) + </p> + +<source><![CDATA[ + <map:match pattern="tba/*"> + <map:generate src="{request:page}"/> + <map:transform src="docs/samples/tba/redirect.xsl"/> + <map:serialize type="html"/> + </map:match> +]]></source> + + <p> +In addition, you may want to use ResourceExistsAction to check whether +the provided page exists. + </p> +</answer> +</faq> </faqs>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]