You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by AxKit Wiki <axkitwiki> on 2004/04/27 06:39:45 UTC

New Wiki Content at Taglibs

Wiki content at Taglibs Changed by someone at IP 210.190.112.253 :

@@ -2,10 +2,46 @@
 
 =head2 Introduction
 
-Tag libraries are ways to hide code behind XML tags. They are how you prevent your L<XSP> pages from becoming a morass of perl code interspersed with a bit of XML for the output (which is what you see with many L<PHP> or L<ASP> pages). Tag libraries range from the very simple (e.g., the L</Param> taglib) to the complex (e.g., the L</PerForm> taglib) to completely application specific tag libraries (such as the Wiki taglib that runs this Wiki).
+Tag libraries are ways to hide code behind XML tags. They are how you prevent your L<XSP> pages from becoming a morass of perl code interspersed with a bit of XML for the output (which is what you see with many L<PHP> or L<ASP> pages). Tag libraries range from the very simple (e.g. the L</Param> taglib) to the complex (e.g. the L</PerForm> taglib) to completely application specific tag libraries (such as the Wiki taglib that runs this Wiki).
 
 =head2 How a taglib works
 
-When an XSP page is compiled it uses a SAX processor to turn that page into perl code. In order to change how the SAX processor works you can register a taglib module with AxKit, then when the XSP compiler sees the namespace belonging to your taglib module it switches control to your module, so your taglib can insert its own custom code into the output.
+When an XSP page is compiled AxKit uses a SAX processor to turn that page into perl code (the perl code in turn generates the XML output at runtime). By creating a taglib you change how the SAX processor works - when it sees tags in your namespace it switches control to your module, so your taglib can insert its own custom code into the output.
 
-This may sound complex and writing perl code this way can prove difficult, but there are a few ways to simplify L<programming taglibs|Writing Taglibs> that make it as simple as writing a perl module.+This may sound complex but and writing perl code this way can prove difficult, but there are a few ways to simplify L<programming taglibs|Writing Taglibs> that make it as simple as writing a perl module.
+
+=head2 Custom or CPAN taglib?
+
+There are many taglibs on CPAN already for things like session management, form processing, and cookie access, but there is nothing mandating that you shouldn't write your own. Generally when people ask if they should write their own or not the answer is one of how they like to work. The taglibs on CPAN tend to be highly generic - low level operations like accessing cookies or sessions or even doing forms. However you may wish to hide all of that operation behind a few custom tags that look something like:
+
+  <fengu:initialize/>
+  <fengu:display page="display"/>
+
+All of this is possible with taglibs.
+
+=head2 Loading taglibs
+
+Before you use a taglib you have to tell AxKit about it by loading it. Doing this is very simple:
+
+  AxAddTaglib AxKit::XSP::Param
+
+This loads the module C<AxKit::XSP::Param> and runs the XSP C<register()> class method on it. From then on you can access the taglib via its namespace (which is specified in the C<$AxKit::XSP::Param::NS> variable):
+
+  <param:action xmlns:param="http://axkit.org/NS/xsp/param/v1"/>
+
+=head1 CPAN Taglibs
+
+The following taglibs are available on CPAN:
+
+=head1 Param
+
+The param taglib is a simple way to access querystring or form parameters in your XSP page. Usage is very simple, just use the namespace prefix followed by the name of the single-valued parameter you wish to access:
+
+  <!-- get the "foo" parameter -->
+  <param:foo/>
+
+Note though that this is restricted to single valued parameters - there is no facility to access parameters with multiple values. Also note that the parameter name is restricted to valid XML LocalNames.
+
+=head1 PerForm
+
+The perform taglib is one of the more complex taglibs on CPAN. It is designed to be a complete solution for creating and processing forms - hence the reason its so complex.