[xslt] Question: How to register a URIResolver for xslt/Python bindings?



Hello:

I am integrating libxslt_py with my Zope application, and I want
to be able to use URI resolution to resolve things like:

xsl:import("urn:arielpartners:foo/bar/sheet1.xsl")

xsl:include("urn:arielpartners:mumble/blather/sheet2.xsl")

and

xsl:value-of select="document("urn:arielpartners:a/b.xml")

This resolution should happen when a user uses a browser
to access a URL.  The HTML for the URL would be automatically
transformed from XML source on the fly.

I am using URNs because some of my documents include portions of others.
Some stylesheets are also created out of piece/parts.
I use URNs instead of URLs so that the same content works
in multiple contexts (as we move from company to company, and
technology to technology) with no changes.  All I do is change
the URN -> URL mapping underneath-- In this way we hope
to "future proof" our content as much as possible...

The idea is that I would intercept a call to resolve the URI
and put in my own logic that uses Zope techniques
(e.g. acquisition) to find objects in the Zope object database that
correspond to the URNs.

There is a complication in that I want to do more than
simply map a given URN to a URL.  In fact, I need to maintain
the *context* in which applyStylesheet() was called.
This context is stored in browser cookies, which get passed
to my Python method in the form of an HTTP Request object.

When I resolve a URN to a URL, I want to retrieve the object
corresponding to the URL from the Zope object database
*using the same context that is in the original REQUEST*
This is important for security and other considerations.

For this reason, I believe I need Python code, not just a static
XML catalog file.

Here was my idea:  What if I subclass "catalog" and override
the resolve() method?

Will the libxml machinery call my method for catalog resolution?

Has anyone done this kind of thing before?

All advice, comments are much appreciated!

Regards,

--Craeg Strong




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]