Re: [xslt] extending xslt to provide something like a macro
- From: Thijs van der Vossen <t vandervossen fngtps com>
- To: xslt gnome org
- Subject: Re: [xslt] extending xslt to provide something like a macro
- Date: Tue, 2 Dec 2003 16:47:49 +0100
On Tuesday 02 December 2003 15:50, Phil Frost wrote:
> I've been playing with xslt for the past few days as a possible method by
> which I can maintain a maximal separation between the presentation and the
> logic of a web application. My current setup is using apache's mod_python
> to apply a standard stylesheet to any requested XML file.
>
> I'm not sure of the best way to solve my problem. What I want is some sort
> of element that can be put in the source XML to signal my application to
> put some standard component in it's place. This component would query a
> database and output the data.
>
> What I've been trying is to write an extension element (by using
> registerExtModuleElement) to do this. The problem is that while I've been
> able to output any data to the output document, I can't find a way in the
> documentation to apply stylesheets to this result. What I'd like to happen
> is have my extensions return the data in XML that is then transformed by
> the stylesheet to XHTML.
>
> Again, I'm not sure if an extension element is the right solution for my
> problem. There are just so many standards floating about I can't find the
> right one :-P So, what is the solution for my problem, and how do I make it
> work?
Use xsl:document() to access more than one xml documents from your xslt.
When you use Python, you can define a custom entity resolver to feed the xml
from you application an register this function to the libxml2 module. Just an
example
def entityResolver(url, id, ctxt):
"""Custom entity resolver."""
try:
return urllib.urlopen(url)
except (IOError, OSError):
pass
libxml2.setEntityLoader(entityResolver)
Now change the resolver function to return the xml data you need in your
template.
Regards,
Thijs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]