WCSCapabilities to ebXML
From Omar Wiki
Contents |
Mapping WCS Capabilities to ebXML
We need a quick way to map a Web Coverage Service capabilities document (and it associated DescribeCoverage) into ebXML so that we can register the metadata with Omar. The easiest way (IMHO) is to use a stylesheet to perform this task, and in particular to use a trick with the XSLT document() function to call the describe coverage operation in each of the CoverageOffering briefs in the capabilitites document. This stylesheet call can only be executed once since it generates UUIDs for the user, data etc., updates should be performed using the SOAP, REST, and GUI interfaces to Omar.
Java Implementation
If you are using Java then the following command line will pull the URL and process the document if executed from omar.home\misc\samples\extDB\ogc directory
java -cp ..\..\..\lib\xalan.jar;..\..\..\lib\xercesImpl.jar;..\..\..\lib\xml-apis.jar org.apache.xalan.xslt.Process -XSL ebxml_wcs.xsl -IN "http://maps.gdal.org/cgi-bin/mapserv_dem?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCapabilities" -OUT gdal_wcs.xml
change the url to http://iceds.ge.ucl.ac.uk/cgi-bin/icedswcs?SERVICE=WCS&REQUEST=GetCapabilities&VERSION=1.0.0 for ICEDS (and the output document to iceds_wcs.xml
Ingestion
Edit omar.home/buildExtDB.xml and add the following ant task
<target name="loadOGCWCS">
<echo message="Loading metadata about OGC ICEDS WCS Service as RegistryOperator"/>
<soapSender req="${build.samples}/extDB/ogc/iceds_wcs.xml"/>
<echo message="Loading metadata about OGC GDAL (FrankW) WCS Service as RegistryOperator"/>
<soapSender req="${build.samples}/extDB/ogc/gdal_wcs.xml"/>
</target>
executing omar.home/build loadOGCWCS will ingest the ebXML document into Omar.
Stylesheet
The stylesheet is as below
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" xmlns:wcs="http://www.opengis.net/wcs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:java="http://xml.apache.org/xalan/java" xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" exclude-result-prefixes="java rim">
<xsl:output method="xml"/>
<xsl:variable name="userId" select="concat('urn:uuid:', java:java.util.UUID.randomUUID())"/>
<xsl:variable name="orgId" select="concat('urn:uuid:', java:java.util.UUID.randomUUID())"/>
<xsl:variable name="serviceId" select="concat('urn:x-ogc:specification:csw-ebrim:Service:OGC-CSW:ebRIM:', */wcs:Service/wcs:name)"/>
<xsl:variable name="describeCoverageURL" select="wcs:WCS_Capabilities/wcs:Capability/wcs:Request/wcs:DescribeCoverage/*/*/wcs:Get/wcs:OnlineResource/@xlink:href"/>
<xsl:template match="@*|node()">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="/">
<SubmitObjectsRequest xmlns="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0" xmlns:gml="http://www.opengis.net/gml" xmlns:lcm="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0" xmlns:query="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:rs="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0
http://www.oasis-open.org/committees/regrep/documents/3.0/schema/lcm.xsd">
<rs:RequestSlotList>
<rim:Slot name="urn:oasis:names:tc:ebxml-regrep:rim:RegistryObject:dontVersion">
<rim:ValueList>
<rim:Value>true</rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Slot name="urn:oasis:names:tc:ebxml-regrep:rim:RegistryObject:dontVersionContent">
<rim:ValueList>
<rim:Value>true</rim:Value>
</rim:ValueList>
</rim:Slot>
</rs:RequestSlotList>
<rim:RegistryObjectList>
<xsl:apply-templates select="@*|node()"/>
</rim:RegistryObjectList>
</SubmitObjectsRequest>
</xsl:template>
<xsl:template match="wcs:Service">
<xsl:variable name="wcsName" select="wcs:name"/>
<xsl:variable name="wcsLabel" select="wcs:label"/>
<xsl:variable name="homeURI" select="wcs:responsibleParty/wcs:contactInfo/wcs:onlineResource/@xlink:href"/>
<rim:Service id="{$serviceId}" objectType="urn:x-ogc:specification:csw-ebrim:Service:OGC-WCS">
<rim:Slot name="OnlineResource">
<rim:ValueList>
<rim:Value><xsl:value-of select="$homeURI"/></rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Slot name="http://purl.org/dc/elements/1.1/subject">
<rim:ValueList>
<xsl:for-each select="wcs:keywords/wcs:keyword">
<rim:Value><xsl:value-of select="."/></rim:Value>
</xsl:for-each>
</rim:ValueList>
</rim:Slot>
<rim:Slot name="Fees">
<rim:ValueList>
<rim:Value><xsl:value-of select="wcs:fees"/></rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Slot name="AccessConstraints">
<rim:ValueList>
<rim:Value><xsl:value-of select="wcs:accessConstraints"/></rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Name>
<rim:LocalizedString xml:lang="en-US" value="{$wcsName}"/>
</rim:Name>
<rim:Description>
<rim:LocalizedString xml:lang="en-US" value="{$wcsLabel}"/>
</rim:Description>
<rim:Classification id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}" classificationNode="urn:x-ogc:specification:csw-ebrim:Service:OGC-WCS" classifiedObject="{$serviceId}">
<rim:Name>
<rim:LocalizedString value="{$wcsName}" xml:lang="en-US"/>
</rim:Name>
</rim:Classification>
<rim:ServiceBinding id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}"
home="{$homeURI}" status="Approved"
service="{$serviceId}"
accessURI="{../wcs:Capability/wcs:Request/wcs:GetCapabilities/*/*/wcs:Get/wcs:OnlineResource/@xlink:href}">
<rim:Slot name="outputFormat">
<rim:ValueList>
<rim:Value>text/xml</rim:Value>
<rim:Value>application/vnd.ogc.se_xml</rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Name>
<rim:LocalizedString xml:lang="en-US" value="GetCapabilities"/>
</rim:Name>
</rim:ServiceBinding>
<rim:ServiceBinding id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}"
home="{$homeURI}" status="Approved"
service="{$serviceId}"
accessURI="{../wcs:Capability/wcs:Request/wcs:DescribeCoverage/*/*/wcs:Get/wcs:OnlineResource/@xlink:href}">
<rim:Slot name="outputFormat">
<rim:ValueList>
<rim:Value>text/xml</rim:Value>
<rim:Value>application/vnd.ogc.se_xml</rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Name>
<rim:LocalizedString xml:lang="en-US" value="DescribeCoverage"/>
</rim:Name>
</rim:ServiceBinding>
<rim:ServiceBinding id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}"
home="{$homeURI}" status="Approved"
service="{$serviceId}"
accessURI="{../wcs:Capability/wcs:Request/wcs:GetCoverage/*/*/wcs:Get/wcs:OnlineResource/@xlink:href}">
<rim:Name>
<rim:LocalizedString xml:lang="en-US" value="GetCoverage"/>
</rim:Name>
</rim:ServiceBinding>
</rim:Service>
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="wcs:responsibleParty">
<xsl:variable name="country" select="wcs:contactInfo/wcs:address/wcs:country"/>
<xsl:variable name="officePhone">
<xsl:call-template name="do-replace">
<xsl:with-param name="text" select="wcs:contactInfo/wcs:phone/wcs:voice"/>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="by" select=""/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="officeFax">
<xsl:call-template name="do-replace">
<xsl:with-param name="text" select="wcs:contactInfo/wcs:phone/wcs:facsimile"/>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="by" select=""/>
</xsl:call-template>
</xsl:variable>
<rim:User id="{$userId}">
<rim:Name>
<rim:LocalizedString value="{wcs:individualName}" charset="UTF-8" xml:lang="en-US"/>
</rim:Name>
<rim:Description/>
<rim:Address streetNumber="" street="{wcs:contactInfo/wcs:address/wcs:deliveryPoint}" postalCode="{wcs:contactInfo/wcs:address/wcs:postalCode}" city="{wcs:contactInfo/wcs:address/wcs:city}" stateOrProvince="" country="{$country}"/>
<rim:PersonName middleName="" lastName="" firstName=""/>
<rim:TelephoneNumber number="{$officePhone}" countryCode="{$country}" phoneType="OfficePhone"/>
<rim:TelephoneNumber number="{$officeFax}" countryCode="{$country}" phoneType="FAX"/>
<rim:EmailAddress address="{wcs:contactInfo/wcs:address/wcs:electronicMailAddress}"/>
</rim:User>
<rim:Organization id="{$orgId}" primaryContact="{$userId}">
<rim:Name>
<rim:LocalizedString value="{wcs:organisationName}" xml:lang="en-US"/>
</rim:Name>
<rim:Address streetNumber="" street="{wcs:contactInfo/wcs:address/wcs:deliveryPoint}" postalCode="{wcs:contactInfo/wcs:address/wcs:postalCode}" city="{wcs:contactInfo/wcs:address/wcs:city}" stateOrProvince="" country="{$country}"/>
<rim:TelephoneNumber number="{$officePhone}" countryCode="{$country}" phoneType="OfficePhone"/>
<rim:TelephoneNumber number="{$officeFax}" countryCode="{$country}" phoneType="FAX"/>
</rim:Organization>
<rim:Association associationType="urn:oasis:names:tc:ebxml-regrep:AssociationType:OffersService" id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}" targetObject="{$serviceId}" sourceObject="{$orgId}"/>
<rim:Association associationType="urn:oasis:names:tc:ebxml-regrep:AssociationType:AffiliatedWith" id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}" targetObject="{$orgId}" sourceObject="{$userId}" />
</xsl:template>
<xsl:template match="wcs:CoverageOffering" mode="DescribeCoverage">
<xsl:variable name="covId" select="concat('urn:uuid:', java:java.util.UUID.randomUUID())"/>
<xsl:variable name="minxy">
<xsl:call-template name="do-replace">
<xsl:with-param name="text">
<xsl:value-of select="wcs:lonLatEnvelope/gml:pos[1]"/>
</xsl:with-param>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="by" select="','"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="maxxy">
<xsl:call-template name="do-replace">
<xsl:with-param name="text">
<xsl:value-of select="wcs:lonLatEnvelope/gml:pos[2]"/>
</xsl:with-param>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="by" select="','"/>
</xsl:call-template>
</xsl:variable>
<rim:ExtrinsicObject id="{$covId}" objectType="urn:x-ogc:specification:csw-ebrim:ObjectType:Dataset">
<rim:Slot name="http://purl.org/dc/elements/1.1/subject">
<rim:ValueList>
<xsl:for-each select="wcs:keywords/wcs:keyword">
<rim:Value><xsl:value-of select="."/></rim:Value>
</xsl:for-each>
</rim:ValueList>
</rim:Slot>
<rim:Slot name="http://www.opengis.net/gml/Envelope" slotType="gml:EnvelopeType">
<rim:ValueList>
<rim:Value><xsl:value-of select="concat($minxy, ' ', $maxxy)"/></rim:Value>
</rim:ValueList>
</rim:Slot>
<rim:Slot name="outputFormat">
<rim:ValueList>
<xsl:for-each select="str:split(wcs:supportedFormats/wcs:formats)">
<rim:Value><xsl:value-of select="."/></rim:Value>
</xsl:for-each>
</rim:ValueList>
</rim:Slot>
<rim:Name>
<rim:LocalizedString xml:lang="en-US" value="{wcs:name}"/>
</rim:Name>
<rim:Description>
<rim:LocalizedString xml:lang="en-US" value="{wcs:label}"/>
</rim:Description>
</rim:ExtrinsicObject>
<rim:Association id="{concat('urn:uuid:', java:java.util.UUID.randomUUID())}" associationType="urn:x-ogc:specification:csw-ebrim:AssociationType:OperatesOn" sourceObject="{$serviceId}" targetObject="{$covId}"/>
</xsl:template>
<xsl:template match="wcs:CoverageOfferingBrief">
<xsl:variable name="coverageName" select="wcs:name"/>
<xsl:apply-templates mode="DescribeCoverage" select="document(concat($describeCoverageURL, 'REQUEST=DESCRIBECOVERAGE&SERVICE=WCS&VERSION=1.0.0&COVERAGE=', $coverageName))"/>
</xsl:template>
<xsl:template name="do-replace">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="by"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:copy-of select="substring-before($text,$replace)"/>
<xsl:copy-of select="$by"/>
<xsl:call-template name="do-replace">
<xsl:with-param name="text">
<xsl:copy-of select="substring-after($text,$replace)"/>
</xsl:with-param>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="by"><xsl:copy-of select="$by"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
