A question recently came up on the difference between the @role attribute and the @flag attribute in Schematron.
Both these attributes provide extra information that can be found in the SVRL (Schematron Validation Report Language) result of a validation.
- The @role attribute lets you provide extra information about the local significance of that individual assertion success or failure. Typically, for error severity. I recently devoted a blog entry to this: see
- The @flag attribute lets you provide extra information about what the global significance of the assertion success or failure. Typically, for feature extraction. The flag attribute is information about a document, to allow specific processing, filtering, collation or counting of that document compared to other documents.
So if you want to say “How do I categorize this particular assert failure or successful report?” then you would should the role attribute. Typically this relates to severity. But if you want to say “How do I categorize the impact of this particular assert failure or successful report on the whole document?” then you should use the flag attribute (by testing the whole SVRL result for any occurrence.)
So lets say we have
<sch:report test="@nationality='italian'" id="I1" role="This-person-is-italian"
flag="This-document-has-an-italian">Italians are interesting.</sch:report>
Then in the SVRL output we will get (on an Italian)
<svrl:successful-report id="I1" location="//person" role="This-person-is-italian"
SVRL does not bring out the difference between role and flag, and the intent is not
clear from reading the SVRL document: it would be better if SVRL jus had a list of
the raised flags at the very start or end (however this was inconvenient to implement
without assignment in functional XSLT with a fixed API. ) Instead, in the SVRL a
raised flag is transferred on the assertion that raised the flag. The difference
is that the flag evaluation function should be considered a boolean function on the
whole SVRL result
/svrl:schematron-output//*[@flag="This-document-has-an-italian"] that primarily expresses some feature summarized about the input document. For example,
so that you can redirect documents containing any Italian people for some special