Ignore:
Timestamp:
09/05/07 16:23:59 (12 years ago)
Author:
ko23
Message:

Updated DIF queries

File:
1 edited

Legend:

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

    r2384 r2464  
    15221522declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    15231523declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
     1524 
    15241525declare variable $targetCollection as xs:string {'TargetCollection'}; 
    15251526declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    15261527declare variable $localIdentifier as xs:string {'LocalID'}; 
     1528 
    15271529for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    1528 exists('moles:dgDataEntity')  
    1529 and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'  
    1530 and moles:dgMetadataID/moles:repositoryIdentifier=$repositoryIdentifier 
    1531 and moles:dgMetadataID/moles:localIdentifier=$localIdentifier] 
    1532 return 
     1530    exists('moles:dgDataEntity')  
     1531    and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'  
     1532    and moles:dgMetadataID/moles:repositoryIdentifier=$repositoryIdentifier 
     1533    and moles:dgMetadataID/moles:localIdentifier=$localIdentifier] 
     1534    return 
    15331535element DIF { 
    1534 attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'}, 
    1535 element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, $utillib:moles_id_separator, 'DIF', $utillib:moles_id_separator, $DE/moles:dgMetadataID/moles:localIdentifier)}, 
    1536 element Entry_Title {string($DE/moles:name)}, 
    1537 element Data_Set_Citation { 
    1538 for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
    1539 return  
    1540 for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    1541 and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
    1542 and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
    1543 return  
    1544 element Dataset_Creator { 
    1545 if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then  
    1546 string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))) 
    1547 else  
    1548 string($DataCreatorRoleHolder/moles:abbreviation) 
    1549 }, 
    1550 element Dataset_Title {string($DE/moles:name)} 
    1551 }, 
    1552 for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgStdParameterMeasured)[(voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_categories, moles:dgValidTermID/moles:ParentListID))] 
    1553 ) 
    1554 return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then  
    1555 element Parameters { 
    1556 element Category {string($StructuredKeyword/*/moles:dgValidTerm)}, 
    1557 if (exists($StructuredKeyword//moles:dgValidSubterm)  
    1558 and $StructuredKeyword//moles:dgValidSubterm != ''  
    1559 and $StructuredKeyword//moles:dgValidSubterm != ' ') then  
    1560 for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] 
    1561 where exists($Subterm/moles:dgValidSubterm) 
    1562 order by $Subterm/moles:ListLevel 
    1563 return  
    1564 if ($Subterm/moles:ListLevel=1) then element Topic {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    1565 else if ($Subterm/moles:ListLevel=2) then element Term {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    1566 else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    1567 else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    1568 else element GCMD_Science_Valid {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
    1569 else() 
    1570 } 
    1571 else(), 
    1572 for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_deprecated, moles:dgValidTermID/moles:ParentListID) and (not(exists(moles:ListLevel)) or moles:ListLevel=0)]) 
    1573 return 
    1574 element Parameters {data($StructuredKeyword/moles:dgValidTerm)}, 
    1575 for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID)]) 
    1576 return  
    1577 element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, 
    1578 for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ 
    1579 not (voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID) 
    1580 or voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) 
    1581 or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) 
    1582 )]/moles:dgValidTerm) 
    1583 return element Keyword {string($Keyword)},  
    1584 for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID)  
    1585 return  
    1586 element Sensor_Name { 
    1587 for $DepDPTAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation)) 
    1588 return element Short_Name {data($DepDPTAbbrev)}, 
    1589 for $DepDPTName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name)) 
    1590 return element Long_Name {data($DepDPTName)} 
    1591 }, 
    1592 for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) 
    1593 return  
    1594 element Source_Name { 
    1595 for $DepObsStnAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation)) 
    1596 return element Short_Name {data($DepObsStnAbbrev)}, 
    1597 for $DepObsStnName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name)) 
    1598 return element Long_Name {data($DepObsStnName)} 
    1599 }, 
    1600 for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:DateRange) 
    1601 return  
    1602 element Temporal_Coverage 
    1603 { 
    1604 element Start_Date {data($TemporalRange/moles:DateRangeStart)}, 
    1605 element End_Date {data($TemporalRange/moles:DateRangeEnd)} 
    1606 }, 
    1607 for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_chronostratigraphic_valids, moles:dgValidTermID/moles:ParentListID)]/moles:dgValidTerm) 
    1608 return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},  
    1609 for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) 
    1610 return element Data_Set_Progress {data($Data_Set_Progress)}, 
    1611 for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) 
    1612 return  
    1613 element Spatial_Coverage { 
    1614 element Southernmost_Latitude {data($BoundingBox/moles:LimitSouth)}, 
    1615 element Northernmost_Latitude {data($BoundingBox/moles:LimitNorth)}, 
    1616 element Westernmost_Longitude {data($BoundingBox/moles:LimitWest)}, 
    1617 element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)} 
    1618 }, 
    1619 for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_location_valids, moles:dgValidTermID/moles:ParentListID)]) 
    1620 return element Location {data($Location/moles:dgValidTerm)},  
    1621 for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) 
    1622 return  
    1623 element Project { 
    1624 for $DepActAbbrev in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:abbreviation) 
    1625 return  
    1626 element Short_Name {data($DepActAbbrev)}, 
    1627 for $DepActName in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:name) 
    1628 return  
    1629 element Long_Name {data($DepActName)} 
    1630 }, 
    1631 if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then  
    1632 for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule 
    1633 return  
    1634 element Access_Constraints { 
    1635 if (exists($DG/moles:dgGranuleSummary/moles:dgGranuleName)) then  
    1636 concat('For data granule ', $DG/moles:dgGranuleSummary/moles:dgGranuleName, ': ') 
    1637 else (), 
    1638 if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyURL)) then 
    1639 concat('See access control policy at ', escape-uri($DG/moles:accessControlPolicy/moles:accessControlPolicyURL, true())) 
    1640 else if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyText)) then 
    1641 data($DG/moles:accessControlPolicy/moles:accessControlPolicyText) 
    1642 else  
    1643 for $securityCondition in $DG/moles:accessControlPolicy/moles:dgSecurityCondition 
    1644 return 
    1645 if (exists($securityCondition/moles:conditionExplanationText)) then 
    1646 concat('Effect: ', data($securityCondition/moles:effect), ' - ', data($securityCondition/moles:conditionExplanationText)) 
    1647 else concat('Effect: ', data($securityCondition/moles:effect), 'needs ', data($securityCondition/moles:attauthRole), ' from ', data($securityCondition/moles:dgAttributeAuthority)) 
    1648 } 
    1649 else (), 
    1650 if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder)) then 
    1651 for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder  
    1652 order by $DataCreatorRole/moles:startDate empty least 
    1653 return  
    1654 for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
    1655 [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    1656 and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
    1657 and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
    1658 return  
    1659 element Originating_Center { 
    1660 if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then 
    1661 (string($DataCreatorRoleHolder/moles:name)) 
    1662 else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then 
    1663 (string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName)))) 
    1664 else ('empty content') 
    1665 } 
    1666 else (), 
    1667 for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder 
    1668 [not(exists(moles:endDate)) or moles:endDate='']  
    1669 return  
    1670 for $DataCuratorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
    1671 [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    1672 and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier 
    1673 and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)] 
    1674 return  
    1675 element Data_Center { 
    1676 element Data_Center_Name { 
    1677 element Short_Name { 
    1678 if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
    1679 string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) 
    1680 else  
    1681 string($DataCuratorRoleHolder/moles:abbreviation) 
    1682 }, 
    1683 element Long_Name { 
    1684 if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
    1685 string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) 
    1686 else string($DataCuratorRoleHolder/moles:name) 
    1687 } 
    1688 }, 
    1689 if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:URI)) then  
    1690 element Data_Center_URL {data($DataCuratorRoleHolder/moles:contactDetails/moles:URI)} 
    1691 else (), 
    1692 for $DGID in $DE/moles:dgDataEntity/moles:dgDataGranule/moles:dataModelID 
    1693 return  
    1694 element Data_Set_ID {concat($DGID/moles:repositoryIdentifier, $utillib:moles_id_separator, $DGID/moles:schemeIdentifier, $utillib:moles_id_separator, $DGID/moles:localIdentifier)}, 
    1695 element Personnel { 
    1696 element Role {'Data Center Contact'}, 
    1697 if (exists($DataCuratorRoleHolder/name/knownAs)) then  
    1698 element First_Name {string($DataCuratorRoleHolder/moles:name/moles:knownAs)} 
    1699 else if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
    1700 element First_Name {string($DataCuratorRoleHolder/moles:name/moles:initials)} 
    1701 else (), 
    1702 element Last_Name { 
    1703 if (exists($DataCuratorRoleHolder/moles:name/moles:familyName)) then  
    1704 string($DataCuratorRoleHolder/moles:name/moles:familyName) 
    1705 else string($DataCuratorRoleHolder/moles:name) 
    1706 }, 
    1707 if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then  
    1708 element Email {string($DataCuratorRole/moles:contactDetails/moles:eMail)} 
    1709 else  
    1710 if (exists($DataCuratorRoleHolder/contactDetails/eMail)) then  
    1711 (element Email {string($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}) 
    1712 else (), 
    1713 if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then  
    1714 element Phone {string($DataCuratorRole/moles:contactDetails/moles:telephone)} 
    1715 else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then  
    1716 element Phone {string($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)} 
    1717 else (), 
    1718 if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then  
    1719 element Fax {string($DataCuratorRole/moles:contactDetails/moles:fax)} 
    1720 else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then  
    1721 element Fax {string($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} 
    1722 else (), 
    1723 if (exists($DataCuratorRole/moles:contactDetails/moles:address)) then  
    1724 element Contact_Address { 
    1725 for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline 
    1726 return element Address {data($addressline)}, 
    1727 if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then  
    1728 element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)} 
    1729 else (), 
    1730 if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)) then  
    1731 element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)} 
    1732 else (), 
    1733 if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:country)) then  
    1734 element Country {string($DataCuratorRole/moles:contactDetails/moles:address/moles:country)} 
    1735 else () 
    1736 } 
    1737 else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address)) then  
    1738 element Contact_Address { 
    1739 for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline 
    1740 return element Address {data($addressline)}, 
    1741 if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then  
    1742 element City {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)} 
    1743 else (), 
    1744 if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then  
    1745 element Postal_Code {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)} 
    1746 else (), 
    1747 if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)) then  
    1748 element Country {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)} 
    1749 else () 
    1750 } 
    1751 else () 
    1752 } 
    1753 }, 
    1754 element Summary {string($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}, 
    1755 for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule 
    1756 return 
    1757 if ($DG/moles:dataModelID/moles:schemeIdentifier='NDG-A0') then  
    1758 (element Related_URL { 
    1759 element URL_Content_Type {'NDG_A_SERVICE'}, 
    1760 if (exists($DG/instance/URI)) then 
    1761 element URL {escape-uri($DG/instance/URI, true())} 
    1762 else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
    1763 element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&datasetID=', true())} 
    1764 else ($DG/moles:dataModelID/moles:repositoryIdentifier), 
    1765 element Description {'The NDG service delivering data via NDG A metadata.'} 
    1766 }, 
    1767 element Related_URL { 
    1768 element URL_Content_Type {'GET DATA > CSML'}, 
    1769 if (exists($DG/instance)) then 
    1770 element URL {escape-uri($DG/instance/URI, true())} 
    1771 else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
    1772 element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&datasetID=', true())} 
    1773 else (), 
    1774 element Description {'The NDG service delivering data via NDG A metadata. Additional tag to be more in line with latest version of GCMD valids'} 
    1775 }) 
    1776 else if ($DG/moles:dataModelID/moles:schemeIdentifier='CDML-0') then  
    1777 (element Related_URL {  
    1778 element URL_Content_Type {'NDG_A_SERVICE'}, 
    1779 if (exists($DG/instance)) then 
    1780 element URL {escape-uri($DG/instance/URI, true())} 
    1781 else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
    1782 element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} 
    1783 else (), 
    1784 element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} 
    1785 }, 
    1786 element Related_URL { 
    1787 element URL_Content_Type {'GET DATA > DX'}, 
    1788 if (exists($DG/instance)) then 
    1789 element URL {escape-uri($DG/instance/URI, true())} 
    1790 else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
    1791 element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} 
    1792 else (), 
    1793 element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} 
    1794 }) 
    1795 else if ($DG/moles:dataModelID/moles:schemeIdentifier='URI') then  
    1796 element Related_URL { 
    1797 element URL {data($DG/moles:instance/moles:URI)}, 
    1798 if (exists($DG/moles:instance/moles:instanceComment)) then  
    1799 element Description {data($DG/moles:instance/moles:instanceComment)} 
    1800 else  
    1801 element Description {'URL to aid in delivering data. Note that this may point directly to the data or, more likely, point to the web site of the curator.'} 
    1802 } 
    1803 else (), 
    1804 for $RelURL_Desc in ($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference)  
    1805 return 
    1806 if (exists($RelURL_Desc/moles:dgSimpleLink)) then 
    1807 element Related_URL { 
    1808 element URL {data($RelURL_Desc/moles:dgSimpleLink/URI)}, 
    1809 element Description {concat(data($RelURL_Desc/dgSimpleLink/moles:name), ' - ', data($RelURL_Desc/dgSimpleLink/moles:notes))} 
    1810 } 
    1811 else (), 
    1812 element Metadata_Name {'[CEOS IDN DIF]'}, 
    1813 element Metadata_Version {'9.4'}, 
    1814 if (exists($DE/moles:dgMetadataProvenance/moles:RecordCreation)) then  
    1815 element DIF_Creation_Date {data($DE/moles:dgMetadataProvenance/moles:RecordCreation/moles:CreatedDate)} 
    1816 else (), 
    1817 for $MDUpdt in $DE/moles:dgMetadataProvenance/moles:RecordUpdate 
    1818 return  
    1819 element DIF_Revision_History {concat(data($MDUpdt/moles:UpdateDate), ' - ', data($MDUpdt/moles:UpdateSummary), ' - ', data($MDUpdt/moles:UpdatedBy))}, 
    1820 if (exists($DE/moles:dgMetadataProvenance/moles:RecordReview)) then  
    1821 element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)} 
    1822 else () 
    1823 }''' 
     1536    attribute xsi:schemaLocation {'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.4.xsd'}, 
     1537    element Entry_ID {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, $utillib:moles_id_separator, 'DIF', $utillib:moles_id_separator, $DE/moles:dgMetadataID/moles:localIdentifier)}, 
     1538    element Entry_Title {string($DE/moles:name)}, 
     1539    element Data_Set_Citation { 
     1540            for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
     1541        return  
     1542            for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     1543                   and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
     1544                   and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
     1545            return  
     1546                    element Dataset_Creator { 
     1547                if (exists($DataCreatorRoleHolder/moles:name/moles:initials)) then  
     1548                    string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName))) 
     1549                else  
     1550                   string($DataCreatorRoleHolder/moles:abbreviation) 
     1551                    }, 
     1552        element Dataset_Title {string($DE/moles:name)} 
     1553    }, 
     1554    for $StructuredKeyword in ($DE/(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[(voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_categories, moles:dgValidTermID/moles:ParentListID))] 
     1555    ) 
     1556        return if (exists($StructuredKeyword/*/moles:dgValidTerm)) then  
     1557            element Parameters { 
     1558            element Category {string($StructuredKeyword/*/moles:dgValidTerm)}, 
     1559            if (exists($StructuredKeyword//moles:dgValidSubterm)  
     1560                and $StructuredKeyword//moles:dgValidSubterm != ''  
     1561                and $StructuredKeyword//moles:dgValidSubterm != ' ') then  
     1562            for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] 
     1563                where exists($Subterm/moles:dgValidSubterm) 
     1564                order by $Subterm/moles:ListLevel 
     1565                return  
     1566                    if ($Subterm/moles:ListLevel=1) then element Topic {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     1567                    else if ($Subterm/moles:ListLevel=2) then element Term {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     1568                    else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     1569                    else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
     1570                    else element GCMD_Science_Valid {$Subterm/moles:ListLevel,($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
     1571            else() 
     1572                } 
     1573        else(), 
     1574    for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_deprecated, moles:dgValidTermID/moles:ParentListID) and (not(exists(moles:ListLevel)) or moles:ListLevel=0)]) 
     1575    return 
     1576        element Parameters {data($StructuredKeyword/moles:dgValidTerm)}, 
     1577    for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID)]) 
     1578        return  
     1579            element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, 
     1580    for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ 
     1581    not (voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID) 
     1582    or voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) 
     1583    or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) 
     1584    )]/moles:dgValidTerm) 
     1585    return element Keyword {string($Keyword)},  
     1586    for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID)  
     1587    return  
     1588        element Sensor_Name { 
     1589            for $DepDPTAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation)) 
     1590                return element Short_Name {data($DepDPTAbbrev)}, 
     1591            for $DepDPTName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name)) 
     1592                return element Long_Name {data($DepDPTName)} 
     1593            }, 
     1594    for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) 
     1595    return  
     1596        element Source_Name { 
     1597            for $DepObsStnAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation)) 
     1598                return element Short_Name {data($DepObsStnAbbrev)}, 
     1599            for $DepObsStnName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name)) 
     1600                return element Long_Name {data($DepObsStnName)} 
     1601            }, 
     1602    for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:DateRange) 
     1603        return  
     1604            element Temporal_Coverage 
     1605                { 
     1606                element Start_Date {data($TemporalRange/moles:DateRangeStart)}, 
     1607                element End_Date {data($TemporalRange/moles:DateRangeEnd)} 
     1608                }, 
     1609    for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_chronostratigraphic_valids, moles:dgValidTermID/moles:ParentListID)]/moles:dgValidTerm) 
     1610        return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},  
     1611    for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) 
     1612        return element Data_Set_Progress {data($Data_Set_Progress)}, 
     1613    for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) 
     1614    return  
     1615        element Spatial_Coverage { 
     1616                element Southernmost_Latitude {data($BoundingBox/moles:LimitSouth)}, 
     1617                element Northernmost_Latitude {data($BoundingBox/moles:LimitNorth)}, 
     1618                element Westernmost_Longitude {data($BoundingBox/moles:LimitWest)}, 
     1619                element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)} 
     1620            }, 
     1621    for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_location_valids, moles:dgValidTermID/moles:ParentListID)]) 
     1622        return element Location {data($Location/moles:dgValidTerm)},  
     1623    for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) 
     1624    return  
     1625        element Project { 
     1626            for $DepActAbbrev in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:abbreviation) 
     1627                return  
     1628                    element Short_Name {data($DepActAbbrev)}, 
     1629            for $DepActName in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:name) 
     1630                return  
     1631                    element Long_Name {data($DepActName)} 
     1632            }, 
     1633    if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then  
     1634            for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule 
     1635                return  
     1636                                element Access_Constraints { 
     1637                            if (exists($DG/moles:dgGranuleSummary/moles:dgGranuleName)) then  
     1638                                concat('For data granule ', $DG/moles:dgGranuleSummary/moles:dgGranuleName, ': ') 
     1639                            else (), 
     1640                            if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyURL)) then 
     1641                                concat('See access control policy at ', escape-uri($DG/moles:accessControlPolicy/moles:accessControlPolicyURL, true())) 
     1642                            else if (exists($DG/moles:accessControlPolicy/moles:accessControlPolicyText)) then 
     1643                                data($DG/moles:accessControlPolicy/moles:accessControlPolicyText) 
     1644                             else  
     1645                                 for $securityCondition in $DG/moles:accessControlPolicy/moles:dgSecurityCondition 
     1646                                 return 
     1647                                     if (exists($securityCondition/moles:conditionExplanationText)) then 
     1648                                         concat('Effect: ', data($securityCondition/moles:effect), ' - ', data($securityCondition/moles:conditionExplanationText)) 
     1649                                     else concat('Effect: ', data($securityCondition/moles:effect), 'needs ', data($securityCondition/moles:attauthRole), ' from ', data($securityCondition/moles:dgAttributeAuthority)) 
     1650                        } 
     1651                else (), 
     1652    if (exists($DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder)) then 
     1653        for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder  
     1654            order by $DataCreatorRole/moles:startDate empty least 
     1655                        return  
     1656                    for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
     1657                                        [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     1658                                        and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
     1659                                        and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
     1660                    return  
     1661                            element Originating_Center { 
     1662                    if (string(local-name($DataCreatorRoleHolder))='dgOrganisation') then 
     1663                        (string($DataCreatorRoleHolder/moles:name)) 
     1664                    else if (string(local-name($DataCreatorRoleHolder))='dgPerson') then 
     1665                        (string(concat(string($DataCreatorRoleHolder/moles:name/moles:initials), ' ', string($DataCreatorRoleHolder/moles:name/moles:familyName)))) 
     1666                    else ('empty content') 
     1667                } 
     1668    else (), 
     1669    for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder 
     1670    [not(exists(moles:endDate)) or moles:endDate='']  
     1671    return  
     1672    for $DataCuratorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgOrganisation | moles:dgPerson) 
     1673    [(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
     1674    and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/*/moles:repositoryIdentifier 
     1675    and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/*/moles:localIdentifier)] 
     1676    return  
     1677    element Data_Center { 
     1678    element Data_Center_Name { 
     1679    element Short_Name { 
     1680    if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
     1681    string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) 
     1682    else  
     1683    string($DataCuratorRoleHolder/moles:abbreviation) 
     1684    }, 
     1685    element Long_Name { 
     1686    if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
     1687    string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName))) 
     1688    else string($DataCuratorRoleHolder/moles:name) 
     1689    } 
     1690    }, 
     1691    if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:URI)) then  
     1692    element Data_Center_URL {data($DataCuratorRoleHolder/moles:contactDetails/moles:URI)} 
     1693    else (), 
     1694    for $DGID in $DE/moles:dgDataEntity/moles:dgDataGranule/moles:dataModelID 
     1695    return  
     1696    element Data_Set_ID {concat($DGID/moles:repositoryIdentifier, $utillib:moles_id_separator, $DGID/moles:schemeIdentifier, $utillib:moles_id_separator, $DGID/moles:localIdentifier)}, 
     1697    element Personnel { 
     1698    element Role {'Data Center Contact'}, 
     1699    if (exists($DataCuratorRoleHolder/name/knownAs)) then  
     1700    element First_Name {string($DataCuratorRoleHolder/moles:name/moles:knownAs)} 
     1701    else if (exists($DataCuratorRoleHolder/moles:name/moles:initials)) then  
     1702    element First_Name {string($DataCuratorRoleHolder/moles:name/moles:initials)} 
     1703    else (),                     
     1704    element Last_Name { 
     1705    if (exists($DataCuratorRoleHolder/moles:name/moles:familyName)) then  
     1706    string($DataCuratorRoleHolder/moles:name/moles:familyName) 
     1707    else string($DataCuratorRoleHolder/moles:name) 
     1708    }, 
     1709    if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then  
     1710    element Email {string($DataCuratorRole/moles:contactDetails/moles:eMail)} 
     1711    else  
     1712    if (exists($DataCuratorRoleHolder/contactDetails/eMail)) then  
     1713    (element Email {string($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}) 
     1714    else (), 
     1715    if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then  
     1716    element Phone {string($DataCuratorRole/moles:contactDetails/moles:telephone)} 
     1717    else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then  
     1718    element Phone {string($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)} 
     1719    else (), 
     1720    if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then  
     1721    element Fax {string($DataCuratorRole/moles:contactDetails/moles:fax)} 
     1722    else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then  
     1723    element Fax {string($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} 
     1724    else (), 
     1725    if (exists($DataCuratorRole/moles:contactDetails/moles:address)) then  
     1726    element Contact_Address { 
     1727    for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline 
     1728    return element Address {data($addressline)}, 
     1729    if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then  
     1730    element City {string($DataCuratorRole/moles:contactDetails/moles:address/moles:city)} 
     1731    else (), 
     1732    if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)) then  
     1733    element Postal_Code {string($DataCuratorRole/moles:contactDetails/moles:address/moles:postcode)} 
     1734    else (), 
     1735    if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:country)) then  
     1736    element Country {string($DataCuratorRole/moles:contactDetails/moles:address/moles:country)} 
     1737    else () 
     1738    } 
     1739    else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address)) then  
     1740    element Contact_Address { 
     1741    for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline 
     1742    return element Address {data($addressline)}, 
     1743    if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then  
     1744    element City {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)} 
     1745    else (), 
     1746    if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then  
     1747    element Postal_Code {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)} 
     1748    else (), 
     1749    if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)) then  
     1750    element Country {string($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:country)} 
     1751    else () 
     1752    } 
     1753    else () 
     1754    } 
     1755    }, 
     1756    element Summary {string($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}, 
     1757    for $DG in $DE/moles:dgDataEntity/moles:dgDataGranule 
     1758        return 
     1759            if ($DG/moles:dataModelID/moles:schemeIdentifier='NDG-A0') then  
     1760                       (element Related_URL { 
     1761                               element URL_Content_Type {'NDG_A_SERVICE'}, 
     1762                               if (exists($DG/instance/URI)) then 
     1763                                   element URL {escape-uri($DG/instance/URI, true())} 
     1764                               else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     1765                                   element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&datasetID=', true())} 
     1766                               else ($DG/moles:dataModelID/moles:repositoryIdentifier), 
     1767                             element Description {'The NDG service delivering data via NDG A metadata.'} 
     1768                           }, 
     1769                      element Related_URL { 
     1770                               element URL_Content_Type {'GET DATA > CSML'}, 
     1771                               if (exists($DG/instance)) then 
     1772                                   element URL {escape-uri($DG/instance/URI, true())} 
     1773                               else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     1774                                   element URL {escape-uri('http://dmgdev1.esc.rl.ac.uk/cgi-bin/ndgDataAccess?datasetSource=dmgdev1.esc.rl.ac.uk&datasetID=', true())} 
     1775                               else (), 
     1776                             element Description {'The NDG service delivering data via NDG A metadata. Additional tag to be more in line with latest version of GCMD valids'} 
     1777                           }) 
     1778            else if ($DG/moles:dataModelID/moles:schemeIdentifier='CDML-0') then  
     1779                           (element Related_URL {  
     1780                                   element URL_Content_Type {'NDG_A_SERVICE'}, 
     1781                               if (exists($DG/instance)) then 
     1782                                   element URL {escape-uri($DG/instance/URI, true())} 
     1783                               else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     1784                                   element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} 
     1785                               else (), 
     1786                             element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} 
     1787                               }, 
     1788                           element Related_URL { 
     1789                               element URL_Content_Type {'GET DATA > DX'}, 
     1790                               if (exists($DG/instance)) then 
     1791                                   element URL {escape-uri($DG/instance/URI, true())} 
     1792                               else if ($DG/moles:dataModelID/moles:repositoryIdentifier='badc.nerc.ac.uk') then 
     1793                                   element URL {escape-uri('http://cdat.badc.nerc.ac.uk/cgi-bin/dxui.py?datasetURI_1=/', true())} 
     1794                               else (), 
     1795                             element Description {'The NDG service delivering data via Data extractor. Additional tag to be more in line with latest version of GCMD valids'} 
     1796                               }) 
     1797            else if ($DG/moles:dataModelID/moles:schemeIdentifier='URI') then  
     1798                       element Related_URL { 
     1799                             element URL {data($DG/moles:instance/moles:URI)}, 
     1800                             if (exists($DG/moles:instance/moles:instanceComment)) then  
     1801                                     element Description {data($DG/moles:instance/moles:instanceComment)}            
     1802                             else  
     1803                                     element Description {'URL to aid in delivering data. Note that this may point directly to the data or, more likely, point to the web site of the curator.'} 
     1804                          } 
     1805        else (), 
     1806        for $RelURL_Desc in ($DE/moles:dgMetadataDescription/moles:descriptionSection/moles:descriptionOnlineReference)  
     1807        return 
     1808                       if (exists($RelURL_Desc/moles:dgSimpleLink)) then 
     1809                       element Related_URL { 
     1810                       element URL {data($RelURL_Desc/moles:dgSimpleLink/URI)}, 
     1811                       element Description {concat(data($RelURL_Desc/dgSimpleLink/moles:name), ' - ', data($RelURL_Desc/dgSimpleLink/moles:notes))} 
     1812                       } 
     1813                       else (), 
     1814    element Metadata_Name {'[CEOS IDN DIF]'}, 
     1815    element Metadata_Version {'9.4'}, 
     1816    if (exists($DE/moles:dgMetadataProvenance/moles:RecordCreation)) then  
     1817            element DIF_Creation_Date {data($DE/moles:dgMetadataProvenance/moles:RecordCreation/moles:CreatedDate)} 
     1818    else (), 
     1819    for $MDUpdt in $DE/moles:dgMetadataProvenance/moles:RecordUpdate 
     1820    return  
     1821        element DIF_Revision_History {concat(data($MDUpdt/moles:UpdateDate), ' - ', data($MDUpdt/moles:UpdateSummary), ' - ', data($MDUpdt/moles:UpdatedBy))}, 
     1822    if (exists($DE/moles:dgMetadataProvenance/moles:RecordReview)) then  
     1823            element Future_DIF_Review_Date {data($DE/moles:dgMetadataProvenance/moles:RecordReview/moles:ReviewDate)} 
     1824    else () 
     1825        }''' 
    18241826         
    18251827DublinCoreDEQuery='''import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
Note: See TracChangeset for help on using the changeset viewer.