Christopher, Many thanks for a model answer,
The missing penny has dropped because of your comment "remember that a logicsheet is just an XSL stylesheet that gets applied to your XSP document to transform it into another XSP document." I had forgotten-cum-misunderstood! For your info C2 does things rather differently than C1, namely, instead of using cocoon processing instructions, you define "pipelines" in a sitemap.xmap file (an xml file that takes over a lot of what was cocoon.properties), which says how the xml file is generated (xsp, jsp, Tidied html, etc) then how it is transformed (generally xslt, but there are also transformers for log, sql, xinclude etc) then how it is serialized (html, xml, wap, svg2png, etc) That was for me the biggest change from the way C1 worked and it took a while to get the hang of, though "I sense it has more power" but the same thing can be achieved as you suggested from C1. Christopher -----Original Message----- From: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Sent: 29 November 2001 21:55 To: [EMAIL PROTECTED] Subject: Re: How do I use logicsheets parameters Christopher, first, may I suggest some general strategies for developing logicsheets? - start simple and extend by small increments, e.g., instead of trying to get this working by passing either an attribute or a child element, get it working one way, then get it working *seperately* the other way, then put them together. On another dimension, get it working first using a plain text element, then get it working with a Java variable. - remember that a logicsheet is just an XSL stylesheet that gets applied to your XSP document to transform it into another XSP document. You can take advantage of this for debugging by simply changing your processing instructions to pass your XSP through your logicsheet using the XSLT processor only, then viewing the output. (Some XML editors will also let you do this pretty easily.) This will give you insight into what the "final" XSP code looks like before conversion to Java. (This is easy to do in C1; I assume you can do it in C2.) - in addition to the above, write a plain XSP first, without using a logicsheet, that produces the expected output. In other words, write and debug an XSP that looks like the XSP you want after your logicsheet is applied. This will help you develop your logicsheet. Okay, so here's what I think you need to do what you are trying to do: <<<<< XSP - Calling page >>>>>>> <?xml version="1.0"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:mytags="http://dummy.org/mytags" > <xsp:logic> String bag="56891"; </xsp:logic> <page> <rasp> <xsp:attribute name="bagage"><xsp:expr>bag</xsp:expr></xsp:attribute> <foo> <mytags:get_my_param> <mytags:passed><xsp:expr>bag</xsp:expr></mytags:passed> </mytags:get_my_param> </foo> <goo> <!-- This just flat won't work, ever. The xsp:attribute doesn't do anything until *after* you run through the XSP processor and get converted to Java. You want this attribute to be transformed by your logicsheet, which happens *before* you are converted to Java. So don't do --> <!-- <mytags:get_my_param> <xsp:attribute name="passed">23</xsp:attribute> </mytags:get_my_param> --> <!-- Instead, try this: --> <mytags:get_my_param passed="bag"/> </goo> <hoo> <mytags:get_my_param passed="23"/> </hoo> </rasp> </page> </xsp:page> <<<<<< Logicsheet >>>>>>>>> <?xml version="1.0"?> <xsl:stylesheet xmlns:xsp="http://apache.org/xsp" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mytags="http://dummy.org/mytags" version="1.0"> <xsl:template match="mytags:get_my_param"> <myparam> <!-- Note - you need to use xsp:attribute rather than xsl:attribute here since the xsl is applied *before* Java generation, but the value of the contents isn't available until the Java is running. --> <xsp:attribute name="horse"> <xsp:expr><xsl:call-template name="value-for-passed"/></xsp:expr> </xsp:attribute> </myparam> </xsl:template> <xsl:template name="value-for-passed"> <xsl:choose> <xsl:when test="@passed"><xsl:value-of select="@passed"/></xsl:when> <xsl:when test="mytags:passed"> <xsl:call-template name="get-nested-content"> <xsl:with-param name="content" select="mytags:passed"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> <xsl:template name="get-nested-content"> <xsl:param name="content"/> <xsl:choose> <xsl:when test="$content/*"> <xsl:apply-templates select="$content/*"/> </xsl:when> <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template> </xsl:stylesheet> <<<<<< Results >>>>>> <page> <rasp bagage="56891"> <foo> <myparam horse="56891"></myparam> </foo> <goo> <myparam horse="56891"></myparam> </goo> <hoo> <myparam horse="23"></myparam> </hoo> </rasp> </page> Hope this helps. Note that I did this all in C1, which has some different processing instructions and namespaces and so forth to use logicsheets. I've tried to return everything to a form that looks like what you had originally, but be warned I may have missed something. -Christopher Please respond to [EMAIL PROTECTED] To: "Cocoon-Users \(E-mail\)" <[EMAIL PROTECTED]> cc: Subject: How do I use logicsheets parameters Could someone help me? I could benefit from a "logicsheet parameters 101" I want to use my own logicsheet and pass in runtime parameter(s) I have set up a logicsheet with the namespace mytags and a "function" get_my_param, to which I want to pass an xsp/java variable. In the following xsp I have three goes at passing a String variable called bag - with the value "56891" - but with no success. (The logicsheet is based on guesses from what I found in session.xsl, util.xsl etc.) .... the results, and the logicsheet follow the listing of the page Note that the <xsp:expr>bag</xsp:expr> gets 'resolved' in the calling page, but its value does not get passed into the logicsheet The <hoo> element shows that a literal value gets passed OK I guess it's to do with the order in which xsp: and mytags: are 'processed', but I don't know how to control this - any answers? <<<<<<<<<<<<<<<< XSP - 'Calling' page >>>>>>>>>>>>>>>> <?xml version="1.0"?> <xsp:page language="java" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:mytags="http://dummy.org/mytags" > <xsp:logic> String bag="56891"; </xsp:logic> <page> <rasp> <xsp:attribute name="bagage"><xsp:expr>bag</xsp:expr></xsp:attribute> <foo> <mytags:get_my_param> <mytags:passed><xsp:expr>bag</xsp:expr></mytags:passed> </mytags:get_my_param> </foo> <goo> <mytags:get_my_param> <xsp:attribute name="passed">23</xsp:attribute> </mytags:get_my_param> </goo> <hoo> <mytags:get_my_param passed="23"/> </hoo> </rasp> </page> </xsp:page> <<<<<<<<<<<<<<<< Results >>>>>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?> <page xmlns:xsp="http://apache.org/xsp" xmlns:xspdoc="http://apache.org/cocoon/XSPDoc/v1" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:mytags="http://dummy.org/mytags"> <rasp bagage="56891"> <foo> <myparam horse="bag"/> </foo> <goo> <myparam horse=""/> </goo> <hoo> <myparam horse="23"/> </hoo> </rasp> </page> <<<<<<<<<<<<<<<< Results try #2 >>>>>>>>>>>>>>>> If I chaneg the priority of the "copy over" template in the logicsheet (quoted below), thus: <xsl:template match="@*|*|text()|processing-instruction()" priority="1"> then I get ... <?xml version="1.0" encoding="UTF-8"?> <page xmlns:xsp="http://apache.org/xsp" xmlns:xspdoc="http://apache.org/cocoon/XSPDoc/v1" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:mytags="http://dummy.org/mytags"> <rasp bagage="56891"> <foo> <mytags:get_my_param> <mytags:passed>56891</mytags:passed> </mytags:get_my_param> </foo> <goo> <mytags:get_my_param passed="23"> </mytags:get_my_param> </goo> <hoo> <mytags:get_my_param passed="23"/> </hoo> </rasp> </page> ... which is quite different, but still not what I want !! <<<<<<<<<<<<<<<< Logicsheet >>>>>>>>>>>>>>>> <?xml version="1.0"?> <xsl:stylesheet xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mytags="http://dummy.org/mytags" version="1.0"> <xsl:template match="mytags:get_my_param"> <xsl:variable name="myparam"> <xsl:call-template name="value-for-passed"/> </xsl:variable> <myparam> <xsl:attribute name="horse"><xsl:value-of select="$myparam"/></xsl:attribute> <!-- <myotherparam> <xsl:attribute name="horse"> <xsl:value-of select="$myotherparam"/> </xsl:attribute> </myotherparam> --> </myparam> </xsl:template> <xsl:template name="value-for-passed"> <xsl:choose> <xsl:when test="@passed"><xsl:value-of select="@passed"/></xsl:when> <xsl:when test="mytags:passed"> <xsl:call-template name="get-nested-content"> <xsl:with-param name="content" select="mytags:passed"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> <xsl:template name="get-nested-content"> <xsl:param name="content"/> <xsl:choose> <xsl:when test="$content/*"> <xsl:apply-templates select="$content/*"/> </xsl:when> <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="@*|*|text()|processing-instruction()"> <xsl:copy> <xsl:apply-templates select="@*|*|text()|processing-instruction()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> --------------------------------------------------------------------- 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]> --------------------------------------------------------------------- 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]>