Changeset 1732 for TI02-CSML/branches/CSML2/csParser.py
- Timestamp:
- 21/11/06 16:23:14 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/branches/CSML2/csParser.py
r1723 r1732 23 23 24 24 def __init__(self, **kwargs): 25 pass 26 #self.kws=kwargs 25 if not hasattr(self, 'ATTRIBUTES'): 26 self.ATTRIBUTES=[] 27 27 28 28 29 def __myQName(self,uri,tag): 29 30 return "{"+uri+"}"+tag 31 32 def __removeURI(self, qname): 33 try: 34 attname = qname.split('}')[1] 35 except IndexError: 36 attname = qname 37 return attname 30 38 31 39 def toXML(self, csmlfrag): 32 40 #process self... and convert  to XML 33 41 # self.ATTRIBUTES 42 for item in self.__dict__: 43 print item 44 if self.__removeURI(item) in self.ATTRIBUTES: 45 print 'yes' 46 csmlfrag.set(item, self.__dict__[item]) 34 47 # self.CHILDREN (recursive - calls the toXML method of children) 35 48 for att in self.__dict__: … … 56 69 57 70 def fromXML(self,csmlfrag): 58 # self.CHILDREN (recursive - calls the fromXML method of children) 71 # deal with attributes, e.g. gml id's 72 for item in csmlfrag.items(): 73 if self.__removeURI(item[0]) in self.ATTRIBUTES: 74 setattr(self, item[0], item[1]) 75 print "DONE" 76 # self.CHILDREN (recursive - calls the fromXML method of children 59 77 for frag in csmlfrag[:]: 60 78 if frag.text is not None: … … 99 117 100 118 101 class Dataset( csElement):119 class Dataset(AbstractGML, csElement): 102 120 ''' Dataset class, needed as root of tree''' 103 121 def __init__(self, **kwargs): 122 AbstractGML.__init__(self,**kwargs) 104 123 self.NAMESPACE=nsCSML 105 124 self.CHILDREN = {'ncExtract':['NetCDFExtract', 'NetCDFExtract']}
Note: See TracChangeset
for help on using the changeset viewer.