-
-
Notifications
You must be signed in to change notification settings - Fork 156
Geoportal FGDC
Tom Kralidis edited this page May 2, 2013
·
2 revisions
fgdc_GetRecords_Request.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:element name="csw:GetRecords" use-attribute-sets="GetRecordsAttributes" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:gml="http://www.opengis.net/gml" xmlns:fgdc="http://www.opengis.net/cat/csw/csdgm">
<csw:Query typeNames="csw:Record">
<csw:ElementSetName>full</csw:ElementSetName>
<csw:Constraint version="1.0.0">
<ogc:Filter>
<ogc:And>
<xsl:apply-templates select="/GetRecords/KeyWord"/>
<xsl:apply-templates select="/GetRecords/LiveDataMap"/>
<!--<xsl:apply-templates select="/GetRecords/Envelope"/>-->
<xsl:call-template name="tmpltEnvelope"/>
<xsl:call-template name="tmpltDate"/>
</ogc:And>
</ogc:Filter>
</csw:Constraint>
</csw:Query>
</xsl:element>
</xsl:template>
<xsl:template match="/GetRecords/KeyWord" xmlns:ogc="http://www.opengis.net/ogc">
<xsl:if test="normalize-space(.)!=''">
<ogc:PropertyIsLike wildCard="*" escapeChar="\" singleChar=".">
<ogc:PropertyName>csw:AnyText</ogc:PropertyName>
<ogc:Literal>*<xsl:value-of select="."/>*</ogc:Literal>
</ogc:PropertyIsLike>
</xsl:if>
</xsl:template>
<xsl:template match="/GetRecords/LiveDataMap" xmlns:ogc="http://www.opengis.net/ogc">
<xsl:if test="translate(normalize-space(./text()),'true', 'TRUE') ='TRUE'">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>dc:format</ogc:PropertyName>
<ogc:Literal>liveData</ogc:Literal>
</ogc:PropertyIsEqualTo>
</xsl:if>
</xsl:template>
<xsl:template name="tmpltEnvelope" xmlns:ogc="http://www.opengis.net/ogc">
<xsl:choose>
<xsl:when test="/GetRecords/Envelope">
<xsl:if test="/GetRecords/Envelope/MinX and /GetRecords/Envelope/MinY and /GetRecords/Envelope/MaxX and /GetRecords/Envelope/MaxY">
<ogc:BBOX xmlns:gml="http://www.opengis.net/gml">
<ogc:PropertyName>ows:BoundingBox</ogc:PropertyName>
<gml:Envelope>
<gml:lowerCorner><xsl:value-of select="/GetRecords/Envelope/MinY"/><xsl:text> </xsl:text><xsl:value-of select="/GetRecords/Envelope/MinX"/></gml:lowerCorner>
<gml:upperCorner><xsl:value-of select="/GetRecords/Envelope/MaxY"/><xsl:text> </xsl:text><xsl:value-of select="/GetRecords/Envelope/MaxX"/></gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<ogc:BBOX xmlns:gml="http://www.opengis.net/gml">
<ogc:PropertyName>ows:BoundingBox</ogc:PropertyName>
<gml:Envelope>
<gml:lowerCorner><xsl:text>-90 -180</xsl:text></gml:lowerCorner>
<gml:upperCorner><xsl:text>90 180</xsl:text></gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="tmpltDate" xmlns:ogc="http://www.opengis.net/ogc">
<xsl:if test="string-length(normalize-space(/GetRecords/FromDate/text())) > 0">
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>dct:modified</ogc:PropertyName>
<ogc:Literal><xsl:value-of select="normalize-space(/GetRecords/FromDate/text())"/></ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
</xsl:if>
<xsl:if test="string-length(normalize-space(/GetRecords/ToDate/text())) > 0">
<ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyName>dct:modified</ogc:PropertyName>
<ogc:Literal><xsl:value-of select="normalize-space(/GetRecords/ToDate/text())"/></ogc:Literal>
</ogc:PropertyIsLessThanOrEqualTo>
</xsl:if>
</xsl:template>
<xsl:attribute-set name="GetRecordsAttributes">
<xsl:attribute name="version">2.0.2</xsl:attribute>
<xsl:attribute name="service">CSW</xsl:attribute>
<xsl:attribute name="resultType">results</xsl:attribute>
<xsl:attribute name="startPosition"><xsl:value-of select="/GetRecords/StartPosition"/></xsl:attribute>
<xsl:attribute name="maxRecords"><xsl:value-of select="/GetRecords/MaxRecords"/></xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>
fgdc_GetRecords_Response.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:dct="http://purl.org/dc/terms/" xmlns:ows="http://www.opengis.net/ows" xmlns:dc="http://purl.org/dc/elements/1.1/" exclude-result-prefixes="csw dc dct ows">
<xsl:output method="xml" indent="no" encoding="UTF-8" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/ows:ExceptionReport">
<exception>
<exceptionText>
<xsl:for-each select="/ows:ExceptionReport/ows:Exception">
<xsl:value-of select="ows:ExceptionText"/>
</xsl:for-each>
</exceptionText>
</exception>
</xsl:when>
<xsl:otherwise>
<Records>
<xsl:attribute name="maxRecords"><xsl:value-of select="/csw:GetRecordsResponse/csw:SearchResults/@numberOfRecordsMatched"/></xsl:attribute>
<xsl:for-each select="/csw:GetRecordsResponse/csw:SearchResults/csw:Record | /csw:GetRecordsResponse/csw:SearchResults/csw:BriefRecord | /csw:GetRecordByIdResponse/csw:Record | /csw:GetRecordsResponse/csw:SearchResults/csw:SummaryRecord">
<Record>
<ID>
<xsl:choose>
<xsl:when test="string-length(normalize-space(dc:identifier[@scheme='urn:x-esri:specification:ServiceType:ArcIMS:Metadata:DocID']/text())) > 0">
<xsl:value-of select="normalize-space(dc:identifier[@scheme='urn:x-esri:specification:ServiceType:ArcIMS:Metadata:DocID'])"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(dc:identifier)"/>
</xsl:otherwise>
</xsl:choose>
</ID>
<Title><xsl:value-of select="dc:title"/></Title>
<Abstract><xsl:value-of select="dct:abstract"/></Abstract>
<Type><xsl:value-of select="dc:type"/></Type>
<LowerCorner><xsl:value-of select="ows:BoundingBox/ows:LowerCorner"/></LowerCorner>
<UpperCorner><xsl:value-of select="ows:BoundingBox/ows:UpperCorner"/></UpperCorner>
<MaxX><xsl:value-of select="normalize-space(substring-after(ows:BoundingBox/ows:UpperCorner, ' '))"/></MaxX>
<MaxY><xsl:value-of select="normalize-space(substring-before(ows:BoundingBox/ows:UpperCorner, ' '))"/></MaxY>
<MinX><xsl:value-of select="normalize-space(substring-after(ows:BoundingBox/ows:LowerCorner, ' '))"/></MinX>
<MinY><xsl:value-of select="normalize-space(substring-before(ows:BoundingBox/ows:LowerCorner, ' '))"/></MinY>
<ModifiedDate><xsl:value-of select="./dct:modified"/></ModifiedDate>
<References>
<xsl:for-each select="./dct:references">
<xsl:value-of select="."/>
<xsl:text>✔</xsl:text>
<xsl:value-of select="@scheme"/>
<xsl:text>✕</xsl:text>
</xsl:for-each>
</References>
<Types>
<xsl:for-each select="./dc:type">
<xsl:value-of select="."/>
<xsl:text>✔</xsl:text>
<xsl:value-of select="@scheme"/>
<xsl:text>✕</xsl:text>
</xsl:for-each>
</Types>
</Record>
</xsl:for-each>
</Records>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
fgdc_GetRecordByID_Response.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:dct="http://purl.org/dc/terms/" xmlns:ows="http://www.opengis.net/ows" exclude-result-prefixes="csw dct">
<xsl:output method="text" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/ows:ExceptionReport">
<exception>
<exceptionText>
<xsl:for-each select="/ows:ExceptionReport/ows:Exception">
<xsl:value-of select="ows:ExceptionText"/>
</xsl:for-each>
</exceptionText>
</exception>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//csw:Record/dct:references"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="//csw:Record/dct:references">
<xsl:value-of select="."/>
<xsl:text>✔</xsl:text>
<xsl:value-of select="@scheme"/>
<xsl:text>✕</xsl:text>
</xsl:template>
</xsl:stylesheet>
CSWProfiles.xml
<Profile>
<ID>urn:ogc:CSW:2.0.2:HTTP:FGDC</ID>
<Name>FGDC CSDGM Application Profile for CSW 2.0</Name>
<CswNamespace>http://www.opengis.net/cat/csw/2.0.2</CswNamespace>
<Description/>
<GetRecords>
<XSLTransformations>
<Request>fgdc_GetRecords_Request.xslt</Request>
<Response>fgdc_GetRecords_Response.xslt</Response>
</XSLTransformations>
</GetRecords>
<GetRecordByID>
<RequestKVPs><![CDATA[service=CSW&request=GetRecordById&version=2.0.2&ElementSetName=full]]></RequestKVPs>
<XSLTransformations>
<Response>fgdc_GetRecordByID_Response.xslt</Response>
</XSLTransformations>
</GetRecordByID>
<SupportSpatialQuery>True</SupportSpatialQuery>
<SupportContentTypeQuery>True</SupportContentTypeQuery>
<SupportSpatialBoundary>True</SupportSpatialBoundary>
</Profile>