[Zope] trying to implement server side xsl transform

Kees de Brabander cj.de.brabander at hccnet.nl
Thu Oct 25 03:33:18 EDT 2007

I don't fully understand what your are doing, though I am interested in a
xsl transformations in Zope. 
Your dtml must fail, however, because you can't use a dtml-tag within a
python expression. I would upload the xml document as a dtml-document and
call it just by its name.
By the way: what role does 4suite play in your process?
If you have a working solution, would you be willing to share it?

-----Oorspronkelijk bericht-----
Van: zope-bounces at zope.org [mailto:zope-bounces at zope.org] Namens Thomas
Verzonden: woensdag 24 oktober 2007 23:02
Aan: zope at zope.org
Onderwerp: [Zope] trying to implement server side xsl transform

Zope Version 	(Zope 2.10.3-final, python 2.4.3, linux2) 
using zeo storage

I am trying to implement a server side XSL Transform with the 
tools I have installed.   I have 4suite, libxml2,  and  libxsl.   The 
all of the files are dtml documents.

Listing 1 below works on the command line and writes an html file named
'foo' to the file system. So I added a def, a parameter to receive, and
indent Listing 1 appropriately to run as an External Method.  I also found,
from this list in September 2006, an almost identical External Method using
parseDoc instead of parseFile, and SaveToString instead of SaveToFile, see
Listing 2 and the traceback that follows it.

  All combinations and attempts to use an External Method result in either
parseDoc or parseFile failing.  Also, the Zope server will not respond to
WEB clients for as long as it is trying to process the External Method and
Apache times out in about 100 seconds  with a Proxy error and I usually have
to restart the Zope server to get access back to it through a WEB client
although ps doesn't show any unusual processor or memory usage.

  I have tried using Listing 1 and then read the file back in to return the
html text but still get the same result, parse failed.

The test page, a dtml document, making the call only contains:

<dtml-call "C_xml2html('<dtml-var 0418rice.xml>')"> or <dtml-call
expr="C_xml2html('<dtml-var 0418rice.xml>')">

Thanks for any help,


Listing 1----  command line python script that works
import libxml2
import libxslt

styledoc =
result=style.applyStylesheet(doc, None)

Listing 2 ---- External Method python script
import libxml2
import libxslt

stylestring = file("/var/zope/Extensions/eadbase.xsl").read()

def xml2html(xmlfile):

  styledoc = libxml2.parseDoc(stylestring)
  result=style.applyStylesheet(doc, None)
  return html

Traceback from the call using Listing 2

2007-10-24T16:29:56 ERROR Zope.SiteErrorLog
Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module OFS.DTMLMethod, line 144, in __call__
   - <DTMLMethod at /appcoll/ead2002/0000_xmlxsltest.html>
   - URL:
   - Physical Path: /appcoll/ead2002/0000_xmlxsltest.html
  Module DocumentTemplate.DT_String, line 476, in __call__
  Module DocumentTemplate.DT_Util, line 196, in eval
   - __traceback_info__: C_xml2html
  Module <string>, line 1, in <expression>
  Module Products.ExternalMethod.ExternalMethod, line 231, in __call__
   - __traceback_info__: (('<dtml-var 0418rice.xml>',), {}, None)
  Module /var/zope/Extensions/xmlxsltests.py, line 11, in xml2html
  Module libxml2, line 1224, in parseDoc
parserError: xmlParseDoc() failed

Thomas McMillan Grant Bennett		Appalachian State University
Operations & Systems Analyst		P O Box 32026
University Library				Boone, North Carolina 28608
(828) 262 6587

They say a picture is worth a thousand words.  As videos could be 25
pictures per second and might last several minutes, how many words is that? 
- Linux Journal, July 2007

Library Systems Help Desk: http://www.library.appstate.edu/help/
Zope maillist  -  Zope at zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.10/1091 - Release Date: 24-10-2007

More information about the Zope mailing list