;ò
lh†>c @ s‹ d Z d d d !Z d d d !Z d d d !Z d k Z d k Z d k l Z d k Z d k l Z d
Z
d Z d Z d
f d „ ƒ YZ
d S( s:
$RCSfile: LibXsltProcessor.py,v $
This class encapsulates an XSLT Processor for use by ZopeXMLMethods.
This is the GNOME libxslt version, including support for XSLT
parameters. It does not yet include support for URN resolution.
Author: Craeg Strong
Release: 1.0
s $Name: $i iþÿÿÿs $Date: 2003/03/30 03:45:47 $s $Revision: 1.17 $i
N( s aq_get( s IXSLTProcessors
URNnamespacess
XSLparameterss
XMLcatalogs LibXsltProcessorc B sq t Z d Z e Z d Z d „ Z d „ Z e e d „ Z d „ Z
e e e d „ Z d „ Z d „ Z
d „ Z RS(
sÛ
This class encapsulates an XSLT Processor for use by ZopeXMLMethods.
This is the GNOME libxslt version, including support for XSLT
parameters. It does not yet include support for URN resolution.
s libxslt 1.0.27c C sM d | _ t i | i d ƒ t i | i d ƒ t i d ƒ t i d ƒ d S( s- Initialize a new instance of LibXsltProcessori s i N( s selfs
debugLevels libxml2s registerErrorHandlers errorHandlers libxslts lineNumbersDefaults substituteEntitiesDefault( s self( ( sN /mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/LibXsltProcessor.pys __init__5 s
c C s
| | _ d S( s‹
Set debug level from 0 to 3.
0 = silent
3 = extra verbose
Debug messages go to Zope server log.
N( s levels selfs
debugLevel( s selfs level( ( sN /mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/LibXsltProcessor.pys
setDebugLevelC s c
C sÎ t } | t j o | i | ƒ } n | i d j o
d G| GHn | i d j o d GH| GHd GH| GHn y% | i | | | | | | | ƒ } Wn3 t
j
o' } t i i t | ƒ d ƒ d Sn X| Sd S( sE
Transforms the passed in XML into the required output (usually
HTML) using the passed in XSLT. Both the XML and XSLT strings
should be well-formed. Returns the output as a string.
transformObject and REQUEST params may be used to acquire Zope
content such as XSLT parameters and URN namespaces, if
required. Catches any exceptions thrown by transformGuts and
sends the error output to stderr, returns empty string to the
caller. The idea is that web site users will at worst see an
empty page.
i s params:s
xsltContents:s xmlContents:s
s N( s Nones topLevelParamss transformObjects selfs getXSLParameterss
debugLevels xsltContentss xmlContentss
transformGutss xmlURLs xsltURLs REQUESTs results Exceptions es syss stderrs writes str(
s selfs xmlContentss xmlURLs xsltContentss xsltURLs transformObjects REQUESTs es topLevelParamss result( ( sN /mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/LibXsltProcessor.pys transformN s$
c C s d | | | <| Sd S( sÃ
This is a convenience function for adding parameters in the
correct format to the parameter map to be used for the
'params' parameter in transformGuts.
s '%s'N( s values paramMaps name( s selfs paramMaps names value( ( sN /mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/LibXsltProcessor.pys addParamt s c C s
y t i | ƒ } | i | ƒ Wn: t i j
o+ } d | t | ƒ f } t
| ƒ ‚ n Xt i | ƒ } y t i | ƒ }
|
i | ƒ Wn4 t i j
o% } d t | ƒ } t
| ƒ ‚ n X| i |
| ƒ }
| i |
ƒ } | i ƒ |
i ƒ |
i ƒ | Sd S( sw
Actually performs the transformation. Throws an Exception if
there are any errors.
s$ XML parse error for XSLT file %s: %ss$ XML parse error for XML document: %sN( s libxml2s parseDocs xsltContentss styleDocs setBases xsltURLs parserErrors es strs messages Exceptions libxslts parseStylesheetDocs styles xmlContentss xmlDocs xmlURLs applyStylesheets paramss resultDocs saveResultToStrings results freeStylesheets freeDoc( s selfs xmlContentss xmlURLs xsltContentss xsltURLs transformObjects paramss REQUESTs es styles resultDocs results messages xmlDocs styleDoc( ( sN /mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/LibXsltProcessor.pys
transformGuts s(
c C s t | ƒ ‚ d S( s™
The default error handler for libxml2 and libxslt prints out
messages to stderr. Throw an exception instead.
N( s Exceptions error( s selfs ctxs error( ( sN /mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/LibXsltProcessor.pys errorHandlerÒ s c C s t | t t ƒ } h } | t j oR xO | D]C } t | | t ƒ } t | ƒ o | | |