Logo Search packages:      
Sourcecode: zope-attachmentfield version File versions  Download package

def AttachmentField::ooconverter::oo_to_html::parseMetadata (   self,
  xml 
)

parse all metadata from xml

Definition at line 259 of file ooconverter.py.

00259                                 :
        """
        parse all metadata from xml
        """
        
        headers={}
        
        # libxml2 encoding translation
        xmlOutEnc=self.getOutEncoding(default='utf8')

        # create xpath context
        doc=libxml2.parseDoc(xml)
        ctxt=doc.xpathNewContext()
        
        # register openoffice xml namespaces
        ctxt.xpathRegisterNs( "office", "http://openoffice.org/2000/office")
        ctxt.xpathRegisterNs( "meta", "http://openoffice.org/2000/meta")
        
        # register dublincore namespace
        ctxt.xpathRegisterNs( "dc", "http://purl.org/dc/elements/1.1/")
        
        dict_list   = ("//meta:user-defined", "//meta:document-statistic")
        string_list = ("//meta:generator", "//dc:title", "//dc:description", "//dc:subject",
                       "//meta:creation-date", "//dc:date",
                       "//dc:language", "//meta:editing-cycles", "//meta:editing-duration")
        list_list   = ("//meta:keywords/child::meta:keyword", )
                     
        for c in string_list:
            r = ctxt.xpathEval("%s" % c)
            name=c.split(":")[-1]
            if len(r): headers[name] = unicode(r[0].get_content(), 'UTF-8', 'replace').encode(xmlOutEnc, 'replace')
            
        for c in list_list:
            r = ctxt.xpathEval("%s" % c)
            name=c.split(":")[-1]
            res=[]
            for n in r:
                res.append(unicode(n.get_content(), 'UTF-8', 'replace').encode(xmlOutEnc, 'replace'))
            headers[name]=res

        # cleanup
        doc.freeDoc()
        ctxt.xpathFreeContext()       

        return headers

                        
    def parseImages(self, html):


Generated by  Doxygen 1.6.0   Back to index