Introduction

Here we go…

Example

1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="test">
    <Header>Where to find Foo</Header>
    <Author>Jane Doe</Author>
    <Date>2021-02-14</Date>
    <!-- Further content -->
</Document>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" schemaVersion="iso" queryBinding="xslt2">

    <title>Document rules</title>

    <ns prefix="t" uri="test"/>

    <pattern>
        <rule context="t:Document">
            <assert id="RULE-R001" test="t:Header">Document MUST contain header.</assert>
            <assert id="RULE-R002" test="t:Author">Document MUST contain author.</assert>
            <assert id="RULE-R003" test="t:Date">Document MUST contain date.</assert>
            <!-- More asserts here... -->
        </rule>
    </pattern>

</schema>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<Tests xmlns="urn:fdc:schunit.com:2020:v1">
    <Description>Verify existence of header in document.</Description>
    <Scope>RULE-R001</Scope>

    <Test>
        <Success>RULE-R001</Success>

        <Document xmlns="test">
            <Header/>
        </Document>
    </Test>

    <Test>
        <Trigger>RULE-R001</Trigger>

        <Document xmlns="test">
            <!-- <Header/> -->
        </Document>
    </Test>
</Tests>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<Tests xmlns="urn:fdc:schunit.com:2020:v1">
    <Description>Verify existence of header in document.</Description>
    <Scope/>

    <Test>
        <Success/>

        <Document xmlns="test">
            <Header/>
        </Document>
    </Test>

    <Test>
        <Trigger/>

        <Document xmlns="test">
            <!-- <Header/> -->
        </Document>
    </Test>
</Tests>