From 58c15494207f620c33b55694fefdf2142375b351 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 11 Feb 2024 16:59:58 +0000 Subject: [PATCH 01/25] [MOD] new root element library, re https://github.com/Schematron/schematron-enhancement-proposals/issues/39 extends available at top level, enabling import of library etc new element rules to group abstract rules, re https://github.com/Schematron/schematron-enhancement-proposals/issues/3 and https://github.com/Schematron/schematron-enhancement-proposals/issues/39 new element group for rule processing without if-then-else behaviour, re https://github.com/Schematron/schematron-enhancement-proposals/issues/25 new attribute severity, re https://github.com/Schematron/schematron-enhancement-proposals/issues/58 --- schematron.rnc | 85 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/schematron.rnc b/schematron.rnc index b1c784b..b22abcf 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -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: @@ -26,7 +26,7 @@ namespace local = "" default namespace sch = "http://purl.oclc.org/dsdl/schematron" -start = schema +start = schema | library # Element declarations schema = @@ -37,8 +37,8 @@ schema = 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*, let*, phase*, abstract-rules*, (rule-set|pattern)+, p*, diagnostics?, properties?)) } active = element active { @@ -54,6 +54,7 @@ assert = attribute properties { xsd:IDREFS }?, rich, linkable, + severity, (foreign & (text | name | value-of | emph | dir | span)*) } diagnostic = @@ -82,6 +83,14 @@ let = (attribute value { string } | foreign-element+) } +library = + element library { + attribute id { xsd:ID }?, + rich, + (foreign + & (inclusion | extends)* + & (title?, p*, abstract-rules*, (rule-set|pattern)+, p*, diagnostics?, properties?)) + } name = element name { attribute path { pathValue }?, @@ -108,23 +117,7 @@ param = 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 { @@ -149,6 +142,7 @@ report = attribute properties { xsd:IDREFS }?, rich, linkable, + severity, (foreign & (text | name | value-of | emph | dir | span)*) } rule = @@ -158,16 +152,36 @@ rule = linkable, (foreign & inclusion* - & ((attribute abstract { "true" }, - attribute id { xsd:ID }, - let*, - (assert | report | extends | p)+) - | (attribute context { pathValue }, + & ((attribute context { pathValue }, attribute id { xsd:ID }?, attribute abstract { "false" }?, let*, (assert | report | extends | p)+))) } +abstract-rule = + element rule { + attribute flag { flagValue }?, + rich, + linkable, + (foreign + & inclusion* + & (attribute abstract { "true" }, + attribute id { xsd:ID }, + 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 }, @@ -205,6 +219,25 @@ foreign-element = | schema | text)* } +rule-set-or-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*)))) +severity = attribute severity{ text }? # Data types uriValue = xsd:anyURI From de1465cd78565488771f3d793474e8271ffaf5a6 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 11 Feb 2024 17:54:27 +0000 Subject: [PATCH 02/25] [MOD] new attribute as, re https://github.com/Schematron/schematron-enhancement-proposals/issues/1 --- schematron.rnc | 1 + 1 file changed, 1 insertion(+) diff --git a/schematron.rnc b/schematron.rnc index b22abcf..cbf91da 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -80,6 +80,7 @@ extends = let = element let { attribute name { nameValue }, + attribute as { text }?, (attribute value { string } | foreign-element+) } From b3b941da1163b063469510032916a6c90c229889 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 11 Feb 2024 18:30:16 +0000 Subject: [PATCH 03/25] [MOD] new element active-group, re https://github.com/Schematron/schematron-enhancement-proposals/issues/25 new element error in (active-*), re https://github.com/Schematron/schematron-enhancement-proposals/issues/47 new attribute severity, re https://github.com/Schematron/schematron-enhancement-proposals/issues/58 --- svrl.rnc | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/svrl.rnc b/svrl.rnc index 47ebd57..785187e 100644 --- a/svrl.rnc +++ b/svrl.rnc @@ -1,4 +1,4 @@ -# Copyright © ISO/IEC 2019 +# 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: @@ -34,7 +34,7 @@ schematron-output = attribute schemaVersion { text }?, human-text*, ns-prefix-in-attribute-values*, - (active-pattern, + (active-pattern-rule-set, (fired-rule, (failed-assert | successful-report)*)*)+ } # only namespaces from sch:ns need to be reported @@ -44,15 +44,15 @@ ns-prefix-in-attribute-values = attribute uri { text }, empty } -# only active patterns are reported +# only active patterns and groups are reported active-pattern = element active-pattern { - attribute id { xsd:NCName }?, - attribute documents { text }?, - attribute name { text }?, - attribute role { string }?, - empty + active } +active-rule-set = + element active-group { + active + } # only rules that are fired are reported, fired-rule = element fired-rule { @@ -73,12 +73,12 @@ diagnostic-reference = # only failed assertions are reported failed-assert = element failed-assert { - attlist.assert-and-report, diagnostic-reference*, property-reference*, human-text + assertion-message } # only successful asserts are reported successful-report = element successful-report { - attlist.assert-and-report, diagnostic-reference*, property-reference*, human-text + assertion-message } # property-reference property-reference = @@ -88,6 +88,14 @@ property-reference = attribute scheme { text }?, human-text } +# errors raised in evaluating pattern/@documents +error = + element error { + attribute document { xsd:anyURI }, + attribute location { text }, + attribute code { text }?, + rich-text + } # human text human-text = element text { @@ -133,5 +141,21 @@ attlist.assert-and-report = attribute location { text }, attribute test { text }, attribute role { string }?, - attribute flag { string }? + attribute flag { string }?, + attribute severity { string }? + +# active patterns and rule-sets +active-pattern-rule-set = + active-pattern | active-rule-set +active = + attribute id { xsd:NCName }?, + attribute documents { text }?, + attribute name { text }?, + attribute role { string }?, + error* + +# assert and report message +assertion-message = + attlist.assert-and-report, diagnostic-reference*, property-reference*, human-text + start = schematron-output \ No newline at end of file From 7b967bcb272143e09f9f90f8ad3de46eb8992082 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Fri, 23 Feb 2024 16:28:30 +0000 Subject: [PATCH 04/25] [MOD] adds value-of and name to emph, dir and span, re https://github.com/Schematron/schematron-enhancement-proposals/issues/37 --- schematron.rnc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/schematron.rnc b/schematron.rnc index cbf91da..35abd01 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -68,9 +68,9 @@ 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 } @@ -186,7 +186,7 @@ rule-set = span = element span { attribute class { classValue }, - (foreign & text) + (foreign & (text | dynamic)*) } title = element title { (text | dir)* } value-of = @@ -239,6 +239,7 @@ rule-set-or-pattern = title?, (p*, param*)))) severity = attribute severity{ text }? +dynamic = value-of | name # Data types uriValue = xsd:anyURI From de3526992ac7aafcfb4a201a17edee064373be32 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sat, 9 Mar 2024 16:21:38 +0000 Subject: [PATCH 05/25] [MOD] add name to model for diagnostic; common decl for message text --- schematron.rnc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/schematron.rnc b/schematron.rnc index 35abd01..098c934 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -55,14 +55,14 @@ assert = rich, linkable, severity, - (foreign & (text | name | value-of | emph | dir | span)*) + 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 = @@ -132,7 +132,7 @@ property = attribute id { xsd:ID }, attribute role { roleValue }?, attribute scheme { text }?, - (foreign & (text | name | value-of | emph | dir | span)*) + message } report = element report { @@ -144,7 +144,7 @@ report = rich, linkable, severity, - (foreign & (text | name | value-of | emph | dir | span)*) + message } rule = element rule { @@ -240,6 +240,7 @@ rule-set-or-pattern = (p*, param*)))) severity = attribute severity{ text }? dynamic = value-of | name +message = (foreign & (text | dynamic | emph | dir | span)*) # Data types uriValue = xsd:anyURI From a532c83d0334b298d9a1b1e9b824803d0a924847 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sat, 9 Mar 2024 18:16:43 +0000 Subject: [PATCH 06/25] [MOD] add optional title to rule, to facilitate svrl:fired-rule/@name; add optional role attribute to pattern and group, to facilitate svrl:active-*/@role; add optional role attribute to svrl:diagnostic-reference, in line with svrl:property-reference re https://github.com/Schematron/schematron-enhancement-proposals/issues/5, https://github.com/Schematron/schematron-enhancement-proposals/issues/7 --- schematron.rnc | 3 +++ svrl.rnc | 1 + 2 files changed, 4 insertions(+) diff --git a/schematron.rnc b/schematron.rnc index 098c934..924b45a 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -156,6 +156,7 @@ rule = & ((attribute context { pathValue }, attribute id { xsd:ID }?, attribute abstract { "false" }?, + title?, let*, (assert | report | extends | p)+))) } @@ -168,6 +169,7 @@ abstract-rule = & inclusion* & (attribute abstract { "true" }, attribute id { xsd:ID }, + title?, let*, (assert | report | extends | p)+)) } @@ -222,6 +224,7 @@ foreign-element = } rule-set-or-pattern = attribute documents { pathValue }?, + attribute role { roleValue }?, rich, (foreign & inclusion* diff --git a/svrl.rnc b/svrl.rnc index 785187e..6ed5bc2 100644 --- a/svrl.rnc +++ b/svrl.rnc @@ -68,6 +68,7 @@ fired-rule = diagnostic-reference = element diagnostic-reference { attribute diagnostic { xsd:NMTOKEN }, + attribute role { text }?, human-text } # only failed assertions are reported From 7e3f659f0fd807f442c6f55c115be2a8e51887f4 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Mon, 11 Mar 2024 11:15:08 +0000 Subject: [PATCH 07/25] [MOD] new optional attribute schematronVersion, re https://github.com/Schematron/schematron-enhancement-proposals/issues/42 --- schematron.rnc | 1 + 1 file changed, 1 insertion(+) diff --git a/schematron.rnc b/schematron.rnc index 924b45a..4fdb565 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -34,6 +34,7 @@ schema = attribute id { xsd:ID }?, rich, attribute schemaVersion { non-empty-string }?, + attribute schematronVersion { non-empty-string }?, attribute defaultPhase { xsd:IDREF }?, attribute queryBinding { non-empty-string }?, (foreign From 0d5fffcce5d5824bf12a7e213d808faf20272bf3 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Mon, 11 Mar 2024 14:25:51 +0000 Subject: [PATCH 08/25] [MOD] SVRL equivalent, re https://github.com/Schematron/schematron-enhancement-proposals/issues/42 --- svrl.rnc | 1 + 1 file changed, 1 insertion(+) diff --git a/svrl.rnc b/svrl.rnc index 6ed5bc2..549a4a1 100644 --- a/svrl.rnc +++ b/svrl.rnc @@ -32,6 +32,7 @@ schematron-output = attribute title { text }?, attribute phase { xsd:NMTOKEN }?, attribute schemaVersion { text }?, + attribute schematronVersion { text }?, human-text*, ns-prefix-in-attribute-values*, (active-pattern-rule-set, From 61be2c942d8b3ed245637038c31983cbddd21dcf Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Mon, 11 Mar 2024 16:44:37 +0000 Subject: [PATCH 09/25] [MOD] value of flag attribute is a list of tokens, re https://github.com/Schematron/schematron-enhancement-proposals/issues/12 --- schematron.rnc | 2 +- svrl.rnc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/schematron.rnc b/schematron.rnc index 4fdb565..b7a904f 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -253,7 +253,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 diff --git a/svrl.rnc b/svrl.rnc index 549a4a1..b09c74a 100644 --- a/svrl.rnc +++ b/svrl.rnc @@ -61,7 +61,7 @@ fired-rule = attribute name { text }?, attribute context { text }, attribute role { string }?, - attribute flag { string }?, + attribute flag { list{ token+ } }?, attribute document { xsd:anyURI }?, empty } @@ -143,7 +143,7 @@ attlist.assert-and-report = attribute location { text }, attribute test { text }, attribute role { string }?, - attribute flag { string }?, + attribute flag { list{ token+ } }?, attribute severity { string }? # active patterns and rule-sets From f2ea42c3a77412d5fb43925f8902741171e98d5d Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sat, 16 Mar 2024 16:33:28 +0000 Subject: [PATCH 10/25] [MOD] schema-level params, re https://github.com/Schematron/schematron-enhancement-proposals/issues/34; abstract pattern params, re https://github.com/Schematron/schematron-enhancement-proposals/issues/8 --- schematron.rnc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/schematron.rnc b/schematron.rnc index b7a904f..a84ede6 100644 --- a/schematron.rnc +++ b/schematron.rnc @@ -39,7 +39,7 @@ schema = attribute queryBinding { non-empty-string }?, (foreign & (inclusion | extends)* - & (title?, ns*, p*, let*, phase*, abstract-rules*, (rule-set|pattern)+, p*, diagnostics?, properties?)) + & (title?, ns*, p*, param*, let*, phase*, abstract-rules*, (rule-set|pattern)+, p*, diagnostics?, properties?)) } active = element active { @@ -114,7 +114,7 @@ p = param = element param { attribute name { nameValue }, - attribute value { non-empty-string } + attribute value { non-empty-string }? } pattern = @@ -232,7 +232,7 @@ rule-set-or-pattern = & ((attribute abstract { "true" }, attribute id { xsd:ID }, title?, - (p*, let*, rule*)) + (p*, param*, let*, rule*)) | (attribute abstract { "false" }?, attribute id { xsd:ID }?, title?, From 9a545849cfa9dfc160747c5e62d5e9e51261bd7e Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sat, 16 Mar 2024 19:01:54 +0000 Subject: [PATCH 11/25] [ADD] unit tests for schematron.sch --- schematron.xspec | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 schematron.xspec diff --git a/schematron.xspec b/schematron.xspec new file mode 100644 index 0000000..e2d7cd7 --- /dev/null +++ b/schematron.xspec @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + From f612212e311f34f1cba75144404d1eea574b71f1 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sat, 16 Mar 2024 21:11:49 +0000 Subject: [PATCH 12/25] [MOD] WIP, re https://github.com/Schematron/schematron-enhancement-proposals/issues/8 --- schematron.sch | 22 ++++++++---- schematron.xspec | 87 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 97 insertions(+), 12 deletions(-) diff --git a/schematron.sch b/schematron.sch index d31f5ab..3714397 100644 --- a/schematron.sch +++ b/schematron.sch @@ -1,5 +1,5 @@ - + Schema for Additional Constraints in Schematron This schema supplies some constraints in addition to those given in the @@ -29,29 +29,39 @@ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD." (RELAX NG Compact Syntax) Schema for Schematron. - The pattern + The pattern attribute of the active element shall match the id attribute of a pattern. - The + The is-a attribute of a pattern element shall match the id attribute of an abstract pattern. + The + name attribute of a pattern param element shall match + the id attribute of an abstract pattern param element. + + - The rule + The rule attribute of an extends element shall match the id attribute of an abstract rule. - A variable name and an abstract pattern parameter should not use the same name. + + A parameter name should not use the same name as a parameter in the same scope. + diff --git a/schematron.xspec b/schematron.xspec index e2d7cd7..facfa84 100644 --- a/schematron.xspec +++ b/schematron.xspec @@ -7,14 +7,39 @@ --> - - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8e62512588285fe632381e998eb5e26490eede39 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 17 Mar 2024 12:25:29 +0000 Subject: [PATCH 13/25] [MOD] rules and unit tests in support of abstract pattern parameters, re https://github.com/Schematron/schematron-enhancement-proposals/issues/8 --- schematron.sch | 32 +++++++++++++++++++------------- schematron.xspec | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/schematron.sch b/schematron.sch index 3714397..a744936 100644 --- a/schematron.sch +++ b/schematron.sch @@ -21,7 +21,9 @@ THIS SCHEMA HAS BEEN MODIFIED FROM THE SCHEMA DEFINED IN ISO/IEC 19757 3, AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD." --> - + + Schema for Additional Constraints in Schematron This schema supplies some constraints in addition to those given in the @@ -33,18 +35,6 @@ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD." attribute of the active element shall match the id attribute of a pattern. - - The - is-a attribute of a pattern element shall match - the id attribute of an abstract pattern. - - The - name attribute of a pattern param element shall match - the id attribute of an abstract pattern param element. - - - The rule attribute of an extends element shall match the id @@ -64,4 +54,20 @@ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD." id="param-name">A parameter name should not use the same name as a parameter in the same scope. + + + The + is-a attribute of a pattern element shall match + the id attribute of an abstract pattern. + + The + name attribute of a pattern param element shall match + the id attribute of an abstract pattern param element. + + + + A pattern parameter value shall be specified. + + diff --git a/schematron.xspec b/schematron.xspec index facfa84..d10bfbe 100644 --- a/schematron.xspec +++ b/schematron.xspec @@ -39,6 +39,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -88,7 +108,7 @@ location="/sch:schema/sch:pattern[@id='bar']/sch:param[1]"/> - + @@ -107,5 +127,20 @@ id="param-names-match" location="/sch:schema/sch:pattern[@id='p7']"/> + + + + + + + From 34105800f60154c6af8d61dcc5b6a2786551b25e Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 17 Mar 2024 12:27:52 +0000 Subject: [PATCH 14/25] [FIX] typo --- schematron.sch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schematron.sch b/schematron.sch index a744936..fee6df6 100644 --- a/schematron.sch +++ b/schematron.sch @@ -63,7 +63,7 @@ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD." The name attribute of a pattern param element shall match - the id attribute of an abstract pattern param element. + the name attribute of an abstract pattern param element. From 16efc79d06ac0ebe25659ab49289b278923d2ba8 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 17 Mar 2024 14:52:27 +0000 Subject: [PATCH 15/25] [MOD] require schema param value, re https://github.com/Schematron/schematron-enhancement-proposals/issues/34 --- schematron.sch | 3 +++ schematron.xspec | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/schematron.sch b/schematron.sch index fee6df6..7d3db6f 100644 --- a/schematron.sch +++ b/schematron.sch @@ -69,5 +69,8 @@ AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD." A pattern parameter value shall be specified. + + A schema parameter value shall be specified. + diff --git a/schematron.xspec b/schematron.xspec index d10bfbe..cceb6d3 100644 --- a/schematron.xspec +++ b/schematron.xspec @@ -142,5 +142,21 @@ id="missing-param-value" location="/sch:schema/sch:pattern[@id='p12']/sch:param"/> + + + + + + + + + + + + From 684253c339ca122e706a68e8a3aabcede30b9bb6 Mon Sep 17 00:00:00 2001 From: Andrew Sales Date: Sun, 17 Mar 2024 19:38:18 +0000 Subject: [PATCH 16/25] [MOD] date --- svrl.sch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svrl.sch b/svrl.sch index e7acb17..e3cf7ee 100644 --- a/svrl.sch +++ b/svrl.sch @@ -1,5 +1,5 @@