diff --git a/src/ruleset.rnc b/src/ruleset.rnc index 0c82320e80aee98bd2731bc5ef5098244cb6a641..98edcbc6d8305845c3ec3be65a4813466e9a76eb 100644 --- a/src/ruleset.rnc +++ b/src/ruleset.rnc @@ -12,7 +12,8 @@ start = Preferences Preferences = element Preferences { element debug { "0" | "1" }?, - MetadataTypeDef* + MetadataTypeDef*, + ImportExportDef } MetadataTypeDef = @@ -74,4 +75,76 @@ AllowedMetadata = attribute num { "*" | "+" | "1o" | "1m" }?, attribute DefaultDisplay { text }?, xsd:NMTOKEN - } \ No newline at end of file + } + +ImportExportDef = + element Formats { + PicaImport? + } + +PicaImport = + element PicaPlus { + ( PicaPlusImportMetadata | PicaPlusImportDocStruct | PicaPlusImportPerson )* + } + +PicaPlusImportMetadata = + [ + s:pattern [ + s:rule [ + context = "Metadata[parent::PicaPlus]" s:assert [ + test = "/Preferences/MetadataType/Name = current()/Name" + "Das Metadatum '" s:value-of [ select = "Name" ] "' muss definiert werden." + ] + ] + ] + ] + element Metadata { + PicaPlusImportMappingElements + } + +PicaPlusImportPerson = + [ + s:pattern [ + s:rule [ + context = "Person[parent::PicaPlus]" s:assert [ + test = "/Preferences/MetadataType/Name = current()/Name" + "Das Metadatum '" s:value-of [ select = "Name" ] "' muss definiert werden." + ] + ] + s:rule [ + context = "Person[parent::PicaPlus]" s:assert [ + test = "/Preferences/MetadataType[Name = current()/Name]/@type = 'person'" + "Das Metadatum '" s:value-of [ select = "Name" ] "' muss als Person gekennzeichnet sein." + ] + ] + ] + ] + element Person { + PicaPlusImportMappingElements + } + +PicaPlusImportDocStruct = + [ + s:pattern [ + s:rule [ + context = "DocStruct[parent::PicaPlus]" s:assert [ + test = "/Preferences/DocStrctType/Name = current()/Name" + "Der Strukturtyp '" s:value-of [ select = "Name" ] "' muss definiert werden." + ] + ] + ] + ] + element DocStruct { + PicaPlusImportMappingElements + & element picaContent { text } + } + +PicaPlusImportMappingElements = + element picaMainTag { text } + & element picaSubTag { + attribute type { "firstname" | "lastname" | "identifier" | "expansion" }? + & text + }* + & element valueCondition { text }? + & element valueRegExp { text }? + & Name \ No newline at end of file diff --git a/test/ruleset.xspec b/test/ruleset.xspec index 313b2de1071d729c6956065315d502bf55c4cfbe..26088d617391580481f76ae728e48572dfa27884 100644 --- a/test/ruleset.xspec +++ b/test/ruleset.xspec @@ -47,4 +47,102 @@ <expect-assert/> </scenario> </scenario> + <scenario label="Import von Pica+"> + <scenario label="Metadatum ist definiert"> + <context> + <Preferences xmlns=""> + <MetadataType> + <Name>is-defined</Name> + </MetadataType> + <PicaPlus> + <Metadata> + <Name>is-defined</Name> + </Metadata> + </PicaPlus> + </Preferences> + </context> + <expect-not-assert/> + </scenario> + <scenario label="Metadatum ist nicht definiert"> + <context> + <Preferences xmlns=""> + <PicaPlus> + <Metadata> + <Name>is-not-defined</Name> + </Metadata> + </PicaPlus> + </Preferences> + </context> + <expect-assert/> + </scenario> + <scenario label="Person ist definiert"> + <context> + <Preferences xmlns=""> + <MetadataType type="person"> + <Name>is-defined</Name> + </MetadataType> + <PicaPlus> + <Person> + <Name>is-defined</Name> + </Person> + </PicaPlus> + </Preferences> + </context> + <expect-not-assert/> + </scenario> + <scenario label="Person ist nicht definiert"> + <context> + <Preferences xmlns=""> + <PicaPlus> + <Person> + <Name>is-not-defined</Name> + </Person> + </PicaPlus> + </Preferences> + </context> + <expect-assert/> + </scenario> + <scenario label="Metadatum ist definiert aber keine Person"> + <context> + <Preferences xmlns=""> + <MetadataType> + <Name>is-defined</Name> + </MetadataType> + <PicaPlus> + <Person> + <Name>is-not-defined</Name> + </Person> + </PicaPlus> + </Preferences> + </context> + <expect-assert/> + </scenario> + <scenario label="Strukturtyp ist definiert"> + <context> + <Preferences xmlns=""> + <DocStrctType> + <Name>is-defined</Name> + </DocStrctType> + <PicaPlus> + <DocStruct> + <Name>is-defined</Name> + </DocStruct> + </PicaPlus> + </Preferences> + </context> + <expect-not-assert/> + </scenario> + <scenario label="Strukturtyp ist nicht definiert"> + <context> + <Preferences xmlns=""> + <PicaPlus> + <DocStruct> + <Name>is-not-defined</Name> + </DocStruct> + </PicaPlus> + </Preferences> + </context> + <expect-assert/> + </scenario> + </scenario> </description>