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

DCAT formatter improvements #8642

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@

<xsl:if test="$isCopyingDatasetInfoToDistribution">
<!--
[mco:useConstraints]
RDF Property: dcterms:license
Definition: A legal document under which the distribution is made available.
Range: dcterms:LicenseDocument
Expand All @@ -359,17 +360,15 @@
for a Distribution of that Dataset SHOULD be avoided as this can create legal conflicts.
See also guidance at 9. License and rights statements.
-->
<xsl:apply-templates mode="iso19115-3-to-dcat"
select="ancestor::mdb:MD_Metadata/mdb:identificationInfo/*/mri:resourceConstraints/*[mco:useConstraints]"/>

<!--
RDF Property: dcterms:accessRights
Definition: A rights statement that concerns how the distribution is accessed.
Range: dcterms:RightsStatement
Usage note: Information about licenses and rights MAY be provided for the Distribution. See also guidance at 9. License and rights statements.
-->
[mco:accessConstraints]
RDF Property: dcterms:accessRights
Definition: A rights statement that concerns how the distribution is accessed.
Range: dcterms:RightsStatement
Usage note: Information about licenses and rights MAY be provided for the Distribution. See also guidance at 9. License and rights statements.
-->
<xsl:apply-templates mode="iso19115-3-to-dcat"
select="ancestor::mdb:MD_Metadata/mdb:identificationInfo/*/mri:resourceConstraints/*[mco:accessConstraints]"/>
select="ancestor::mdb:MD_Metadata/mdb:identificationInfo/*/mri:resourceConstraints/*"/>

<!--
RDF Property: dcterms:rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
|mdb:identificationInfo/*/mri:citation/*/cit:edition
|mdb:identificationInfo/*/mri:defaultLocale
|mdb:identificationInfo/*/mri:otherLocale
|mdb:identificationInfo/*/mri:resourceConstraints/*[mco:useConstraints]
|mdb:identificationInfo/*/mri:resourceConstraints/*[mco:accessConstraints]
|mdb:identificationInfo/*/mri:resourceConstraints/*
|mdb:identificationInfo/*/mri:status
|mdb:identificationInfo/*/mri:descriptiveKeywords
|mdb:identificationInfo/*/mri:pointOfContact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
as="node()"
select="(/root/mdb:MD_Metadata|/mdb:MD_Metadata|/root/gmd:MD_Metadata|/gmd:MD_Metadata)"/>

<!-- Extract languages from ISO19115.3-2018 mdb:MD_Metadata -->
<xsl:template mode="get-language"
match="mdb:MD_Metadata"
as="node()*">
Expand All @@ -80,6 +81,29 @@
</xsl:for-each>
</xsl:template>

<!-- Extract languages from ISO19139 gmd:MD_Metadata -->
<xsl:template mode="get-language"
match="gmd:MD_Metadata"
as="node()*">
<xsl:variable name="defaultLanguage"
select="$metadata/gmd:language"/>

<xsl:for-each select="$defaultLanguage">
<xsl:variable name="iso3code"
as="xs:string?"
select="gmd:LanguageCode/@codeListValue"/>
<language id="{util:twoCharLangCode($iso3code)}"
iso3code="{$iso3code}"
iso2code="{util:twoCharLangCode($iso3code)}"
default=""/>
</xsl:for-each>
<xsl:for-each select="$metadata/gmd:locale/*[not(@id = $defaultLanguage/@id)]">
<language id="{util:twoCharLangCode(gmd:languageCode/*/@codeListValue)}"
iso3code="{gmd:languageCode/*/@codeListValue}"
iso2code="{util:twoCharLangCode(gmd:languageCode/*/@codeListValue)}"/>
</xsl:for-each>
</xsl:template>

<xsl:variable name="languages"
as="node()*">
<xsl:apply-templates mode="get-language"
Expand Down Expand Up @@ -107,8 +131,9 @@
<!-- TODO: Should we consider DOI? It may be encoded in metadata linkage (not available in ISO19139) -->

<xsl:value-of select="if($metadataLinkage) then $metadataLinkage
else if($metadataIdentifier) then $metadataIdentifier
else concat($resourcePrefix, encode-for-uri($metadata/mdb:metadataIdentifier/*/mcc:code/*/text()))"
else if (string($metadataIdentifier) and starts-with($metadataIdentifier, 'http')) then $metadataIdentifier
else if (string($metadataIdentifier)) then concat($resourcePrefix, encode-for-uri($metadataIdentifier))
else concat($resourcePrefix, encode-for-uri($metadata/mdb:metadataIdentifier/*/mcc:code/*/text()))"
/>
</xsl:function>

Expand All @@ -125,7 +150,7 @@
select="($metadata/mdb:identificationInfo/*/mri:citation/*/cit:identifier)[1]"/>
</xsl:variable>

<xsl:value-of select="if($resourceIdentifier) then $resourceIdentifier
<xsl:value-of select="if(string($resourceIdentifier) and starts-with($resourceIdentifier, 'http')) then $resourceIdentifier
else concat($catalogRecordUri, '#resource')"
/>
</xsl:function>
Expand Down Expand Up @@ -247,6 +272,8 @@
|cit:identifier">
<xsl:variable name="code"
select="*/mcc:code/*/text()"/>
<xsl:variable name="codeAnchor"
select="*/mcc:code/*/@xlink:href"/>
<xsl:variable name="codeSpace"
select="*/mcc:codeSpace/*/text()"/>
<xsl:variable name="isUrn"
Expand All @@ -261,6 +288,7 @@
then concat($codeSpace,
(if (ends-with($codeSpace, $separator)) then '' else $separator),
$code)
else if ($codeAnchor) then $codeAnchor
else $code"/>

<xsl:variable name="codeType"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<xsl:if test="*/text() != ''">
<xsl:element name="{$nodeName}">
<xsl:attribute name="xml:lang" select="$languages[@default]/@iso3code"/>
<xsl:attribute name="xml:lang" select="$languages[@default]/@iso2code"/>
<xsl:value-of select="*/text()"/>
</xsl:element>
</xsl:if>
Expand All @@ -55,7 +55,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$nodeName}">
<xsl:attribute name="xml:lang" select="$languages[concat('#', @id) = $translationLanguage]/@iso3code"/>
<xsl:attribute name="xml:lang" select="$languages[concat('#', @id) = $translationLanguage]/@iso2code"/>
<xsl:value-of select="text()"/>
</xsl:element>
</xsl:otherwise>
Expand Down
Loading