Changeset 1455 for TI07-MOLES
- Timestamp:
- 24/08/06 12:26:29 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/PythonCode/existInterface/eXistGeneralInterface.py
r1450 r1455 1 1 # Code inspired by example on eXist website. 2 import urllib2, base64, urllib, urlparse, httplib, xmlrpclib, types 2 import urllib2, base64, urllib, urlparse, httplib, xmlrpclib, types,sys 3 3 4 4 class InstanceObject(object): … … 131 131 r='none' 132 132 return r 133 #getXMLRecord gets any XML record, added by Dom134 def getXMLRecord(self,collID,IDdefinition,itemID):135 ''' Get a specific document from a collection in a repository by using the collection name and ID and ID element name '''136 xq ='''for $DE in collection('%s')/*[%s='%s'] return $DE'''%(collID,IDdefinition,itemID)133 134 def defineNamespace(self,abNS,fullNS): 135 #xq="declare namespace %s='%s'",(abNS,fullNS) 136 xq = '' 137 137 id,summary=self.executeQuery(xq) 138 138 if summary['hits']==1: … … 142 142 r='none' 143 143 return r 144 145 #getXMLRecord gets any XML record including ns:id as attribute, (added by Dom) 146 def getXMLRecord(self,collID,IDdefinition,itemID,att=None,namespaceLong=None,namespaceShort=None): 147 ''' Get a specific document from a collection in a repository by using the collection name and ID and ID element name ''' 148 if att: # ID is stored in an attribute 149 if namespaceLong and namespaceShort: #if attribute has namespace e.g. gml:id 150 xq='''declare namespace %s="%s"; for $DE in collection('%s')/*[@%s='%s'] return $DE'''%(namespaceShort,namespaceLong,collID,IDdefinition,itemID) 151 else: xq='''for $DE in collection('%s')/*[@%s='%s'] return $DE'''%(collID,IDdefinition,itemID) 152 else: 153 xq='''for $DE in collection('%s')/*[%s='%s'] return $DE'''%(collID,IDdefinition,itemID) 154 id,summary=self.executeQuery(xq) 155 if summary['hits']==1: 156 r=self.retrieve(id,0,{}) 157 self.sessionRelease(id) 158 else: 159 r='none' 160 return r 161 144 162 if __name__=="__main__": 145 163 … … 174 192 print 'done getXMLRecord (MOLES)' 175 193 #print existDB.chunkedFullText('badc') 194 195 print existDB.getXMLRecord('/db/ndg_A_metadata','gml:id','coapec_sample',att=1,namespaceLong='http://www.opengis.net/gml',namespaceShort='gml') 196 print 'done getXMLRecord with gml:id attribute (CSML)' 176 197 177
Note: See TracChangeset
for help on using the changeset viewer.