- Timestamp:
- 24/01/07 14:13:17 (14 years ago)
- Location:
- TI02-CSML/trunk/csml
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/csmllibs/csmlxlink.py
r2034 r2038 39 39 return ds 40 40 41 def resolveXlink(csElement, csDocument): 42 '''takes a CSML element, containing Xlinks and resolves them within the csDocument''' 43 if hasattr(csElement, 'arcrole'): 44 usage=csElement.arcrole.split('#')[0] 45 elem=csElement.arcrole.split('#')[1] 46 if usage=='http://ndg.nerc.ac.uk/xlinkUsage/insert': 47 for child in csElement.CHILDREN: 48 print getattr(csElement, child).__class__ 49 print csElement.CHILDREN 50 if getattr(csElement, child).__class__ == elem: 51 print 'yes' 52 53 #if csElement.arcrole[:40]=='http://ndg.nerc.ac.uk/xlinkUsage/insert#': 54 #insert the element 55 56 print csElement.href 57 print csElement.arcrole 58 print csElement.role 59 print csElement.show 60 61 return csDocument -
TI02-CSML/trunk/csml/parser_extra.py
r1912 r2038 7 7 # Function to resolve references in CSML doc. 8 8 9 import csml 9 10 import csml.parser 10 11 import sys … … 93 94 94 95 class ParserPostProcessor: 95 def __init__(self,dataset): 96 #Needs rewriting for CSML v2 see V1original.96 def __init__(self,dataset): 97 97 98 self.dataset=dataset 98 99 100 def __findmatch(self, href): 101 for sd in csml.csmllibs.csmlextra.listify(self.dataset.storageDescriptor.descriptors): 102 if type(sd)==csml.parser.AggregatedArray: 103 for comp in csml.csmllibs.csmlextra.listify(sd.components): 104 if hasattr(comp, 'fileList'): 105 if hasattr(comp.fileList, 'id'): 106 if comp.fileList.id==href: 107 return comp.fileList 108 109 110 99 111 def resolveReferences(self): 100 pass 101 # return self.dataset 112 #for each xlink, call csml.csmllibs.csmlxlink.resolveXlink() 113 #start with fileLists in the the storage descriptors: 114 if hasattr(self.dataset, 'storageDescriptor'): 115 if hasattr(self.dataset.storageDescriptor, 'descriptors'): 116 for sd in csml.csmllibs.csmlextra.listify(self.dataset.storageDescriptor.descriptors): 117 if type(sd)==csml.parser.AggregatedArray: 118 for comp in csml.csmllibs.csmlextra.listify(sd.components): 119 if hasattr(comp, 'fileListXLINK'): 120 if hasattr(comp.fileListXLINK, 'href'): 121 fList = self.__findmatch(comp.fileListXLINK.href[1:]) 122 if fList is not None: 123 comp.fileList =fList 124 del comp.fileListXLINK 125 126 #for feature in self.dataset.featureCollection.featureMembers: 127 #if hasattr(feature.value.rangeSet, 'valueArray'): 128 ##could be an xlink here.. 129 #for vc in csml.csmllibs.csmlextra.listify(feature.value.rangeSet.valueArray.valueComponent): 130 #if hasattr(vc, 'href'): 131 #self.dataset=csml.csmllibs.csmlxlink.resolveXlink(vc, self.dataset) 132 #sys.exit() 133 return self.dataset -
TI02-CSML/trunk/csml/testfiles/basictest.py
r2030 r2038 14 14 ####################################################### 15 15 # 1. Test parsing from CSML file 16 tree = ElementTree(file='../XMLInstances/CSMLExample_SuperWrap.xml') 16 #tree = ElementTree(file='../XMLInstances/CSMLExample_SuperWrap.xml') 17 tree = ElementTree(file='../testfiles/gridseries/testout2.xml') 18 17 19 #tree = ElementTree(file='nagridseries.xml') 18 20 #tree = ElementTree(file='bodc.xml') … … 26 28 27 29 #resolve references: 28 #dataset=parser_extra.ParserPostProcessor(dataset).resolveReferences()30 dataset=csml.parser_extra.ParserPostProcessor(dataset).resolveReferences() 29 31 30 32 #This creates a new CSML document string from the CSML objects in memory.
Note: See TracChangeset
for help on using the changeset viewer.