Ignore:
Timestamp:
01/05/08 14:28:47 (11 years ago)
Author:
cbyrom
Message:

Various updates to the xquery files - to remove usage of invalid specs
and dependency on obsolete function calls. Also add the inputParse_xquery_lib.xquery
file - referenced from the xquery files but not currently included in codebase.
NB, changes made to allow use of Saxon java library to do xqueries - to
remove the need for the discovery service eXist DB.

  • NB, also changes tested by comparing saxon transforms to eXist ones; these

were found to be identical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/xquery/dif2moles.xq

    r3151 r3841  
    77(: Note algoritm for creating non-pre-existing organisations :) 
    88(: dgPersons are not created as one can't tell automatically which are people and which are orgs, and orgs are simpler :)   
     9 
    910import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    1011import module namespace inputParse='http://ndg.nerc.ac.uk/xquery/lib/inputParse' at 'xmldb:exist:///db/xqueryLib/Utilities/inputParse_xquery_lib.xquery'; 
     12 
    1113declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
    1214declare namespace dif='http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
    1315declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    1416 
    15 (: Keep as an example, but note the entryID in the dif is an 
    16    NDG format ID, so the example isn't as obvious .... 
    17 declare variable $targetCollection as xs:string {'/db/discovery/original/ndg.noc.soton.ac.uk'}; 
    18 declare variable $input_repository as xs:string {'ndg.noc.soton.ac.uk'}; 
    19 declare variable $input_repository_local as xs:string {'nocs'}; 
    20 declare variable $input_entry_id as xs:string {'ndg.noc.soton.ac.uk__DIF__NOCSDAT110'}; 
    21 declare variable $output_local_id as xs:string {'NOCS_DAT110'}; 
    22 :) 
    2317(: Replacable parameters :) 
    24 declare variable $targetCollection as xs:string {'TargetCollection'}; 
    25 declare variable $input_repository as xs:string {'RepositoryID'}; 
    26 declare variable $input_repository_local as xs:string {'repository_localid'}; 
    27 declare variable $input_entry_id as xs:string {'Input_Entry_ID'}; 
    28 declare variable $output_local_id as xs:string {'LocalID'}; 
     18declare variable $targetCollection as xs:string := 'TargetCollection'; 
     19declare variable $input_repository as xs:string := 'RepositoryID'; 
     20declare variable $input_repository_local as xs:string := 'repository_localid'; 
     21declare variable $input_entry_id as xs:string := 'Input_Entry_ID'; 
     22declare variable $output_local_id as xs:string := 'LocalID'; 
    2923 
    3024for $DIF in collection($targetCollection)/dif:DIF[dif:Entry_ID=$input_entry_id] 
     
    4741element localIdentifier {concat('generated_desc-', $output_local_id)} 
    4842else 
    49 element localIdentifier {concat('generated_desc-', escape-uri(string($DIF/dif:Entry_ID), true()))} 
     43element localIdentifier {concat('generated_desc-', encode-for-uri(string($DIF/dif:Entry_ID)))} 
    5044}, 
    5145element metadataDescriptionLastUpdated {current-date()}                 , 
     
    5852element descriptionSection { 
    5953element descriptionOnlineReference { 
    60 element dgSimpleLink {escape-uri(data($descOnline/dif:URL), true())}}, 
     54element dgSimpleLink {encode-for-uri(data($descOnline/dif:URL))}}, 
    6155if (exists($descOnline/dif:URL_Content_Type)) then  
    6256element dgReferenceName {data($descOnline/dif:URL_Content_Type)} 
     
    7973element dgValidTermID { 
    8074element ParentListID {$voclib:unknown_vocab_id}, 
    81 element TermID {escape-uri('dummy unit', true())} 
     75element TermID {encode-for-uri('dummy unit')} 
    8276} 
    8377} 
     
    8983element dgValidTermID { 
    9084element ParentListID {concat($voclib:gcmd_science_valids_categories, '/current')}, 
    91 element TermID {escape-uri($parameter/dif:Category, true())} 
     85element TermID {encode-for-uri($parameter/dif:Category)} 
    9286}, 
    9387element dgValidSubterm { 
     
    9690element dgValidTermID { 
    9791element ParentListID {concat($voclib:gcmd_science_valids_topics, '/current')}, 
    98 element TermID {escape-uri($parameter/dif:Topic, true())} 
     92element TermID {encode-for-uri($parameter/dif:Topic)} 
    9993}, 
    10094element dgValidSubterm { 
     
    10397element dgValidTermID { 
    10498element ParentListID {concat($voclib:gcmd_science_valids_terms, '/current')}, 
    105 element TermID {escape-uri($parameter/dif:Term, true())} 
     99element TermID {encode-for-uri($parameter/dif:Term)} 
    106100}, 
    107101if (exists($parameter/dif:Variable) and $parameter/dif:Variable!='') then 
     
    110104element dgValidTermID { 
    111105element ParentListID {concat($voclib:gcmd_science_valids_variables, '/current')}, 
    112 element TermID {escape-uri($parameter/dif:Variable, true())} 
     106element TermID {encode-for-uri($parameter/dif:Variable)} 
    113107}, 
    114108if (exists($parameter/dif:Detailed_Variable) and $parameter/dif:Detailed_Variable!='') then 
     
    117111element dgValidTermID { 
    118112element ParentListID {$voclib:unknown_vocab_id}, 
    119 element TermID {escape-uri($parameter/dif:Detailed_Variable, true())} 
     113element TermID {encode-for-uri($parameter/dif:Detailed_Variable)} 
    120114}, 
    121115element ListLevel {4}} 
     
    170164element dgValidTermID { 
    171165element ParentListID {concat($voclib:gcmd_location_valids, '/current')}, 
    172 element TermID {escape-uri($location, true())} 
     166element TermID {encode-for-uri($location)} 
    173167} 
    174168} 
     
    195189element dgValidTermID { 
    196190element ParentListID {concat($voclib:gcmd_chronostratigraphic_valids, '/current')}, 
    197 element TermID {escape-uri($chronostratigraphic, true())} 
     191element TermID {encode-for-uri($chronostratigraphic)} 
    198192} 
    199193} 
     
    212206element localIdentifier {concat('generated_creator-', $output_local_id)} 
    213207else 
    214 element localIdentifier {concat('generated_creator-', escape-uri(string($DIF/dif:Entry_ID), true()))} 
     208element localIdentifier {concat('generated_creator-', encode-for-uri(string($DIF/dif:Entry_ID)))} 
    215209}, 
    216210element roleName {'Data Creator'}, 
     
    223217element repositoryIdentifier {$input_repository}, 
    224218if ($output_local_id != 'Output_LocalID') then 
    225 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id), true())} 
    226 else 
    227 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), true())} 
     219element localIdentifier  {encode-for-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id))} 
     220else 
     221element localIdentifier  {encode-for-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)))} 
    228222}, 
    229223element startDate {current-date()} 
     
    236230element repositoryIdentifier {$input_repository}, 
    237231if ($output_local_id != 'Output_LocalID') then 
    238 element localIdentifier  {escape-uri(concat('generated_creator-', $output_local_id), true())} 
    239 else 
    240 element localIdentifier  {escape-uri(concat('generated_creator-', data($DIF/dif:Entry_ID)), true())} 
     232element localIdentifier  {encode-for-uri(concat('generated_creator-', $output_local_id))} 
     233else 
     234element localIdentifier  {encode-for-uri(concat('generated_creator-', data($DIF/dif:Entry_ID)))} 
    241235}, 
    242236element roleName {'Data Creator'}, 
     
    249243element repositoryIdentifier {$input_repository}, 
    250244if ($output_local_id != 'Output_LocalID') then 
    251 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id), true())} 
    252 else 
    253 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)), true())} 
     245element localIdentifier  {encode-for-uri(concat('generated_orgcit-', string($creatorID), '-', $output_local_id))} 
     246else 
     247element localIdentifier  {encode-for-uri(concat('generated_orgcit-', string($creatorID), '-', data($DIF/dif:Entry_ID)))} 
    254248}, 
    255249element startDate {current-date()} 
     
    262256element repositoryIdentifier {$input_repository}, 
    263257if ($output_local_id != 'Output_LocalID') then 
    264 element localIdentifier  {escape-uri(concat('generated_curator-', $output_local_id), true())} 
    265 else 
    266 element localIdentifier  {escape-uri(concat('generated_curator-', data($DIF/dif:Entry_ID)), true())} 
     258element localIdentifier  {encode-for-uri(concat('generated_curator-', $output_local_id))} 
     259else 
     260element localIdentifier  {encode-for-uri(concat('generated_curator-', data($DIF/dif:Entry_ID)))} 
    267261}, 
    268262element roleName {'Data Curator'}, 
     
    296290element ParentListID {$voclib:unknown_vocab_id} 
    297291, 
    298 element TermID {escape-uri($structuredKeywords, true())} 
     292element TermID {encode-for-uri($structuredKeywords)} 
    299293} 
    300294}, 
     
    305299element dgValidTermID { 
    306300element ParentListID {concat($voclib:iso_topic_list, '/current')}, 
    307 element TermID {escape-uri($structuredKeywords, true())} 
     301element TermID {encode-for-uri($structuredKeywords)} 
    308302} 
    309303}, 
     
    344338element repositoryIdentifier {$input_repository}, 
    345339if ($output_local_id != 'Output_LocalID') then 
    346 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creator), '-', $output_local_id), true())} 
    347 else 
    348 element localIdentifier  {escape-uri(concat('generated_orgcit-', string($creator), '-', data($DIF/dif:Entry_ID)), true())} 
     340element localIdentifier  {encode-for-uri(concat('generated_orgcit-', string($creator), '-', $output_local_id))} 
     341else 
     342element localIdentifier  {encode-for-uri(concat('generated_orgcit-', string($creator), '-', data($DIF/dif:Entry_ID)))} 
    349343}, 
    350344element name {string($creator)}, 
Note: See TracChangeset for help on using the changeset viewer.