API - Electronic legal deposits
Introduction
APIs related to electronic legal deposits at the National Library of Sweden
For more documentation on legal deposits, see: Metadatabyrån
Currently available APIs are:
- Validation of XML metadata
Validation of XML metadata
Quick start
Example with curl:
curl --header "Content-Type:text/xml" --data-binary @myrss.xml "https://api.eplikt.kb.se/validate?schema=WEB_ARTICLE_RSS"
myrss.xml is the metadata file to be validated, placed locally on your computer.
Usage
Validation service is available at:
https://api.eplikt.kb.se/validate?schema=SCHEMA_NAME
Available schemas are:
WEB_ARTICLE_RSSDocumentationFGS_METS: DocumentationDDEX_382: Currently no documentationDDEX_383: Currently no documentationDDEX_411: Currently no documentationDDEX_43: Currently no documentation
Response if validation succeeds
If the XML validates the response will be:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<validationResponse>
<resultcode>OK</resultcode>
</validationResponse>
Response if validation fails
If the XML does NOT validate, a message will be returned including relevant validation errors. We use schema and schematron validation.
Example - empty title
The RSS code used for this example is the example found here: Leverans via RSS (in swedish) but with the following errors:
- an empty <title> element
- a <pubdate> element with a missing + sign for date zone
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<validationResponse>
<resultcode>ERROR</resultcode>
<schemaValidationErrors>
<error>
<message>cvc-pattern-valid: Value 'Thu, 06 Jun 2024 08:00:22 0200' is not facet-valid with respect to pattern '(((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?\d\d? +((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +\d\d\d\d +\d\d:\d\d(:\d\d)? +(([+\-]\d\d\d\d)|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\w)' for type 'Rfc822FormatDate'.</message>
<location>Line 17 and column 62</location>
</error>
<error>
<message>cvc-type.3.1.3: The value 'Thu, 06 Jun 2024 08:00:22 0200' of element 'pubDate' is not valid.</message>
<location>Line 17 and column 62</location>
</error>
<error>
<message>cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'RestrictedString'.</message>
<location>Line 19 and column 28</location>
</error>
<error>
<message>cvc-type.3.1.3: The value '' of element 'title' is not valid.</message>
<location>Line 19 and column 28</location>
</error>
</schemaValidationErrors>
</validationResponse>
Please note that the response does not word wrap, sidescrolling is needed to read the full response.
Example - missing title element
The RSS code used for this example is the example found here: Leverans via RSS (in swedish) but with the following errors:
- missing <title> element
- ISBN with incorrect check digit
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<validationResponse>
<resultcode>ERROR</resultcode>
<schematronValidationErrors>
<svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:ern="http://ddex.net/xml/ern/341"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:kb="http://www.kb.se/identifiers/schematron/functions"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:saxon="http://saxon.sf.net/"
xmlns:schold="http://www.ascc.net/xml/schematron"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaVersion=""
title=""><!--
-->
<svrl:ns-prefix-in-attribute-values prefix="dcterms" uri="http://purl.org/dc/terms/"/>
<svrl:ns-prefix-in-attribute-values prefix="media" uri="http://search.yahoo.com/mrss/"/>
<svrl:ns-prefix-in-attribute-values prefix="mods" uri="http://www.loc.gov/mods/v3"/>
<svrl:ns-prefix-in-attribute-values prefix="dcterms" uri="http://purl.org/dc/terms/"/>
<svrl:ns-prefix-in-attribute-values prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance"/>
<svrl:ns-prefix-in-attribute-values prefix="kb" uri="http://www.kb.se/identifiers/schematron/functions"/>
<svrl:ns-prefix-in-attribute-values prefix="ern" uri="http://ddex.net/xml/ern/341"/>
<svrl:active-pattern document="" id="item_rules" name="item_rules"/>
<svrl:fired-rule context="item"/>
<svrl:failed-assert location="/rss[1]/channel[1]/item[1]" test="count(title) eq 1">
<svrl:text>An item should have one title element.</svrl:text>
</svrl:failed-assert>
<svrl:fired-rule context="item/link"/>
<svrl:fired-rule context="dcterms:publisher[not(@xsi:type)]"/>
<svrl:fired-rule context="item/media:content"/>
<svrl:fired-rule context="item/media:content"/>
<svrl:fired-rule context="item/media:content"/>
<svrl:ns-prefix-in-attribute-values prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance"/>
<svrl:ns-prefix-in-attribute-values prefix="mods" uri="http://www.loc.gov/mods/v3"/>
<svrl:ns-prefix-in-attribute-values prefix="dcterms" uri="http://purl.org/dc/terms/"/>
<svrl:ns-prefix-in-attribute-values prefix="ern" uri="http://ddex.net/xml/ern/341"/>
<svrl:ns-prefix-in-attribute-values prefix="kb" uri="http://www.kb.se/identifiers/schematron/functions"/>
<svrl:active-pattern document=""
id="primary_identifier_checks"
name="primary_identifier_checks"/>
<svrl:fired-rule context="dcterms:*[@xsi:type][kb:stripped-xsi-type(@xsi:type) = 'isbn'] | mods:identifier[@type='isbn']"/>
<svrl:failed-assert location="/rss[1]/channel[1]/item[1]/*:identifier[namespace-uri()='http://purl.org/dc/terms/'][1]"
test="if (string-length($stripISBN)= 13) then (if ($calculation13 ne 0) then (10 - $calculation13) else 0) eq $checksum13 else (if ($calculation10 ne 0) then (11 - $calculation10) else 0) eq number($checksum10)">
<svrl:text>Incorrect ISBN check digit</svrl:text>
</svrl:failed-assert>
<svrl:fired-rule context="mods:identifier[@type='urn'] | dcterms:*[@xsi:type][kb:stripped-xsi-type(@xsi:type) = 'urn']"
id="urn-identifier-rule"/>
<svrl:fired-rule context="dcterms:*[@xsi:type][kb:stripped-xsi-type(@xsi:type) = 'issn'] | mods:identifier[@type='issn']"/>
<svrl:fired-rule context="dcterms:*[@xsi:type][kb:stripped-xsi-type(@xsi:type) = 'isbn'] | mods:identifier[@type='isbn']"/>
<svrl:fired-rule context="dcterms:*[@xsi:type][kb:stripped-xsi-type(@xsi:type) = 'isbn'] | mods:identifier[@type='isbn']"/>
</svrl:schematron-output>
</schematronValidationErrors>
</validationResponse>