Beispiel #1
0
 def __init__(self, outputParams, saxHandler=None, fragment=False):
     CheckVersion(feature="4XSLT's SaxWriter")
     self.__fragment = fragment
     self.__firstElementFlag = True
     self.__orphanedNodes = []
     self.__saxHandlerClass = None
     self.__saxHandler = None
     self.__stateStack = []
     self.__currElement = None
     self.__currText = u''
     self._outputParams = outputParams or OutputParameters.OutputParameters()
     if saxHandler:
         self.__saxHandler = saxHandler
     elif self.__outputParams.method == 'xml':
         self.__initSaxHandler(Sax2.XmlDomGenerator)
         if self.__outputParams.omitXmlDeclaration in [None, 'no']:
             self.__saxHandler.xmlDecl(
                 self.__outputParams.version,
                 self.__outputParams.encoding,
                 self.__outputParams.standalone
                 )
     elif self.__outputParams.method == 'html':
         self.__initSaxHandler(HtmlSax.HtmlDomGenerator)
     elif self.__outputParams.method == 'text':
         self.__initSaxHandler(TextSax.TextGenerator)
Beispiel #2
0
def create_writer(stream,
                  wargs=None,
                  pubid=None,
                  sysid=None,
                  encoding="UTF-8"):
    wargs = wargs or {}
    if not stream:
        raise BinderException(NO_STREAM_GIVEN_FOR_UNBIND)
    op = OutputParameters.OutputParameters()
    for arg in wargs:
        setattr(op, arg, wargs[arg])
    #Doctype info in the document object override any given explicitly
    if sysid: op.doctypeSystem = sysid
    if pubid: op.doctypePublic = pubid
    #writer = XmlWriter.XmlWriter(op, stream)
    writer = XmlWriter.CdataSectionXmlWriter(op, stream)
    return writer
Beispiel #3
0
    def instantiate(self, context, processor):
        op = OutputParameters.OutputParameters()
        op.method = "xml"
        op.encoding = processor.writers[-1]._outputParams.encoding
        op.omitXmlDeclaration = 1
        stream = cStringIO.StringIO()
        processor.pushResult(XmlWriter.XmlWriter(op, stream))
        try:
            for child in self.children:
                child.instantiate(context, processor)
        finally:
            processor.popResult()
        msg = stream.getvalue()

        if self._terminate:
            raise XsltRuntimeException(Error.STYLESHEET_REQUESTED_TERMINATION,
                                       self, msg)
        else:
            processor.xslMessage(msg)

        return
Beispiel #4
0
 def __init__(self, *args, **kwds):
     XsltElement.__init__(self, *args, **kwds)
     self._output_parameters = OutputParameters.OutputParameters()
     return
Beispiel #5
0
 def reset2(self):
     self.outputParams = OutputParameters.OutputParameters()
     self.spaceRules = []
     self.namespaceAliases = {}
     self.decimalFormats = {}
     return
Beispiel #6
0
 def setup(self):
     self._output_parameters = OutputParameters.OutputParameters()
     return