[Zope] Parse a XML file in Zope, zopeXMLmethods Product not working in Zope 2.8.1

Sascha Ottolski sascha.ottolski at gallileus.de
Mon Sep 26 12:34:05 EDT 2005


Am Montag, 26. September 2005 15:57 schrieb Martin Koekenberg:
> Hello,
>
> I've a xml file on the file system (the source is on an other webserver and
> the download is scheduled). How ca I parse this file with a xslt in Zope.
> ZopeXMLmethods isn't working annymore in Zope 2.8.1.
>
> Does annyone knows a Product of method to parse xml in Zope without the
> zopeXMLmethods product ?
>
> Regards,
>
> Martin Koekenberg

I do it like this (ExternalMethod in this case):

--------------------------------------------------------------------
import libxml2
import libxslt

stylestring = file("/path/to/style/file.xsl").read()

def xslt(data):
    # note: if styledoc and style are defined outside the function,
    # zope dumps core :-(
    styledoc = libxml2.parseDoc(stylestring)
    style = libxslt.parseStylesheetDoc(styledoc)
    doc = libxml2.parseDoc(data)
    result = style.applyStylesheet(doc, None)
    html = style.saveResultToString(result)
    style.freeStylesheet()
    doc.freeDoc()
    result.freeDoc()
    return html
--------------------------------------------------------------------


may be not very smart, but it's working :-)


Cheers, 

Sascha


More information about the Zope mailing list