Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to use the EPSG Registry API to export a release of the registry for offline use but am receiving a registry error.

After following the Developer Guide I am HTTP POSTing the following XML request to the API URL:

<?xml version="1.0" encoding="UTF-8"?>
<GetRecords 
    xmlns="http://www.opengis.net/cat/csw" 
    xmlns:ogc="http://www.opengis.net/ogc" 
    startPosition="1" maxRecords="100" 
    outputFormat="application/xml; charset=UTF-8" 
    resultType="results">
  <!--  
    Retrieve the ReleaseObject releated to the current Version History record.
    Then use the ReleaseObject identifier to obtain the actual compressed 
    GML Dictionary file containing the EPSG Dataset via a getRepositoryItem 
    request.
  --> 
  <Query typeNames="Association=a RegistryObject=release">
    <ElementSetName typeNames="release">full</ElementSetName>
    <Constraint version="1.1.0">
      <ogc:Filter>
        <ogc:And>
          <!-- find the correct association --> 
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$a/targetObject</ogc:PropertyName>
            <ogc:Literal>urn:ogc:def:version-history:EPSG::6.15</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$a/associationType</ogc:PropertyName>
            <ogc:Literal>
              urn:x-ogp:def:AssociationType:EPSG:ReleaseFor</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <!-- now relate it to the ReleaseObject --> 
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$a/sourceObject</ogc:PropertyName>
            <ogc:PropertyName>$release/id</ogc:PropertyName>
          </ogc:PropertyIsEqualTo>
       </ogc:And>
      </ogc:Filter>
    </Constraint>
  </Query>
</GetRecords>

The XML is copied from section 5.3 'How To... Export a Release' of the guide, and the URL to send GetRecords requests to is suggested by section 4.1.1 'GetRecordById'. The XML error response I get is as follows:

<?xml version="1.0"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows" version="2.0">
  <ows:Exception exceptionCode="InvalidRequest">
    <ows:ExceptionText>XML Schema validation error</ows:ExceptionText>
    <ows:ExceptionText>
Error:Error
 Line:    2
 Column:  193
 Message: cvc-elt.1: Cannot find the declaration of element 'GetRecords'.
    </ows:ExceptionText>                                               
  </ows:Exception>
</ows:ExceptionReport>

I am using the curl command line program to run the query as follows:

curl -H 'Content-Type: appliation/xml' --data @request.xml 'http://www.epsg-registry.org/indicio/query'

Can you see where I'm going wrong? If not is there any other way to automatically download the registry? I am aware that I can login to the Registry HTML interface and download the registry from there but I would like to automate the process.

share|improve this question
add comment

2 Answers

It looks to me like the server is trying to validate your XML request, and failing to find the XSD that contains the definition of GetRecords.

I think the EPSG sample is outdated for that server, because changing the CSW namespace to http://www.opengis.net/cat/csw/2.0.2 gets me some more errors about the Query element. Annex C of the EPSG API spec tells us that it only supports CSW 2.0.1, but I've had no joy with that version either.

So I would read up on CSW 2.0.2 XML POST requests and reformulate your request to make it valid 2.0.2 and see what that turns up.

It is my experience of this sort of documentation that an example was written for one version and it worked, then they updated other parts of the documentation without regression testing the samples. For instance, I tried the GetRepositoryItem example, and in the docs it puts it all lower case, whereas the server only accepts CamelCase.

share|improve this answer
1  
Thanks @MerseyViking - updating the XML based on the latest CSW-ebRIM Registry Service spec proved to work. I'll upload the working methodology in a few hours when I'm allowed to self answer the question. –  Homme Zwaagstra Mar 9 '12 at 14:46
add comment
up vote 0 down vote accepted

Thanks to @MerseyViking for pointing me in the right direction: updating the XML based on the OGC document 'CSW-ebRIM Registry Service - Part 1: ebRIM profile of CSW' proved to be the answer.

Exporting the latest EPSG registry data comes in 3 steps:

1) Run a query to obtain the release id of the latest version:

<?xml version="1.0" encoding="UTF-8"?>
<GetRecords
    xmlns="http://www.opengis.net/cat/csw/2.0.2"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"
    xmlns:wrs="http://www.opengis.net/cat/wrs/1.0"
    startPosition="1"
    maxRecords="1"
    outputFormat="application/xml; charset=UTF-8"
    resultType="results"
    service="CSW-ebRIM"
    version="2.0.2">
  <!--
      Retrieve valid Version History records.
      Sort by the Version History Slot named 'VersionDate'; use Ascending order
      so that the last Version History record in the result list will represent
      the current version of the dataset.
  -->
  <Query typeNames="wrs:ExtrinsicObject_eo rim:Slot_versionDate">
    <ElementSetName typeNames="eo">brief</ElementSetName>
    <Constraint version="1.1.0">
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsLike wildCard="*" escapeChar="/" singleChar="?">
            <ogc:PropertyName>$eo/@id</ogc:PropertyName>
            <ogc:Literal>*:EPSG::*</ogc:Literal>
          </ogc:PropertyIsLike>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$eo/@objectType</ogc:PropertyName>
            <ogc:Literal>urn:x-ogp:def:ObjectType:EPSG:version-history</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$eo/@status</ogc:PropertyName>
            <ogc:Literal>urn:oasis:names:tc:ebxml-regrep:StatusType:Approved</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$eo/$versionDate/@name</ogc:PropertyName>
            <ogc:Literal>VersionDate</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:And>
      </ogc:Filter>
    </Constraint>
    <ogc:SortBy>
      <ogc:SortProperty>
        <ogc:PropertyName>$eo/$versionDate/ValueList/Value</ogc:PropertyName>
        <ogc:SortOrder>DESC</ogc:SortOrder>
      </ogc:SortProperty>
    </ogc:SortBy>
  </Query>
</GetRecords>

e.g. using curl after saving the above XML as version.xml:

curl -H 'Content-Type: appliation/xml' --data @version.xml 'http://www.epsg-registry.org/indicio/query'

2) Run a query to obtain the URL to download the release ID obtained:

<?xml version="1.0" encoding="UTF-8"?>
<GetRecords
    xmlns="http://www.opengis.net/cat/csw/2.0.2"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"
    xmlns:wrs="http://www.opengis.net/cat/wrs/1.0"
    startPosition="1"
    maxRecords="100"
    outputFormat="application/xml; charset=UTF-8"
    resultType="results"
    service="CSW-ebRIM"
    version="2.0.2">
  <!--
      Retrieve the ReleaseObject releated to the current Version History record.
      Then use the ReleaseObject identifier to obtain the actual compressed
      GML Dictionary file containing the EPSG Dataset via a getRepositoryItem
      request.
  -->
  <Query typeNames="rim:Association_a rim:RegistryObject_release">
    <ElementSetName typeNames="release">full</ElementSetName>
    <Constraint version="1.1.0">
      <ogc:Filter>
        <ogc:And>
          <!-- find the correct association -->
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$a/targetObject</ogc:PropertyName>
            <ogc:Literal>urn:ogc:def:version-history:EPSG::7.9.6</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$a/associationType</ogc:PropertyName>
            <ogc:Literal>urn:x-ogp:def:AssociationType:EPSG:ReleaseFor</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <!-- now relate it to the ReleaseObject -->
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>$a/sourceObject</ogc:PropertyName>
            <ogc:PropertyName>$release/id</ogc:PropertyName>
          </ogc:PropertyIsEqualTo>
        </ogc:And>
      </ogc:Filter>
    </Constraint>
  </Query>
</GetRecords>

e.g. using curl after saving the above XML as release.xml and inserting the release id obtained in step 1:

curl -H 'Content-Type: appliation/xml' --data @release.xml 'http://www.epsg-registry.org/indicio/query'

3) The release data can then be downloaded by following the url associated with the required format.

This process has been integrated in the python-epsg code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.