hi,
your example is not going to work at all, ..., i suggest you to take a
look at java source code generated from xsp page, this code is located
somewhere in tomcat/work/localhost*/cocoon/org/apache/www/...your_xsp.java,
you'll find there that element <person-colour> and Java variable person are
cmpletely unrelated, you might try in xsp something like
<xsp:element name="person-colour">
<xsp:attribute name="person"><xsp-request:get-parameter
name="person"/></xsp:attribute>
</xsp:element>
this way the XML output generated by XSP page will contain somewhere the
element
<person-colour person="Peter"/> // or whatever your request parameter was
then you can match in your XSL the element person-colour and use its attribute
@person to take a value from external xml file, ...
cheers,
martin
On Thu, Oct 25, 2001 at 09:57:26AM +1000, Phil Blake wrote:
> I am missing something when it comes to getting and passing request
> arguments. I've looked at the cocoon examples, and although my test
> example appears to match the cocoon one in every way there is obviously
> something fundamental missing.
>
> I think I'm pretty close. :) If anyone could help me get past this
> misunderstanding it would be much appreciated.
>
> My example scenario allows the user to enter a URL like the following:
> http://hostname/example/colour.html?person=Phil%20Blake
> The result would be a HTML page with the person's favorite colour.
>
> In the sitemap I added a generic matcher that matches anything .html and
> returns the corresponding xsp. I figured (as opposed to read anywhere in
> documentation) that I needed to include the use-request-parameters and
> use-browser-capabilities-db parameters - I don't know why I want them,
> just that they appeared in the cocoon sitemap.
> <!-- Match *.html and map to *.xsp -->
> <map:match pattern="**.html">
> <map:generate type="serverpages" src="{1}.xsp"/>
> <map:transform src="Example.xsl">
> <map:parameter
> name="use-request-parameters" value="true"/>
> <map:parameter
> name="use-browser-capabilities-db" value="true"/>
> </map:transform>
> <map:serialize/>
> </map:match>
>
> The requested xsp page looks like this. (colour.xsp)
> <xsp:page
> language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:xsp-response="http://apache.org/xsp/response/2.0">
> <xsp:logic>
> String person = null;
> </xsp:logic>
> <html>
> <title>The favorite colour page - Yay"</title>
> <xsp:logic>
> person = <xsp-request:get-parameter name="person"/>;
> </xsp:logic>
> <xsp:expr>person</xsp:expr> has a favorite colour! It is
> <person-colour/>
> </html>
> </xsp:page>
>
> I then have a half/broken stylesheet that is supposed to select the
> person named in the URL person path arg. Then return their favorite
> colour. However, as you'll notice, I can't see how to get from the first
> line, to the second one. I assume the variable selectedPerson contains a
> person node. (I don't know 'cause I can't make it work).
> However, I have no idea how to use that variable to retrieve the colour.
> XSL Stylesheet:
> <xsl:template match="person-colour">
> <!-- Select the person, somehow -->
> <xsl:variable name="selectedPerson"
> select="document('people.xml',.)/people/person[name='$person']"/>
> <!-- return their favorite colour, somehow -->
> <xsl:value-of select="$selectedPerson/favoriteColour">
> </xsl:template>
>
>
>
> XML External Content (people.xml)
> <people>
> <person>
> <name>Phil</name>
> <favoriteColour>blue</favoriteColour>
> </person>
> <person>
> <name>Arthur</name>
> <favoriteColour>yellow</favoriteColour>
> </person>
> </people>
>
>
> Thanks for your help. Have fun,
>
> Phil
>
>
> ---------------------------------------------------------------------
> 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]>
>
>
--
2CC0 4AF6 92DA 5CBF 5F09 7BCB 6202 7024 6E06 0223
http://mman.dyndns.org/mman.gpg
---------------------------------------------------------------------
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]>