On Tue, 25 Jun 2002, Philip Mak wrote:
> <page><%
> my $name = $Request->Params('name');
> if ($name) {
> %>Your name is: <%=$name%><%
> } else {
> %><form>
> Enter your name: <input type="text" name="name" />
> <input type="submit" />
> </form><%
> }
> %></page>
>
> I find the latter example to be much more readable and faster to code.
>
> Am I missing the point here?
Some of it, yes. There are several advantages to XSP that you may be
missing.
1. It's very easy in that ASP page to create a closure by accident. Say
you have:
<%
sub foo {
if ($Request->Params('name')) {
# blah blah
}
}
%>
You have created a closure.
With XSP, there is a special section of the page devoted to "compile-once"
functions that ensure you never get a closure created (and enforce
variable passing).
2. The resulting XML you create doesn't have to be HTML (in fact it
probably shouldn't be) - you're supposed to pass it on to a stylesheet
processor (XSLT or XPathScript) for turning it into HTML (or some other
format). All of this stuff is built in to AxKit. In fact you can even turn
the whole thing into PDF.
3. Sometimes the tags aren't needed. In the above example you could omit
some and XSP figures out the right thing to do, for example you could
change it to:
<page xmlns:xsp="http://apache.org/xsp/core/v1"
xmlns:param="http://axkit.org/NS/xsp/param/v1"
>
<xsp:logic>
if (<param:name/>) {
<para>Your name is: <param:name/></para>
}
else {
<form>
Enter your name: <input type="text" name="name" />
<input type="submit"/>
</form>
}
</xsp:logic>
</page>
Which is quite a bit less typing.
4. You may also want to check out the document I wrote on the design of
the wiki, at http://axkit.org/wiki/view/AxKit/WikiDesign which may help
you see some of the benefits.
5. Reducing typing isn't everything ;-)
> I read that one of the significant advantages of AxKit is total
> separation of web design and code. However, on the websites that I
> work on, I do both the web design and the code.
Even so, what happens when you need to redesign the whole site? Sure you
can split things up into headers and footers to make sure it's not quite
so difficult, but ultimately the "sandwich" technique is very limited, and
assumes your page can actually be sandwiched (often it can't and you end
up with hacks). The XSLT/XPathScript way of working with declarative
processing is the result of people seeing problems with that way of
working and fixing it (or at least attempting to - YMMV).
--
<!-- Matt -->
<:->Get a smart net</:->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]