From 21f13cdb522cb8ed4cb2c9f23d5caa6050978f00 Mon Sep 17 00:00:00 2001 From: David Maus <maus@hab.de> Date: Tue, 20 Feb 2018 09:27:47 +0100 Subject: [PATCH] Validiere gegen Strukturdatentypologie --- src/schema/diglib.sch | 14 ++++++++++++++ src/xproc/publish.xpl | 14 +++++++++++++- test/schema/diglib.xspec | 27 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/schema/diglib.sch create mode 100644 test/schema/diglib.xspec diff --git a/src/schema/diglib.sch b/src/schema/diglib.sch new file mode 100644 index 0000000..fc7be35 --- /dev/null +++ b/src/schema/diglib.sch @@ -0,0 +1,14 @@ +<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <ns prefix="mets" uri="http://www.loc.gov/METS/"/> + <ns prefix="rdf" uri="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> + <ns prefix="rdfs" uri="http://www.w3.org/2000/01/rdf-schema#"/> + <pattern> + <title>Strukturdatentypologie</title> + <rule context="mets:div[@TYPE]"> + <assert test="concat('http://uri.hab.de/ontology/diglib-struct#', @TYPE) = doc('http://uri.hab.de/ontology/diglib-struct.rdf')//rdfs:Class/@rdf:about" id="structmap.unknown-type"> + Das @TYPE-Attribut einer Struktur muss mit einem in der Strukturdatentypologie definierten Wert belegt + werden. Der Wert <value-of select="@TYPE"/> ist unbekannt. + </assert> + </rule> + </pattern> +</schema> diff --git a/src/xproc/publish.xpl b/src/xproc/publish.xpl index 0d46c36..3b1536e 100644 --- a/src/xproc/publish.xpl +++ b/src/xproc/publish.xpl @@ -75,7 +75,7 @@ </p:input> </p:xslt> - <p:validate-with-xml-schema assert-valid="true"> + <p:validate-with-xml-schema assert-valid="true" name="validate-mets"> <p:input port="source"> <p:pipe step="normalize" port="result"/> </p:input> @@ -84,6 +84,18 @@ </p:input> </p:validate-with-xml-schema> + <p:validate-with-schematron assert-valid="true"> + <p:input port="source"> + <p:pipe step="validate-mets" port="result"/> + </p:input> + <p:input port="schema"> + <p:document href="../schema/diglib.sch"/> + </p:input> + <p:input port="parameters"> + <p:empty/> + </p:input> + </p:validate-with-schematron> + <p:store> <p:with-option name="href" select="$targetUri"/> </p:store> diff --git a/test/schema/diglib.xspec b/test/schema/diglib.xspec new file mode 100644 index 0000000..efc9817 --- /dev/null +++ b/test/schema/diglib.xspec @@ -0,0 +1,27 @@ +<xspec:description schematron="../../src/schema/diglib.sch" + xmlns:mets="http://www.loc.gov/METS/" + xmlns:xspec="http://www.jenitennison.com/xslt/xspec"> + + <xspec:scenario label="Validating a structure with an unknown @TYPE"> + <xspec:context> + <mets:mets> + <mets:structMap> + <mets:div TYPE="unkown"/> + </mets:structMap> + </mets:mets> + </xspec:context> + <xspec:expect-assert id="structmap.unknown-type"/> + </xspec:scenario> + + <xspec:scenario label="Validating a structure with an known @TYPE"> + <xspec:context> + <mets:mets> + <mets:structMap> + <mets:div TYPE="C0005"/> + </mets:structMap> + </mets:mets> + </xspec:context> + <xspec:expect-not-assert id="structmap.unknown-type"/> + </xspec:scenario> + +</xspec:description> -- GitLab