well, actually one of the best ways to do this is to do the following...

<xi:include href="querymydb.xsp"/>

And you just create an XSP page with your ESQL (or whatever logic) in it. Now 
querymydb.xsp is a nice module which is compiled and its output will even be 
cached in cases where that makes sense to AxKit. The only real limitation is 
you can't pass dynamic parameters to the module (IE, you can have a query 
string but its value has to be constant because XInclude processing happens 
before anything else). 

Another approach is to use the XSLT document() function. So for instance you 
can merge in content from other modules in XSLT with something like

<xsl:copy-of select="document(querymydb.xsp)"/>

This has the advantage of letting you generate a query string dynamically. The 
down side of course is you loose the chance to do more XSP processing on the 
results.

Also check out the 'axkit:' URL scheme. This allows you to make local 
subrequests (so a URL like 'axkit:/foo.xsp' in a document() call will be 
handled as an internal Apache subrequest, which is much more efficient than a 
normal call to a URL which has to go through the HTTP protocol). There are 
some cases where you will find axkit URLs don't do what you want, but in 
general they work real good! :o).

As for including one taglib in another, there are a few possible approaches to 
that. Taglibs are generally built as a set of functions. Depending on how the 
author factored up his code you may be able to get at the core functionality 
via making calls to internal functions in the taglib itself. With 
TaglibHelper based taglibs this is usually pretty straightforward. Personally 
I design my taglibs to be nothing but thin wrappers over generalized APIs 
which are placed in seperate modules, that way you can access functionality 
either directly in XSP logic when necessary or build various taglibs that 
call the same functionality in different ways.

Another way to access some functionality is simply to use tags like functions. 
Some tags return strings, or they will return strings if called from perl or 
in the context of <xsp:expr>. In that case you may be able to simply call a 
tag and have it return a value that is an argument to your own tag, like the 
way the various "param" taglibs work. 

Taglib authors should make an effort to factor functionality into modules 
seperate from the taglib itself. Unfortunately a lot of them don't, which is 
the real root cause of this sort of awkwardness (yes, this paragraph is aimed 
at taglib authors!).

On Wednesday 23 July 2003 08:04 am, Adam Griffiths wrote:
> Hi,
>
> Joerg, thanks for your comments, I eagerly await AxKit 2.0, until then I
> guess I'll use a taglib to combine the functional components, as you
> suggest.
>
> In order to do this, could anyone tell me best way to make a taglib that
> uses tags from another taglib?
>
> For example, to get something like:
>
>   <mylib:query-my-db>
>      <!-- esql stuff here -->
>   </mylib:query-my-db>
>
> to expand to:
>
>   <esql:connection>
>     <esql:driver>Pg</esql:driver>
>     <esql:dburl>dbname=axkit</esql:dburl>
>     <esql:username>postgres</esql:username>
>     <esql:password>password</esql:password>
>     <esql:execute-query>
>        <!-- esql stuff here -->
>     </esql:execute-query>
>   </esql:connection>
>
> Regards
>
> Adam
> ________________________________________________________
> s_p_a_m_t_r_a_p       from:[EMAIL PROTECTED]
> Do not email the above address or remove these two lines
>
> -----Original Message-----
> From: J�rg Walter [mailto:[EMAIL PROTECTED]
> Sent: 23 July 2003 11:44
> To: [EMAIL PROTECTED]
> Subject: Re: Building applications with AxKit and XSP, in a reusable
> extensible way...
>
> Am Wednesday, 23. July 2003 12:23, schrieb Adam Griffiths:
> > Hi,
> >
> > I've been using AxKit for a while now and I'd really appreciate any
> > ideas or information on the following question.
> >
> > XSP is great for generating dynamic XML documents and it's fast too.
> > It also caches the Perl code necessary to generate the dynamic XML
> > page so multiple requests only require it is parsed once. However as
> > my application grows and has an increasing number of XSP pages I am
> > finding that many share identical code / xsp-xml fragments, which
> > makes maintaining them all is becoming increasingly difficult.
>
> Use taglibs or XInclude. If you find yourself reusing similar functional
> components, make a taglib of them. If you find yourself reusing data
> components, or lots of data with a little bit of logic, use XInclude. If
> you
>
> find yourself reusing a lot of data, try rearranging things so you do XSLT
> _after_ XSP. Of course, this combination does not work with logic inside
> your
> data.
>
> I use XSLT->XSP->... a lot, but as you already recognized, it's darn slow.
>
> For the caching behaviour you suggest you will have to wait for AxKit 2.0.
> It
> will most probably have that flexibility.

-- 
Tod Harter
Giant Electronic Brain
http://www.giantelectronicbrain.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to