[Zope-xml] XML Transform without predefined XML source (Re: XMLTransform interface alternatives)

Craeg K Strong cstrong at arielpartners.com
Thu Sep 5 15:27:34 EDT 2002


See comments embedded below...

Brad Clements wrote:
> On 4 Sep 2002 at 15:00, Igor Elbert wrote:
> 
>>I think it would be useful if XMLTransform allowed me to leave the Source
>>ID field empty and assumed it's applied to an XML. For example I would like
>>to be able to write: http://MyFolder/myZSQLmethod/asXML/transform and get a
>>rendered page.
>>
> I made the following modification to XMLTransform.py
> 
>     def transform(self, REQUEST,xmlContents=None):
>         """
> 
>         Generate result using transformer and return it as a string
> 
>         """
> 
>         registry    = self.findRegistry()
>         xslObject   = registry.transformerObject(self.transformerName)
>         xslContents = xslObject(xslObject, REQUEST)
>         systemID    = xslObject.absolute_url()
>         if xmlContents is None:
>             xmlContents = self.getContents(REQUEST)
> 
> So I can call it from a PythonScript. Not exactly what you want, but getting there.

Yeap.  I will be looking in to this RSN, as there are many situations
where we want to use this too :-)

> I'd like to see caching of the prepared Stylesheet.

This is more complicated than it might at first seem.  My guess is you are
thinking of a situation where the XSLT is simply a chunk of ASCII text
sitting somewhere.  But our XSLTs are nothing of the sort :-)  In fact, they
have

a) embedded DTML tags that dynamically at runtime get filled in with whatever
values the attributes they reference have at the moment

b) are themselves XMLTransforms because they are generated using other XSLT
transformers.  We have a two-level transformation scheme which helps keep
the XSLTs more generic and less monolithic.  We generate all of our XSLTs out
of pieces and parts.

That said, we still get caching.  Because we make all of our XSLTs instances of 
XMLTransform, they can be cached the same way.

Again, we wanted to keep caching functionality outside of XMLTransform.py
itself, to make the code cleaner and simpler.  The CacheManager does the
caching on behalf of the XMLTransform.

If, having understood the above, you still have suggestions for further caching
opportunities, I am willing to entertain them  :)

  I don't need the output cached since
> it's all dynamic.

Thats OK, the "never Cache" option was designed for that situation.  If you set
Caching to "off" (which means never cache) in the XMLTransform, it won't attempt
to cache the output.

--Craeg





More information about the Zope-xml mailing list