;ò lh†>c@s´dZddd!Zddd!Zddd!ZdkZdklZdkZdk Z dk Z d k l Z d Z d Z d fd „ƒYZdfd„ƒYZdfd„ƒYZdS(s3 $RCSfile: SabPythProcessor.py,v $ This class encapsulates an XSLT Processor for use by ZopeXMLMethod. This is the SabPyth version, including support for XSLT parameters. It does not yet include support for URN resolution. Author: Craeg Strong Release: 1.0 s $Name: $iiþÿÿÿs$Date: 2003/03/30 03:45:47 $s$Revision: 1.12 $i N(saq_get(sIXSLTProcessors URNnamespacess XSLparameterssSabPythProcessorcBshtZdZeZdZd„Zd„Zeed„Z d„Z eged„Z d„Z d„Z RS( sÓ This class encapsulates an XSLT Processor for use by ZopeXMLMethod. This is the SabPyth version, including support for XSLT parameters. It does not yet include support for URN resolution. s Sab-Pyth-0.52cCs d|_dS(s-Initialize a new instance of SabPythProcessoriN(sselfs debugLevel(sself((sN/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/SabPythProcessor.pys__init__2scCs ||_dS(s‹ Set debug level from 0 to 3. 0 = silent 3 = extra verbose Debug messages go to Zope server log. N(slevelsselfs debugLevel(sselfslevel((sN/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/SabPythProcessor.pys setDebugLevel:sc CsÎg}|tj o|i|ƒ}n|idjo dG|GHn|idjodGH|GHdGH|GHny%|i|||||||ƒ} Wn3t j o'}tiit|ƒdƒdSnX| SdS( 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. isparams:is xsltContents:s xmlContents:s sN(stopLevelParamsstransformObjectsNonesselfsgetXSLParameterss debugLevels xsltContentss xmlContentss transformGutssxmlURLsxsltURLsREQUESTsresults Exceptionsessyssstderrswritesstr( sselfs xmlContentssxmlURLs xsltContentssxsltURLstransformObjectsREQUESTsestopLevelParamssresult((sN/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/SabPythProcessor.pys transformEs$    cCsd|||<|SdS(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%sN(svaluesparamMapsname(sselfsparamMapsnamesvalue((sN/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/SabPythProcessor.pysaddParamksc Csøh} |tj o|i|ƒ} n|idjo dG| GHntiƒ} g}|o|i ƒ}n| i ti t| |ƒƒ| i titƒƒ| iddd|d|fd|fgƒt| idƒd ƒ} | id ƒ} | Sd S( sw Actually performs the transformation. Throws an Exception if there are any errors. is namespaces:s arg:sheets arg:inputs arg:outputsinputssheetsoutputsutf8s ISO-8859-1N(s namespaceMapstransformObjectsNonesselfsretrieveNamespacess debugLevelsSablotsCreateProcessorssps paramListsparamssitemss regHandlers HLR_SCHEMEsUrnSchemeHandlersREQUESTs HLR_MESSAGEsMessageHandlersruns xmlContentss xsltContentssunicodes getResultArgstextsencodesresult( sselfs xmlContentssxmlURLs xsltContentssxsltURLstransformObjectsparamssREQUESTs paramLists namespaceMapsspsresultstext((sN/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/SabPythProcessor.pys transformGutsvs&    cCst|ttƒ}h}|tj oRxO|D]C}t||tƒ}t|ƒo|||scCsdS(sò put: save data to the URI (if possible) handle = the handle assigned on open buffer = pointer to the data *byteCount = number of bytes to write (the number actually written is returned here) N((sselfshandles bytecount((sN/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/SabPythProcessor.pysputJscCst|i|