Ignore:
Timestamp:
12/02/07 11:16:11 (15 years ago)
Author:
ko23
Message:

Intermediate update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/MDIP/XQueries/MDIP2MOLES.xquery

    r2056 r2142  
    33(: dgPersons are not created as one can't tell automatically which are people and which are orgs, and orgs are simpler :)   
    44(: Not producing valid MOLES as still got to work out parameter vocabulary namespaces in the subject field :)   
     5import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     6import module namespace inputParse='http://ndg.nerc.ac.uk/xquery/lib/inputParse' at 'xmldb:exist:///db/xqueryLib/Utilities/inputParse_xquery_lib.xquery'; 
    57 
    68declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
     
    3840declare variable $ndg_data_provider_vocab as xs:string {'http://vocab.ndg.nerc.ac.uk/N010'}; 
    3941declare variable $ndg_vertical_extent_base as xs:string {'http://vocab.ndg.nerc.ac.uk/null'}; 
    40  
    41 declare function f:fix-coord($e as element()) as element()  
    42 (: Parse a non-decimal co-ordinate element,  parse to see if it's possible to convert to  
    43     a decimal co-ordinate, and do so, else return the rubbish provided :) 
    44 { 
    45 if ($e castable as xs:decimal) then   
    46         $e 
    47 else 
    48         let $value := substring(data($e), 1, string-length($e)-1) 
    49         let $point := lower-case(data($e)) 
    50         return 
    51         if ($value  castable as xs:decimal) then   
    52                 if (ends-with($point, 'n')) then 
    53                         element {name($e)} {$value}  
    54                 else if (ends-with($point, 's')) then 
    55                         element {name($e)} {concat('-', $value)}  
    56                 else if (ends-with($point, 'e')) then 
    57                         element {name($e)} {$value}  
    58                 else if (ends-with($point, 'w')) then 
    59                         element {name($e)} {concat('-', $value)}  
    60                 else $e 
    61         else  $e 
    62 } ; 
    63  
    64 declare function f:spot-vocab($vocab_root as xs:string, $vocab_uri as xs:string) as xs:boolean  
    65 (: See if the vocab pointed if from the vocab pointed at by the vocab_root :) 
    66 { 
    67 if ($vocab_root = substring($vocab_uri, 1, string-length($vocab_root))) then   
    68         true() 
    69 else 
    70         false() 
    71 } ; 
    7242 
    7343for $MDIP in collection($input_collection)/mdip:Metadata[mdip:DatasetIdentifier=$input_DatasetIdentifier] 
     
    130100                                                element dgSpatialCoverage { 
    131101                                                        element BoundingBox { 
    132                                                                 element LimitNorth {data(f:fix-coord($MDIP/mdip:NorthCoOrdinate))}, 
    133                                                                 element LimitSouth {data(f:fix-coord($MDIP/mdip:SouthCoOrdinate))}, 
    134                                                                 element LimitWest {data(f:fix-coord($MDIP/mdip:WestCoOrdinate))}, 
    135                                                                 element LimitEast {data(f:fix-coord($MDIP/mdip:EastCoOrdinate))} 
     102                                                        element LimitNorth {data(inputParse:fix-coord($MDIP/mdip:NorthCoOrdinate))}, 
     103                                                        element LimitSouth {data(inputParse:fix-coord($MDIP/mdip:SouthCoOrdinate))}, 
     104                                                        element LimitWest {data(inputParse:fix-coord($MDIP/mdip:WestCoOrdinate))}, 
     105                                                        element LimitEast {data(inputParse:fix-coord($MDIP/mdip:EastCoOrdinate))} 
    136106                                                        }, 
    137107                                                        for $location in $MDIP/mdip:Extent 
Note: See TracChangeset for help on using the changeset viewer.