;ņ lh†>c@sdZddd!Zddd!Zddd!ZdklZdklZd kl Z d k l Z d k l Z d klZd klZdkZdkZdkZdklZdZdZdfd„ƒYZdfd„ƒYZde efd„ƒYZde efd„ƒYZdS(s $RCSfile: FourSuite11Processor.py,v $ This class encapsulates an XSLT Processor for use by ZopeXMLMethods. This is the 4Suite 0.11 version, including support for XSLT parameters and URL/URN resolution. Author: Craeg Strong Release: 1.0 s $Name: $iiž’’’s$Date: 2003/03/30 03:45:47 $s$Revision: 1.27 $i (sxpath(s Processor(s XsltException(sStylesheetReader(s PyExpatReader(saq_get(sStringION(sIXSLTProcessors URNnamespacess XSLparameterssFourSuite11ProcessorcBshtZdZeZdZd„Zd„Zeed„Z d„Z eeed„Z d„Z d„Z RS( s° This class encapsulates an XSLT Processor for use by ZopeXMLMethods This is the 4Suite 0.11 version, including support for XSLT parameters and URN resolution. s 4Suite-0.11.1cCs d|_dS(s1Initialize a new instance of FourSuite11ProcessoriN(sselfs debugLevel(sself((sR/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/FourSuite11Processor.pys__init__6scCs ||_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((sR/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/FourSuite11Processor.pys setDebugLevel>sc CsĪt}|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:s xsltContents:s xmlContents:s sN(sNonestopLevelParamsstransformObjectsselfsgetXSLParameterss debugLevels xsltContentss xmlContentss transformGutssxmlURLsxsltURLsREQUESTsresults Exceptionsessyssstderrswritesstr( sselfs xmlContentssxmlURLs xsltContentssxsltURLstransformObjectsREQUESTsestopLevelParamssresult((sR/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/FourSuite11Processor.pys transformIs$    cCs||d|f<|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. sN(svaluesparamMapsname(sselfsparamMapsnamesvalue((sR/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/FourSuite11Processor.pysaddParamnscCsĘh} |tj o|i|ƒ} n|idjo dG| GHn|idjoIdkl}l} |i ƒ}|idjod|_ d|_ q„n t ƒ}y„|it| ||gƒƒ|it| |ƒƒ|i||ƒ|i|d|d|ƒ} |idjodGH| GHdGHnWn’tj o} tt| ƒƒ‚nmtiti fj oT} t!| d ƒo)d | i"t| ƒf} t| ƒ‚q¾tt| ƒƒ‚nX| Sd S( sw Actually performs the transformation. Throws an Exception if there are any errors. is namespaces:(sExtendedProcessingElementssStylesheetReaderistopLevelParamssbaseUris ===Result===s ============s stylesheetUrisWhile processing %s %sN($s namespaceMapstransformObjectsNonesselfsretrieveNamespacess debugLevelsxml.xsltsExtendedProcessingElementssStylesheetReadersExtendedProcessors processors _4xslt_debugs _4xslt_traces ProcessorssetStylesheetReadersStylesheetURIResolversREQUESTsxsltURLssetDocumentReadersDocumentURIResolversappendStylesheetStrings xsltContentss runStrings xmlContentssparamssresults XsltExceptionses ExceptionsstrsxpathsRuntimeExceptionsCompiletimeExceptionshasattrs stylesheetUrismessage(sselfs xmlContentssxmlURLs xsltContentssxsltURLstransformObjectsparamssREQUESTsExtendedProcessingElementssresultsStylesheetReadersmessageses namespaceMaps processor((sR/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/FourSuite11Processor.pys transformGutsys@        cCst|ttƒ}h}|tj oRxO|D]C}t||tƒ}t|ƒo|||