Changeset 2835 for TI05-delivery


Ignore:
Timestamp:
21/08/07 12:36:34 (12 years ago)
Author:
lawrence
Message:

Slightly more elegant default xml encoding solution

Location:
TI05-delivery/ows_framework/trunk/ows_server/ows_server/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndgRetrieve.py

    r2834 r2835  
    7373     
    7474    try: 
    75     x=xmlHandler2.xmlHandler(r,string=1) 
    76     return 1,x 
     75        x=xmlHandler2.xmlHandler(r,string=1) 
     76        return 1,x 
    7777    except Exception,e: 
    7878        logString='Document parse for [%s] failed [%s]'%(uri,e) 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/xmlHandler2.py

    r2834 r2835  
    3535        # Unfortunately we never know whether the incoming xml content is 
    3636        # unicode or a string ... 
     37        encoding='utf-8' 
    3738        try: 
    38             self.xmls=unicode(self.xmls,'utf-8') 
    39         except: 
    40             pass 
    41         self.xmls=self.xmls.encode('utf-8','replace') 
     39            ss=xml[0:39].split('"') 
     40            if ss[2]=='encoding=': encoding=ss[3] 
     41        except:pass 
     42        try: 
     43            self.xmls=unicode(self.xmls,encoding) 
     44        except:pass 
     45        self.xmls=self.xmls.encode(encoding,'replace') 
    4246         
    4347        self.realns={}             
     
    4953            self.xmls=self.__fixXML(self.xmls) 
    5054            self.tree=ET.XML(self.xmls) 
    51          
    52              
     55 
    5356        self.__updatens() 
    5457     
Note: See TracChangeset for help on using the changeset viewer.