Sun Sep 19 21:17:37 2004
XSPIntroductionXSP stands for eXtensible Server Pages (not XML Server Pages, although that might apply equally well). This means that XSP is a server pages technology a similar idea to ASP or PHP or JSP - a file on your web server that executes some code to produce results. XSP is however better than those other solutions because the output of an XSP page is structured XML, meaning you can then pipe it through XSLT (or any of the other AxKit language modules) to produce HTML or any other kind of output format depending on the client making the request. So you get all the structured data benefits, and the separation of content from presentation that XML and AxKit bring you, while still having easy to write dynamic code. In diagramatic terms the pipeline might look like this: Request --> [XSP] -- (XML) --> [XSLT] -- (HTML) --> Browser [] - Engine component () - Output format The above is the most common pipeline pattern when using XSP, however you are free to choose your own pipeline pattern as you see fit. So what does an XSP page look like?Again, let's start off simply. First here's how we might configure AxKit to deliver XSP pages as above: AxAddRootProcessor application/x-xsp NULL \
{http://apache.org/xsp/core/v1}page
AxAddRootProcessor text/xsl output2html.xsl \
{http://apache.org/xsp/core/v1}page
Now here's <xsp:page xmlns:xsp="http://apache.org/xsp/core/v1">
<output>
Hello World. The time of request is:
<xsp:expr>scalar localtime</xsp:expr>
</output>
</xsp:page>
And the output from that would be something like: <output> Hello World. The time of request is: Wed Feb 5 10:46:11 2003 </output> Finally we could design our Now we can break the page down into components:
Taglibs to Make Life EasierAnyone familiar with Server Pages technologies knows that it very quickly becomes unmanagable to embed code in your pages. You end up with a bigger mess than just coding in plain CGI scripts very easily. In order to combat this problem XSP allows you to very easily create what are called Tag Libraries. These are basically libraries of tags that do useful things. For example the AxKit Wiki Please see the separate page for more details. Namespaces EverywhereAnother important thing about XSP is its use of XML Namespaces An XML namespace is very simple - it is simply a URI, though the URI does not have to map to anything important - it doesn't even need to really exist (a simple way to work if this confuses you is to make your namespace URIs URNs, which is a private definition that looks something like "urn:mytaglibnamespace"). Finally if you don't like all the extra work that this involves (mapping namespaces to modules, loading modules and getting everything right in your XSP page) you can specify the namespace as a module by setting the config variable: PerlSetVar XSPResNamespaces 1 And in your XSP page you can now use: <xsp:page xmlns:wiki="res:perl/AxKit/XSP/Wiki"> Which will use the taglib defined in the module Where to now?From here check out how to use taglibs, or see how to write your own taglib, and finally there's the full blown XSP Guide which documents the core of XSP in much more detail. Edit This Page / Show Page History / |

Home
is basically a tag library held together with an XSP page for glue.