Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12] Extend mapping to spatial coverage #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 84 additions & 6 deletions transformations/abcd2bioschemas/abcd2bioschemas-xml.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,91 @@ exclude-result-prefixes="xsl md panxslt set">
</usageInfo>
</xsl:for-each>

<xsl:for-each select="$country[not(.=preceding::*)]">
<spatialCoverage type="Country">
<name><xsl:value-of select="."/></name>
<identifier><xsl:value-of select="../abcd:ISO3166Code"/></identifier>
</spatialCoverage>
<xsl:for-each select="/abcd:DataSets/abcd:DataSet/abcd:Units/abcd:Unit">
<xsl:variable name="unit_locality" select="./abcd:Gathering/abcd:LocalityText"></xsl:variable>
<xsl:variable name="unit_coordinates" select="./abcd:Gathering/abcd:SiteCoordinateSets/abcd:SiteCoordinates/abcd:CoordinatesLatLong"></xsl:variable>
<xsl:variable name="unit_latitude" select="./abcd:Gathering/abcd:SiteCoordinateSets/abcd:SiteCoordinates/abcd:CoordinatesLatLong/abcd:LatitudeDecimal"></xsl:variable>
<xsl:variable name="unit_longitude" select="./abcd:Gathering/abcd:SiteCoordinateSets/abcd:SiteCoordinates/abcd:CoordinatesLatLong/abcd:LongitudeDecimal"></xsl:variable>
<xsl:variable name="unit_spatial_datum" select="./abcd:Gathering/abcd:SiteCoordinateSets/abcd:SiteCoordinates/abcd:CoordinatesLatLong/abcd:SpatialDatum"></xsl:variable>
<xsl:variable name="unit_country" select="./abcd:Gathering/abcd:Country/abcd:Name"></xsl:variable>
<xsl:variable name="unit_named_areas" select="./abcd:Gathering/abcd:NamedAreas/abcd:NamedArea"></xsl:variable>

<xsl:for-each select="$unit_country[not(.=preceding::*)]">
<spatialCoverage type="Country">
<name><xsl:value-of select="."/></name>
<identifier><xsl:value-of select="../abcd:ISO3166Code"/></identifier>
</spatialCoverage>
</xsl:for-each>

<xsl:for-each select="$unit_locality">
<xsl:choose>
<xsl:variable name="preceding_latitude" select="preceding::*[self::abcd:CoordinatesLatLong][1]/abcd:LatitudeDecimal"></xsl:variable>
<xsl:variable name="preceding_longitude" select="preceding::*[self::abcd:CoordinatesLatLong][1]/abcd:LongitudeDecimal"></xsl:variable>
<xsl:when test="not(.=preceding::*)">
<spatialCoverage type="Place">
<name><xsl:value-of select="."/></name>
<description><xsl:value-of select="."/></description>
<xsl:if test="$unit_coordinates">
<geo type="GeoCoordinates">
<xsl:if test="$unit_latitude">
<latitude xsi:type="xs:double"><xsl:value-of select="$unit_latitude"/></latitude>
</xsl:if>
<xsl:if test="$unit_longitude">
<longitude xsi:type="xs:double"><xsl:value-of select="$unit_longitude"/></longitude>
</xsl:if>
<xsl:if test="$unit_spatial_datum">
<additionalType><xsl:value-of select="$unit_spatial_datum"/></additionalType>
</xsl:if>
</geo>
</xsl:if>
<xsl:if test="$unit_named_areas">
<xsl:for-each select="$unit_named_areas">
<containedInPlace type="Place">
<name><xsl:value-of select="."/></name>
<xsl:if test="./abcd:AreaClass">
<additionalType><xsl:value-of select="./abcd:AreaClass"/></additionalType>
</xsl:if>
</containedInPlace>
</xsl:for-each>
</xsl:if>
</spatialCoverage>
</xsl:when>
<xsl:otherwise>
<!-- TODO: Part below can be removed if its if-clause can be combined with the first one -->
<xsl:if test="not($preceding_latitude = $unit_latitude and $preceding_longitude = $unit_longitude)">
<spatialCoverage type="Place">
<name><xsl:value-of select="."/></name>
<description><xsl:value-of select="."/></description>
<xsl:if test="$unit_coordinates">
<geo type="GeoCoordinates">
<xsl:if test="$unit_latitude">
<latitude xsi:type="xs:double"><xsl:value-of select="$unit_latitude"/></latitude>
</xsl:if>
<xsl:if test="$unit_longitude">
<longitude xsi:type="xs:double"><xsl:value-of select="$unit_longitude"/></longitude>
</xsl:if>
<xsl:if test="$unit_spatial_datum">
<additionalType><xsl:value-of select="$unit_spatial_datum"/></additionalType>
</xsl:if>
</geo>
</xsl:if>
<xsl:if test="$unit_named_areas">
<xsl:for-each select="$unit_named_areas">
<containedInPlace type="Place">
<name><xsl:value-of select="."/></name>
<xsl:if test="./abcd:AreaClass">
<additionalType><xsl:value-of select="./abcd:AreaClass"/></additionalType>
</xsl:if>
</containedInPlace>
</xsl:for-each>
</xsl:if>
</spatialCoverage>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>

<!-- get bounding box coordinates or coordinate pair, if there is only one -->
<xsl:if test="$coordinates/abcd:LatitudeDecimal and $coordinates/abcd:LongitudeDecimal">
<spatialCoverage type="Place">
Expand Down