Changeset 2260


Ignore:
Timestamp:
12/03/07 20:06:07 (12 years ago)
Author:
lawrence
Message:

Slight changes to support modified xqueries, and modified xquery
itself ... first cut at MDIP (based on DC, doesn't actually do
anything proper for now).

Location:
TI07-MOLES/trunk/PythonCode/wsgi
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/wsgi/DocumentRetrieve.py

    r2120 r2260  
    77# Note that ndgRetreive essentially provides test cases for this code. 
    88 
     9debug=1 
     10 
    911def queryReplace(xquery,repository,localID,targetCollection): 
    1012    ''' Used to modify the vanilla xqueries to a query which gets the actual requested documents ''' 
    1113    xquery=xquery.replace('RepositoryID',repository,1) 
    1214    xquery=xquery.replace('LocalID',localID,1) 
    13     xquery=xquery.replace('/db/ndg_B_metadata', targetCollection) 
     15    xquery=xquery.replace('TargetCollection', targetCollection) 
    1416    return xquery 
    1517     
     
    4143            # xquery=listingQuery 
    4244 
    43             #targetCollection='/db/ndg_B_metadata' 
     45            # default code has targetCollection='/db/ndg_B_metadata, this gets us the right one ... 
    4446            xquery=ObjectTypeQuery 
    4547            xquery=queryReplace(xquery,repository,localID,targetCollection) 
     
    5254             
    5355            # check output formats 
    54             allowed = ['DIF','DC','ISO19115','NDG-B0','NDG-B1'] 
     56            allowed = ['DIF','DC','ISO19139','NDG-B0','NDG-B1','MDIP'] 
    5557            if format not in allowed: raise TypeError,'Invalid document output format [%s]'%format 
    5658             
     
    6365            objectType=int(xml.getElementsByTagNameNS( 
    6466                            "http://ndg.nerc.ac.uk/moles", "objectType").item(0).firstChild.data) 
     67            if debug: print 'objectType=%s'%objectType 
    6568             
    6669            if format.find('NDG')==-1 and objectType!=4: 
     
    7174            xquery={'DIF':DIFQuery, 
    7275                    'DC':DublinCoreDEQuery, 
    73                     'ISO19115':ISO19139Query, 
     76                    'ISO19139':ISO19139Query, 
    7477                    'NDG-B0':MOLESQuery, 
     78                    'MDIP':MDIPQuery, 
    7579                    'NDG-B1':{ 
    7680                        4:StubBDEQuery, 
     
    8892            # should only be the one document in the result set 
    8993            if hits!=1:  
     94                if debug: 
     95                    f=open('xquery.%s.fails.xq'%format,'w') 
     96                    f.write(xquery) 
     97                    f.close() 
    9098                raise ValueError,'Actual Document Query returned [%s] hits - internal error!'%hits 
    9199              
  • TI07-MOLES/trunk/PythonCode/wsgi/ndgRetrieve.py

    r2118 r2260  
    77from stubB import stubB 
    88from ndgObject import ndgObject 
     9from MDIP import MDIP 
    910 
    1011# any class with a get method can be used here, and then only 
     
    4748            elif format=='DC': 
    4849                r=DC(xml) 
     50            elif format=='MDIP': 
     51                r=MDIP(xml) 
    4952            r=self.renderer.render(r) 
    5053        elif otype=='print': 
     
    126129            try: 
    127130                if ori: 
    128                     print 'and off we go' 
     131                    print 'Original Document Request' 
    129132                    r=ws.getOriginal(uri.uri) 
    130133                    if outputType=='html': outputType='print'  # sanity ...     
    131134                else: 
     135                     
    132136                    if 'format' not in inputs.keys(): 
    133137                        format='NDG-B0' 
    134138                    else: 
    135139                        format=inputs['format'] 
     140                    print 'Request for %s format document'%inputs['format'] 
    136141                    r=ws.get(uri.repository,uri.schema,uri.localID,format=format)        
    137142                if isinstance(r,int): 
     
    174179import unittest 
    175180testURI='noc.soton.ac.uk__DIF__NOCSDAT193' 
     181retriever=ndgRetrieve('./') 
    176182class TestCase(unittest.TestCase): 
    177      
    178  
    179     def testRetrieve(self): 
    180         ''' Test fundamental retrieval capability ''' 
    181         ctype='text/html'  
    182         retriever=ndgRetrieve('./') 
    183         inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'DIF','type':'html'} 
    184         ctype,r=retriever._present(inputs,ctype) 
    185          
     183         
    186184    def testOriginal(self): 
    187185        ''' Tests the ability to obtain an original document ''' 
    188         ctype='text/html'  
    189         retriever=ndgRetrieve('./') 
    190         inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'DIF','type':'html','original':'1'} 
    191         ctype,r=retriever._present(inputs,ctype) 
    192          
     186        inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'original','type':'html','original':'1'} 
     187        ctype,r=retriever._present(inputs,'text/html') 
     188        if r[0:3]=='<p>':raise ValueError,r 
     189    def testDIF(self): 
     190        ''' Tests the ability to obtain a DIF document ''' 
     191        inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'DIF','type':'html'} 
     192        ctype,r=retriever._present(inputs,'text/html') 
     193        if r[0:3]=='<p>':raise ValueError,r 
     194    def testMDIP(self): 
     195        ''' Tests the ability to obtain an MDIP document ''' 
     196        inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'MDIP','type':'html'} 
     197        ctype,r=retriever._present(inputs,'text/html') 
     198        if r[0:3]=='<p>':raise ValueError,r 
     199    def testISO(self): 
     200        ''' Tests the ability to obtain an ISO document ''' 
     201        inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'ISO19139','type':'html'} 
     202        ctype,r=retriever._present(inputs,'text/html') 
     203        if r[0:3]=='<p>':raise ValueError,r 
     204    def testDC(self): 
     205        ''' Tests the ability to obtain a DC document ''' 
     206        inputs={'repository':'glue.badc.rl.ac.uk','uri':testURI,'format':'DC','type':'html'} 
     207        ctype,r=retriever._present(inputs,'text/html') 
     208        if r[0:3]=='<p>':raise ValueError,r 
     209         
     210         
    193211if __name__=="__main__": 
    194212    unittest.main() 
  • TI07-MOLES/trunk/PythonCode/wsgi/ndgSearch.py

    r2116 r2260  
    182182        j=len(responses) 
    183183        if i!=j: 
    184             raise ValueError,'Internal inconsistency in search return [%s!=%s]'%(i,j) 
     184            raise ValueError,'Internal inconsistency in search return [hits:%s!=responses:%s]'%(i,j) 
    185185        indices=range(i) 
    186186        results=[] 
  • TI07-MOLES/trunk/PythonCode/wsgi/ndg_xqueries.py

    r2258 r2260  
    55declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $DE 
    66in 
    7 collection('/db/ndg_B_metadata')/dgMetadata/dgMetadataRecord[exists(dgDataEntity)] return 
     7collection('TargetCollection')/dgMetadata/dgMetadataRecord[exists(dgDataEntity)] return 
    88<dgMetadataRecord>{$DE/dgMetadataID/repositoryIdentifier} 
    99{$DE/dgMetadataID/localIdentifier}<fileName>{util:document-name($DE)}</fileName></dgMetadataRecord> 
    1010''' 
    1111 
    12 ObjectTypeQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $Obj in collection('/db/ndg_B_metadata')/dgMetadata/dgMetadataRecord[dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID']  return <objectType>{if (exists($Obj/dgDataEntity)) then 4 else (if (exists($Obj/dgObservationStation)) then 3 else (if (exists($Obj/dgDataProductionTool)) then 2 else (if (exists($Obj/dgActivity)) then 1 else (0))))}</objectType>''' 
     12ObjectTypeQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $Obj in collection('TargetCollection')/dgMetadata/dgMetadataRecord[dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID']  return <objectType>{if (exists($Obj/dgDataEntity)) then 4 else (if (exists($Obj/dgObservationStation)) then 3 else (if (exists($Obj/dgDataProductionTool)) then 2 else (if (exists($Obj/dgActivity)) then 1 else (0))))}</objectType>''' 
    1313 
    1414StubBDEQuery = '''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     
    12971297) (: End namespace strip :)''' 
    12981298 
    1299 ISO19139Query = '''declare default element namespace 'http://www.isotc211.org/2005/gmd'; declare namespace moles='http://ndg.nerc.ac.uk/moles'; declare namespace gco='http://www.isotc211.org/2005/gco'; declare namespace gmd='http://www.isotc211.org/2005/gmd'; declare namespace gml='http://www.opengis.net/gml'; declare namespace xlink='http://www.w3.org/1999/xlink'; declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; for $DE in collection('/db/ndg_B_metadata')/moles:dgMetadata/moles:dgMetadataRecord[ exists(moles:dgDataEntity) and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' and moles:dgMetadataID/moles:localIdentifier='LocalID'] return element MD_Metadata {attribute xsi:schemaLocation {'http://www.isotc211.org/2005/gmd http://www.isotc211.org/2005/gmd/metadataEntity.xsd'}, element fileIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':ISO19115:', $DE/moles:dgMetadataID/moles:localIdentifier)}}, element language {element gmd:LanguageCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English'}}, element hierarchyLevel {element MD_ScopeCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode_dataset'}, 'dataset'}}, for $parent in $DE/moles:dgRelatedDataEntity[moles:RelationID/moles:dgValidTerm='is-part-of'] return element parentIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier)}}, for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] return for $DataCuratorRoleHolder in collection('/db/ndg_B_metadata')/moles:dgMetadata/(moles:dgPerson | moles:dgOrganisation)[ moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:localIdentifier] return element contact {element CI_ResponsibleParty {if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then element organisationName {element gco:CharacterString {string($DataCuratorRoleHolder/moles:name)}}else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then element individualName {element gco:CharacterString {string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName)))}}else ('empty content') , element positionName {if (exists($DataCuratorRoleHolder/moles:localName)) then element gco:CharacterString {$DataCuratorRoleHolder/moles:localName}else if (exists($DataCuratorRole/moles:roleName)) then element gco:CharacterString {$DataCuratorRole/moles:roleName}else element gco:CharacterString {'Curator'}}, element contactInfo {element gmd:CI_Contact {if (exists($DataCuratorRole/moles:contactDetails/moles:telephone or $DataCuratorRole/moles:contactDetails/moles:fax or $DataCuratorRoleHolder/moles:contactDetails/moles:telephone or $DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then element phone {element gmd:CI_Telephone {if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then element voice {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:telephone)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element voice {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then element facsimile {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element facsimile {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}}else () }} else (), element address {element gmd:CI_Address {if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:address/moles:city)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:eMail)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}}else () }}}}, element role {element CI_RoleCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode_custodian'}, if (exists($DataCuratorRole/moles:localName)) then data($DataCuratorRole/moles:localName) else if (exists($DataCuratorRoleHolder/moles:localName)) then data($DataCuratorRoleHolder/moles:localName) else 'Curator' }}}}, element dateStamp {element gco:Date {adjust-date-to-timezone(current-date())}}, element metadataStandardName {element gco:CharacterString {'ISO 19115:2003'}}, element metadataStandardVersion {element gco:CharacterString {'2003'}}, element identificationInfo {element gmd:MD_DataIdentification {element citation {element gmd:CI_Citation {element title {element gco:CharacterString {data($DE/moles:name)}}, if (exists($DE/moles:abbreviation) and not(empty($DE/moles:abbreviation))) then element alternateTitle {element gco:CharacterString {data($DE/moles:abbreviation)}}else (), element date {if (exists($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate)) then element gmd:CI_Date {element date {element gco:Date {adjust-date-to-timezone(data($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate))}}, element dateType {element CI_DateTypeCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/moles:gmxCodelists.xml#CI_DateTypeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode_creation' }, 'Creation'}}}else attribute gco:nilReason {'unknown'}}}}, element abstract {element gco:CharacterString {data($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}}, element language {element gmd:LanguageCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English' }}, for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) return element topicCategory {element gmd:MD_TopicCategoryCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}, attribute codeListValue {string($ISOTopicCategory/moles:dgValidTerm)}, string($ISOTopicCategory/moles:dgValidTerm)}}, if (exists($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage)) then element extent {element gmd:EX_Extent {(: add bounding boxes:) for $geoBBox in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox return element geographicElement {element EX_GeographicBoundingBox {element westBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitWest)}}, element eastBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitEast)}}, element southBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitSouth)}}, element northBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitNorth)}}}}, for $geoArea in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea return element geographicElement {element EX_GeographicDescription {element geographicIdentifier {element gmd:RS_Identifier {element gco:CharacterString {element code {data(dgArea/dgValidTerm)}}, element gco:CharacterString {element codeSpace {data(dgArea/dgValidTermID/ParentListID)}}}}}}}}else()}}}''' 
    1300  
     1299ISO19139Query = '''declare default element namespace 'http://www.isotc211.org/2005/gmd'; declare namespace moles='http://ndg.nerc.ac.uk/moles'; declare namespace gco='http://www.isotc211.org/2005/gco'; declare namespace gmd='http://www.isotc211.org/2005/gmd'; declare namespace gml='http://www.opengis.net/gml'; declare namespace xlink='http://www.w3.org/1999/xlink'; declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; for $DE in collection('TargetCollection')/moles:dgMetadata/moles:dgMetadataRecord[ exists(moles:dgDataEntity) and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier='RepositoryID' and moles:dgMetadataID/moles:localIdentifier='LocalID'] return element MD_Metadata {attribute xsi:schemaLocation {'http://www.isotc211.org/2005/gmd http://www.isotc211.org/2005/gmd/metadataEntity.xsd'}, element fileIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':ISO19115:', $DE/moles:dgMetadataID/moles:localIdentifier)}}, element language {element gmd:LanguageCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English'}}, element hierarchyLevel {element MD_ScopeCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode_dataset'}, 'dataset'}}, for $parent in $DE/moles:dgRelatedDataEntity[moles:RelationID/moles:dgValidTerm='is-part-of'] return element parentIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier)}}, for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] return for $DataCuratorRoleHolder in collection('TargetCollection')/moles:dgMetadata/(moles:dgPerson | moles:dgOrganisation)[ moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:localIdentifier] return element contact {element CI_ResponsibleParty {if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then element organisationName {element gco:CharacterString {string($DataCuratorRoleHolder/moles:name)}}else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then element individualName {element gco:CharacterString {string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName)))}}else ('empty content') , element positionName {if (exists($DataCuratorRoleHolder/moles:localName)) then element gco:CharacterString {$DataCuratorRoleHolder/moles:localName}else if (exists($DataCuratorRole/moles:roleName)) then element gco:CharacterString {$DataCuratorRole/moles:roleName}else element gco:CharacterString {'Curator'}}, element contactInfo {element gmd:CI_Contact {if (exists($DataCuratorRole/moles:contactDetails/moles:telephone or $DataCuratorRole/moles:contactDetails/moles:fax or $DataCuratorRoleHolder/moles:contactDetails/moles:telephone or $DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then element phone {element gmd:CI_Telephone {if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then element voice {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:telephone)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element voice {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then element facsimile {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element facsimile {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)}}else () }} else (), element address {element gmd:CI_Address {if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:address/moles:city)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)}}else (), if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:eMail)}}else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}}else () }}}}, element role {element CI_RoleCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode_custodian'}, if (exists($DataCuratorRole/moles:localName)) then data($DataCuratorRole/moles:localName) else if (exists($DataCuratorRoleHolder/moles:localName)) then data($DataCuratorRoleHolder/moles:localName) else 'Curator' }}}}, element dateStamp {element gco:Date {adjust-date-to-timezone(current-date())}}, element metadataStandardName {element gco:CharacterString {'ISO 19115:2003'}}, element metadataStandardVersion {element gco:CharacterString {'2003'}}, element identificationInfo {element gmd:MD_DataIdentification {element citation {element gmd:CI_Citation {element title {element gco:CharacterString {data($DE/moles:name)}}, if (exists($DE/moles:abbreviation) and not(empty($DE/moles:abbreviation))) then element alternateTitle {element gco:CharacterString {data($DE/moles:abbreviation)}}else (), element date {if (exists($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate)) then element gmd:CI_Date {element date {element gco:Date {adjust-date-to-timezone(data($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate))}}, element dateType {element CI_DateTypeCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/moles:gmxCodelists.xml#CI_DateTypeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode_creation' }, 'Creation'}}}else attribute gco:nilReason {'unknown'}}}}, element abstract {element gco:CharacterString {data($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}}, element language {element gmd:LanguageCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English' }}, for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) return element topicCategory {element gmd:MD_TopicCategoryCode {attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}, attribute codeListValue {string($ISOTopicCategory/moles:dgValidTerm)}, string($ISOTopicCategory/moles:dgValidTerm)}}, if (exists($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage)) then element extent {element gmd:EX_Extent {(: add bounding boxes:) for $geoBBox in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox return element geographicElement {element EX_GeographicBoundingBox {element westBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitWest)}}, element eastBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitEast)}}, element southBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitSouth)}}, element northBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitNorth)}}}}, for $geoArea in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea return element geographicElement {element EX_GeographicDescription {element geographicIdentifier {element gmd:RS_Identifier {element gco:CharacterString {element code {data(dgArea/dgValidTerm)}}, element gco:CharacterString {element codeSpace {data(dgArea/dgValidTermID/ParentListID)}}}}}}}}else()}}}''' 
     1300             
     1301MOLESQuery = '''declare default element namespace 'http://ndg.nerc.ac.uk/moles';for $Moles in collection('TargetCollection')/dgMetadata/dgMetadataRecord[dgMetadataID/schemeIdentifier='NDG-B0' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID'] return $Moles ''' 
     1302             
    13011303DIFQuery = '''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    13021304import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
  • TI07-MOLES/trunk/PythonCode/wsgi/renderEntity.py

    r2118 r2260  
    2424        #       contentHTML='' 
    2525         
    26         if entity.metadataType is 'DC': 
     26        if entity.metadataType in ['DC','MDIP']: 
    2727            return entity.toHTML() 
    2828         
Note: See TracChangeset for help on using the changeset viewer.