On Apr 17, 2004, at 2:56 PM, leon tian wrote:

hi, thanks a lot for ur help! it works! i went through the faq and wish i could make things easy by making the same default namespace in stylesheet:
 
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
 
but it doesn't work...

Right, you can only have one default namespace! :-)

 
i have another question. in order to get a webpage and transform it dynamically, i need a form for user to fill in the url and pass it to my server. after went through the documentation, i found out it's so difficult to make even a simple form in cocoon. may i use a html form instead and how to handle the parameters in sitemap?

It's not difficult! Just a little learning curve, that's all. I would say that for a very simple form where you don't have to do any validation, and where you don't need "sticky" fields or to preload the values of any of the fields... then it's probably a toss-up. But once you add any of these aspects, the advantage goes to Woody/CForms.

For your scenario, if you want to go with just a straight HTML form, there are a lot of ways you could do it. The most straightforward would probably be something like this:

<map:match pattern="getPage">
<map:generate type="html" src="{request-param:uri}" />
<map:transform.... />
<map:serialize type="html" />
</map:match>

(This shows a standard way of extracting request parameters in the sitemap, using an InputModule — see http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html for more info).

So then — just write your <form action="getPage"> with an <input name="uri">, and you're off to the races!

But we can improve upon this... so far, we have a single resource, "getPage", that displays some transformed page depending on the value of a form parameter. That kind of sucks, doesn't it? What if I want to bookmark that page, or email the link to somebody... I can't really do that, can I? The answer is to do something like this:

<map:match pattern="getPage>
<map:redirect-to uri="showPage/{request-param:uri}" />
</map:match>

<map:match pattern="showPage/*">
<map:generate type="html" src="{1}" />
<map:transform... />
<map:serialize type="html" />
</map:match>

HTH,
mark

Reply via email to