Skip to content

Commit

Permalink
[#12] Add doublet check for locality & coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed Jul 18, 2024
1 parent b0d4e1b commit 656f34f
Showing 1 changed file with 62 additions and 28 deletions.
90 changes: 62 additions & 28 deletions transformations/abcd2bioschemas/abcd2bioschemas-xml.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ exclude-result-prefixes="xsl md panxslt set">
<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_altitude" select="./abcd:Gathering/abcd:Altitude"></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>

Expand All @@ -151,37 +150,72 @@ exclude-result-prefixes="xsl md panxslt set">
</spatialCoverage>
</xsl:for-each>

<xsl:for-each select="$unit_locality[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: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_altitude">
<elevation xsi:type="xs:double"><xsl:value-of select="$unit_altitude"/></elevation>
<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>
</geo>
</xsl:if>
<xsl:if test="$unit_named_areas">
<xsl:for-each select="$unit_named_areas">
<containedInPlace type="Place">
</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>
<xsl:if test="./abcd:AreaClass">
<additionalType><xsl:value-of select="./abcd:AreaClass"/></additionalType>
<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>
</containedInPlace>
</xsl:for-each>
</xsl:if>
</spatialCoverage>
<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>

Expand Down

0 comments on commit 656f34f

Please sign in to comment.