Skip to content

Latest commit

 

History

History
140 lines (84 loc) · 6.87 KB

File metadata and controls

140 lines (84 loc) · 6.87 KB

How to use the XSLT

The XSLT can be run directly on the ouput of a CSW or on single metadata records, by using any of the programming languages supporting XSLT conversion.

The actual output of the XSLT depends on configuration parameters that specify:

  • whether to use the core or extended GeoDCAT-AP profile;
  • whether coupled resources should be looked up
  • whether deprecated mappings must or much not be included
  • which spatial reference system to use for the geometry encoding of the bounding box (when available).
  • The HTTP URIs to be used for the metadata record and/or the described resource.

The following sections describe first the XSLT configuration parameters, and then give some examples on how to run the XSLT.

Configuration parameters

Parameter $profile

This parameter specifies the GeoDCAT-AP profile to be used:

  • value core: the GeoDCAT-AP core profile, which includes only the INSPIRE / "core" ISO 19115 metadata elements supported in DCAT-AP.
  • value extended: the GeoDCAT-AP extended profile, which defines mappings for all the INSPIRE / "core" ISO 19115 metadata elements.

The default value is: extended.

The specifications for the core and extended GeoDCAT-AP profiles are available on the Joinup collaboration platform of the EU ISA Programme:

https://joinup.ec.europa.eu/solution/geodcat-ap

Parameter $CoupledResourceLookup

This parameter specifies whether the coupled resource, referenced via @xlink:href, should be looked up to fetch the resource's ID (i.e., code and the optional code space). More precisely:

  • value enabled: The coupled resource is looked up
  • value disabled: The coupled resource is not looked up

The default value is enabled for GeoDCAT-AP Extended, and disabled otherwise.

CAVEAT: Using this feature may cause the transformation to hang, in case the URL in @xlink:href is broken or does not return the expected resource (e.g., and HTML page, instead of an XML-encoded ISO 19139 record). It is strongly recommended that this issue is dealt with by using appropriate configuration parameters and error handling (e.g., by specifying a timeout on HTTP calls and by setting the HTTP Accept header to application/xml).

Parameter $include-deprecated

This parameter specifies whether deprecated mappings (following the release of GeoDCAT-AP 2.0.0) should be included or not in the output. More precisely:

  • value yes: Deprecated mappings are included in the output
  • value no: Deprecated mapping are not included in the output

The default value is yes.

CAVEAT: The reason of supporting the possibility of including deprecated mappings is to ensure backward compatibility with legacy systems not yet migrated to GeoDCAT-AP 2.0.0.

Parameters for the spatial reference system of the bounding box

These parameters denote the URI and URN, respectively, of the spatial reference system (SRS) used in the geometry encodings of the bounding box generated by the XSLT (WKT, GML, and GeoJSON). More precisely:

  • The SRS URI (parameter $SrsUri) is used in the WKT and GML encodings of the bounding box.
  • The SRS URN (parameter $SrsUrn) is used in the GeoJSON encoding of the bounding box.

The SRS URI's and URN's to be used are those operated by the OGC's registry:

The default SRS is CRS84 (WGS84 lon/lat). If a different SRS is used, the axis order (lat/lon or lon/lat) must be explicitly specified in parameter $SrsAxisOrder.

The possible values for parameter $SrsAxisOrder are the following:

  • LatLon: latitude / longitude.
  • LonLat: longitude / latitude.

As already mentioned, the axis order must be specified only if the reference SRS is different from CRS84. If the reference SRS is CRS84, the value specified in parameter $SrsAxisOrder is ignored.

Parameters $ResourceUri and $MetadataUri

These parameters must be customised depending on the strategy used to assign HTTP URIs.

The default rule implies that HTTP URIs are specified for the metadata file identifier (metadata URI) and the resource identifier (resource URI). For more details and examples, see the relevant XSLT documentation.

Running the XSLT

This section provides examples of code from popular programming languages that can be used to run the XSLT.

PHP

<?php

// The URL of the XML document to be transformed. Here it corresponds to a "GetRecords" output of a fictitious CSW, with the "maxRecords" parameter set to 10.
  $xmlURL = "http://some.site/csw?request=GetRecords&service=CSW&version=2.0.2&namespace=xmlns%28csw=http://www.opengis.net/cat/csw%29&resultType=results&outputSchema=http://www.isotc211.org/2005/gmd&outputFormat=application/xml&typeNames=csw:Record&elementSetName=full&constraintLanguage=CQL_TEXT&constraint_language_version=1.1.0&maxRecords=10";

// The URL pointing to the latest version of the XSLT.
  $xslURL = "https://raw.githubusercontent.com/SEMICeu/iso-19139-to-dcat-ap/master/iso-19139-to-dcat-ap.xsl";
  
  $xml = new DOMDocument;
  $xml->load($xmlURL) or die();

  $xsl = new DOMDocument;
  $xsl->load($xslURL) or die();
  
  $proc = new XSLTProcessor();
  $proc->importStyleSheet($xsl);
  
  echo $proc->transformToXML($xml);

?>

Python

import lxml.etree as ET
from urllib2 import urlopen

# The URL of the XML document to be transformed. Here it corresponds to a "GetRecords" output of a fictitious CSW, with the "maxRecords" parameter set to 10.
xmlURL = "http://some.site/csw?request=GetRecords&service=CSW&version=2.0.2&namespace=xmlns%28csw=http://www.opengis.net/cat/csw%29&resultType=results&outputSchema=http://www.isotc211.org/2005/gmd&outputFormat=application/xml&typeNames=csw:Record&elementSetName=full&constraintLanguage=CQL_TEXT&constraint_language_version=1.1.0&maxRecords=10"

# The URL pointing to the latest version of the XSLT.
xslURL = "https://raw.githubusercontent.com/SEMICeu/iso-19139-to-dcat-ap/master/iso-19139-to-dcat-ap.xsl"
  
xml = ET.parse(urlopen(xmlURL))
xsl = ET.parse(urlopen(xslURL))

transform = ET.XSLT(xsl)

print(ET.tostring(transform(xml), pretty_print=True))

Python: command line tool

A Python script that can be used as a command line tool has been contributed by @arbakker:

https://gist.github.com/arbakker/42f73421654b4d5f29211ead2ae0ab25/

Java

TBD