def _createDocument(self, rootName = u"root"): #$NON-NLS-1$ u"""Creates the zdom document.""" #$NON-NLS-1$ dom = ZDom() params = { u"prefix" : self.prefix, #$NON-NLS-1$ u"root" : rootName, #$NON-NLS-1$ u"namespace" : self.namespace #$NON-NLS-1$ } xml = u"""<%(prefix)s:%(root)s xmlns:%(prefix)s="%(namespace)s" />""" % params #$NON-NLS-1$ dom.loadHTML(xml) return dom
def readDnDSource(self, stgMedium): fmtstring = unicode(len(stgMedium.data)) + u"s" #$NON-NLS-1$ dataTuple = unpack(fmtstring, stgMedium.data) cfhtml = dataTuple[0] html = self._decodeCfHtml(cfhtml) htmlDom = ZDom() rootNode = None try: htmlDom.loadHTML(html) rootNode = htmlDom.selectSingleNode(u"/*") #$NON-NLS-1$ except: # Probably an encoding problem of some sort - just # return None (we are going to let IE handle it anyway) pass return ZHtmlDnDSource(rootNode)
def _attachContent(self, newDom, jbeHtmlFileName): # Only do it if the content file exists. if os.path.isfile(jbeHtmlFileName): newDom.setNamespaceMap(DOCUMENT_NSS_MAP) contentNode = newDom.selectSingleNode(u"/zns:entry/zns:content") #$NON-NLS-1$ html = self._loadContent(jbeHtmlFileName) # FIXME (PJ) use xhtml deserializer to load zDom. try: jbeHtmlDom = ZDom() jbeHtmlDom.loadHTML(html) contentNode.appendChild(newDom.importNode(jbeHtmlDom.documentElement, True)) contentNode.setAttribute(u"mode", u"xml") #$NON-NLS-2$ #$NON-NLS-1$ except: contentNode.setText(html) contentNode.setAttribute(u"type", u"text/html") #$NON-NLS-2$ #$NON-NLS-1$ contentNode.setAttribute(u"mode", u"escaped") #$NON-NLS-2$ #$NON-NLS-1$