Skip to content

Commit

Permalink
Initialer Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
David Maus committed Oct 10, 2017
0 parents commit f4dc29d
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.xsd
*.rng
*.sch
/test/*-compiled.xspec
/test/xspec
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
XSPEC = xspec.cmd
TRANG = java -jar lib/trang.jar
SAXON = java -jar lib/saxon9he.jar

%.rng: %.rnc
$(TRANG) -I rnc -O rng $< $@

%.xsd: %.rnc
$(TRANG) -I rnc -O xsd $< $@

%.sch: %.rng
$(SAXON) -xsl:lib/rngsch.xsl -o:$@ $<

test: src/ruleset.sch
$(XSPEC) -s test/ruleset.xspec

all: src/ruleset.xsd src/ruleset.rng src/ruleset.sch test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Schemata für Kitodo.Production
==
18 changes: 18 additions & 0 deletions lib/rngsch.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<xsl:transform version="2.0"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="rng:grammar">
<sch:schema queryBinding="xslt2">
<xsl:apply-templates/>
</sch:schema>
</xsl:template>

<xsl:template match="sch:*">
<xsl:sequence select="."/>
</xsl:template>

<xsl:template match="text()"/>

</xsl:transform>
Binary file added lib/saxon9he.jar
Binary file not shown.
Binary file added lib/trang.jar
Binary file not shown.
78 changes: 78 additions & 0 deletions src/ruleset.rnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# -*- mode: rnc; -*-
#
# RelaxNG Schema für Kitido.Production Regelsatz
#
# Author: David Maus <[email protected]>
# Timestamp: <2017-10-10 15:16:42 maus>
#

namespace s = "http://purl.oclc.org/dsdl/schematron"

start = Preferences

Preferences =
element Preferences {
element debug { "0" | "1" }?,
MetadataTypeDef*
}

MetadataTypeDef =
element Metadata {
attribute type { "person" | "identifier" }?,
(
Name
& NameTranslation*
)
}

Name =
## Interner Name des Metadaten- oder Strukturtyps. Der Name wird zur Referenzierung benutzt und muss daher dokumentweit eindeutig sein.
element Name { xsd:NMTOKEN }

NameTranslation =
## Übersetzung eines Namens in die über das Attribut @name spezifizierte Sprache.
element language {
attribute name { xsd:language },
text
}

StructTypeDef =
element DocStrctType {
attribute anchor { "true" }?
& Name
& NameTranslation
& AllowedChildStruct*
& AllowedMetadata*
}

AllowedChildStruct =
[
s:pattern [
s:rule [
context = "allowedchildtype" s:assert [
test = "/Preferences/DocStrctType[Name = .]"
"Der Strukturtyp '" s:value-of [ select = "." ] "' muss definiert werden."
]
]
]
]
element allowedchildtype {
xsd:NMTOKEN
}

AllowedMetadata =
[
s:pattern [
s:rule [
context = "metadata[parent::DocStrctType]" s:assert [
test = "/Preferences/MetadataType[Name = .]"
"Das Metadatum '" s:value-of [ select = "." ] "' muss definiert werden."
]
]
]
]
element metadata {
attribute num { "*" | "+" | "1o" | "1m" }?,
attribute DefaultDisplay { text }?,
xsd:NMTOKEN
}
27 changes: 27 additions & 0 deletions test/ruleset.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<description xmlns="http://www.jenitennison.com/xslt/xspec" schematron="../src/ruleset.sch">
<scenario label="Definition der Strukturtypen">
<scenario label="Untergeordneter Strukturtyp ist definiert">
<context>
<Preferences xmlns="">
<DocStrctType>
<Name>is-defined</Name>
</DocStrctType>
<DocStrctType>
<allowedchildtype>is-defined</allowedchildtype>
</DocStrctType>
</Preferences>
</context>
<expect-assert/>
</scenario>
<scenario label="Untergeordneter Strukturtyp ist nicht definiert">
<context>
<Preferences xmlns="">
<DocStrctType>
<allowedchildtype>is-not-defined</allowedchildtype>
</DocStrctType>
</Preferences>
</context>
<expect-assert/>
</scenario>
</scenario>
</description>

0 comments on commit f4dc29d

Please sign in to comment.