Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58c1549
[MOD] new root element library, re https://github.com/Schematron/sche…
AndrewSales Feb 11, 2024
de1465c
[MOD] new attribute as, re https://github.com/Schematron/schematron-e…
AndrewSales Feb 11, 2024
b3b941d
[MOD] new element active-group, re https://github.com/Schematron/sche…
AndrewSales Feb 11, 2024
7b967bc
[MOD] adds value-of and name to emph, dir and span, re https://github…
AndrewSales Feb 23, 2024
de35269
[MOD] add name to model for diagnostic; common decl for message text
AndrewSales Mar 9, 2024
a532c83
[MOD] add optional title to rule, to facilitate svrl:fired-rule/@name;
AndrewSales Mar 9, 2024
7e3f659
[MOD] new optional attribute schematronVersion, re https://github.com…
AndrewSales Mar 11, 2024
0d5fffc
[MOD] SVRL equivalent, re https://github.com/Schematron/schematron-en…
AndrewSales Mar 11, 2024
61be2c9
[MOD] value of flag attribute is a list of tokens, re https://github.…
AndrewSales Mar 11, 2024
f2ea42c
[MOD] schema-level params, re https://github.com/Schematron/schematro…
AndrewSales Mar 16, 2024
9a54584
[ADD] unit tests for schematron.sch
AndrewSales Mar 16, 2024
f612212
[MOD] WIP, re https://github.com/Schematron/schematron-enhancement-pr…
AndrewSales Mar 16, 2024
8e62512
[MOD] rules and unit tests in support of abstract pattern parameters,…
AndrewSales Mar 17, 2024
3410580
[FIX] typo
AndrewSales Mar 17, 2024
16efc79
[MOD] require schema param value, re https://github.com/Schematron/sc…
AndrewSales Mar 17, 2024
684253c
[MOD] date
AndrewSales Mar 17, 2024
147ec85
[FIX] typo, re https://github.com/Schematron/schematron-enhancement-p…
AndrewSales Jun 22, 2024
bb90662
[MOD] svrl:error as child of root element, re https://github.com/Sche…
AndrewSales Jun 22, 2024
574aba6
[MOD] add attribute from, re https://github.com/Schematron/schematron…
AndrewSales Jul 21, 2024
9bff057
[MOD] mandatory svrl:error and human-text, for errors occurring befor…
AndrewSales Jul 21, 2024
5456295
[MOD] attribute visit-each, re https://github.com/Schematron/schematr…
AndrewSales Jul 21, 2024
3342fbd
[MOD] add optional params and lets; make patterns optional, re https:…
AndrewSales Jul 28, 2024
200f135
[MOD] new optional attribute phase/@when
AndrewSales Sep 7, 2024
745c2f4
[FIX] align attribute name with DIS, re https://github.com/Schematron…
AndrewSales Mar 22, 2025
f12483d
[FIX] changes to reflect DIS comments
AndrewSales Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 78 additions & 35 deletions schematron.rnc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © ISO/IEC 2017
# Copyright © ISO/IEC 2024
# The following permission notice and disclaimer shall be included in all
# copies of this XML schema ("the Schema"), and derivations of the Schema:

Expand Down Expand Up @@ -26,19 +26,20 @@
namespace local = ""
default namespace sch = "http://purl.oclc.org/dsdl/schematron"

start = schema
start = schema | library

# Element declarations
schema =
element schema {
attribute id { xsd:ID }?,
rich,
attribute schemaVersion { non-empty-string }?,
attribute schematronEdition { non-empty-string }?,
attribute defaultPhase { xsd:IDREF }?,
attribute queryBinding { non-empty-string }?,
(foreign
& inclusion*
& (title?, ns*, p*, let*, phase*, pattern+, p*, diagnostics?, properties?))
& (inclusion | extends)*
& (title?, ns*, p*, param*, let*, phase*, abstract-rules*, (rule-set|pattern)+, p*, diagnostics?, properties?))
}
active =
element active {
Expand All @@ -54,22 +55,23 @@ assert =
attribute properties { xsd:IDREFS }?,
rich,
linkable,
(foreign & (text | name | value-of | emph | dir | span)*)
severity,
message
}
diagnostic =
element diagnostic {
attribute id { xsd:ID },
attribute role { roleValue }?,
rich,
(foreign & (text | value-of | emph | dir | span)*)
message
}
diagnostics = element diagnostics { foreign & inclusion* & diagnostic* }
dir =
element dir {
attribute value { "ltr" | "rtl" }?,
(foreign & text)
(foreign & (text | dynamic)*)
}
emph = element emph { text }
emph = element emph { (foreign & (text | dynamic)*) }
extends =
element extends {
(attribute rule { xsd:IDREF }
Expand All @@ -79,9 +81,18 @@ extends =
let =
element let {
attribute name { nameValue },
attribute as { text }?,
(attribute value { string }
| foreign-element+)
}
library =
element library {
attribute id { xsd:ID }?,
rich,
(foreign
& (inclusion | extends)*
& (title?, p*, param*, let*, abstract-rules*, (rule-set|pattern)*, p*, diagnostics?, properties?))
}
name =
element name {
attribute path { pathValue }?,
Expand All @@ -103,32 +114,18 @@ p =
param =
element param {
attribute name { nameValue },
attribute value { non-empty-string }
attribute value { non-empty-string }?
}

pattern =
element pattern {
attribute documents { pathValue }?,
rich,
(foreign
& inclusion*
& ((attribute abstract { "true" },
attribute id { xsd:ID },
title?,
(p*, let*, rule*))
| (attribute abstract { "false" }?,
attribute id { xsd:ID }?,
title?,
(p*, let*, rule*))
| (attribute abstract { "false" }?,
attribute is-a { xsd:IDREF },
attribute id { xsd:ID }?,
title?,
(p*, param*))))
rule-set-or-pattern
}
phase =
element phase {
attribute id { xsd:ID },
attribute from { pathValue }?,
attribute when { pathValue }?,
rich,
(foreign & inclusion* & (p*, let*, active*))
}
Expand All @@ -138,7 +135,7 @@ property =
attribute id { xsd:ID },
attribute role { roleValue }?,
attribute scheme { text }?,
(foreign & (text | name | value-of | emph | dir | span)*)
message
}
report =
element report {
Expand All @@ -149,7 +146,8 @@ report =
attribute properties { xsd:IDREFS }?,
rich,
linkable,
(foreign & (text | name | value-of | emph | dir | span)*)
severity,
message
}
rule =
element rule {
Expand All @@ -158,20 +156,43 @@ rule =
linkable,
(foreign
& inclusion*
& ((attribute abstract { "true" },
attribute id { xsd:ID },
let*,
(assert | report | extends | p)+)
| (attribute context { pathValue },
& ((attribute context { pathValue },
attribute visit-each { pathValue }?,
attribute id { xsd:ID }?,
attribute abstract { "false" }?,
title?,
let*,
(assert | report | extends | p)+)))
}
abstract-rule =
element rule {
attribute flag { flagValue }?,
rich,
linkable,
(foreign
& inclusion*
& (attribute abstract { "true" },
attribute id { xsd:ID },
title?,
let*,
(assert | report | extends | p)+))
}
abstract-rules =
element rules {
attribute id { xsd:ID }?,
rich,
title?,
p*,
abstract-rule+
}
rule-set =
element group {
rule-set-or-pattern
}
span =
element span {
attribute class { classValue },
(foreign & text)
(foreign & (text | dynamic)*)
}
title = element title { (text | dir)* }
value-of =
Expand Down Expand Up @@ -205,6 +226,28 @@ foreign-element =
| schema
| text)*
}
rule-set-or-pattern =
attribute documents { pathValue }?,
attribute role { roleValue }?,
rich,
(foreign
& inclusion*
& ((attribute abstract { "true" },
attribute id { xsd:ID },
title?,
(p*, param*, let*, rule*))
| (attribute abstract { "false" }?,
attribute id { xsd:ID }?,
title?,
(p*, let*, rule*))
| (attribute abstract { "false" }?,
attribute is-a { xsd:IDREF },
attribute id { xsd:ID }?,
title?,
(p*, param*))))
severity = attribute severity{ text }?
dynamic = value-of | name
message = (foreign & (text | dynamic | emph | dir | span)*)

# Data types
uriValue = xsd:anyURI
Expand All @@ -213,7 +256,7 @@ exprValue = string
fpiValue = string
langValue = xsd:language
roleValue = string
flagValue = string
flagValue = list{ token+ }
nameValue = string

# In the default query language binding, xsd:NCNAME
Expand Down
41 changes: 30 additions & 11 deletions schematron.sch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
© ISO/IEC 2017
© ISO/IEC 2024
The following permission notice and disclaimer shall be included in all
copies of this XML schema ("the Schema"), and derivations of the Schema:
Permission is hereby granted, free of charge in perpetuity, to any
Expand All @@ -21,37 +21,56 @@ THIS SCHEMA HAS BEEN MODIFIED FROM THE SCHEMA DEFINED IN ISO/IEC 19757 3,
AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD."
-->

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" xml:lang="en">
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" xml:lang="en" queryBinding="xslt2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name='abstract-pattern' match='sch:pattern[@abstract="true"]' use='@id'/>
<sch:title>Schema for Additional Constraints in Schematron</sch:title>
<sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/>
<sch:p>This schema supplies some constraints in addition to those given in the
ISO/IEC 19757 2
(RELAX NG Compact Syntax) Schema for Schematron. </sch:p>
<sch:pattern>
<sch:rule context="sch:active">
<sch:assert test="//sch:pattern[@id=current()/@pattern]"> The pattern
<sch:assert test="//sch:pattern[@id=current()/@pattern]" id='active-patterns'> The pattern
attribute of the active element shall match the id
attribute of a pattern.</sch:assert>
</sch:rule>
<sch:rule context="sch:pattern[@is-a]">
<sch:assert test="//sch:pattern[@abstract='true'][@id=current()/@is-a]"> The
is-a attribute of a pattern element shall match
the id attribute of an abstract pattern.
</sch:assert>
</sch:rule>
<sch:rule context="sch:extends">
<sch:assert test="//sch:rule[@abstract='true'][@id=current()/@rule]"> The rule
<sch:assert test="//sch:rule[@abstract='true'][@id=current()/@rule]" id="abstract-rules"> The rule
attribute of an extends element shall match the id
attribute of an abstract rule.
</sch:assert>
</sch:rule>
<sch:rule context="sch:let">
<sch:assert
<sch:assert id="param-variable-clash"
test="not(//sch:pattern
[@abstract='true']/sch:param[@name=current()/@name])"
> A variable name and an abstract pattern parameter should not use the
same name.
</sch:assert>
</sch:rule>
<sch:rule context="sch:param">
<sch:assert test="not(../(sch:param except current())[@name=current()/@name])"
id="param-name">A parameter name should not use the same name as a parameter in the same scope.</sch:assert>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:rule context="sch:pattern[@is-a]">
<sch:assert test="key('abstract-pattern', @is-a)" id="abstract-patterns"> The
is-a attribute of a pattern element shall match
the id attribute of an abstract pattern.
</sch:assert>
<sch:assert test="every $name in current()/sch:param/@name
satisfies $name eq key('abstract-pattern', @is-a)/sch:param/@name" id="param-names-match"> The
name attribute of a pattern param element shall match
the name attribute of an abstract pattern param element.
</sch:assert>
</sch:rule>
<sch:rule context="sch:pattern[@is-a]/sch:param">
<sch:assert test="@value or key('abstract-pattern', ../@is-a)/sch:param/@value" id="missing-param-value">A pattern parameter value shall be specified.</sch:assert>
</sch:rule>
<sch:rule context="sch:schema/sch:param">
<sch:assert test="@value" id="schema-param-value">A schema parameter value shall be specified.</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
Loading