Questions tagged [schematron]

Schematron is a structural, rule-based validation language for XML documents. It uses XPath and XSLT to validate rules most other schemas can not.

Schematron is a rule-based validation language for XML documents. Schematron allows one to model complex relationships in XML content and to formulate rules that most other schema languages do not support. Schematron is not often used alone but is usually used along with another schema language. In this case, the other language is used to validate the grammar of the XML model and schematron is used to validate business rules.

One of its most powerful mechanisms is sch:assertion, that allows the author of the schema to assert arbitrary XPath expressions and report any content where this assertion failed. To date, XML Schema 1.1 is the only other schema language that supports assertions (while DTD, XML Schema 1.0 and RNG do not).

Although implementations exist that work directly with schematron schemas, the canonical model is to first transform the schema into an style sheet using stylesheets available at the schematron home page which can then be used to validate the input document by transforming it into Schematron Validation Report Language (SVRL), a language used for reporting the results of a schematron validation. Many of the implementations that work directly with schematron follow this canonical model internally.

An additional and highly positive feature of schematron is that the schema writer is free to write their own validation messages. This allows schematron to generate very clear explanatory error messages, a feature missing from other schema languages.

It was invented by Rick Jelliffe and is an ISO Standard. In addition to the main language, the same ISO standard defines the SVRL language used for reporting results of validations.

For a more thorough introduction to Schematron Erik Siegel's book "Schematron: A language for validating XML" might help.

255 questions
4
votes
1 answer

Validate XML with namespaces against Schematron using lxml in Python

I am not able to get lxml Schematron validator to recognize namespaces. Validation works fine in code without namespaces. This is for Python 3.7.4 and lxml 4.4.0 on MacOS 10.15 Here is the schematron file
Craeg Strong
  • 165
  • 10
4
votes
1 answer

Validate an XML against a Schematron using PHP

There are a lot of resources about Schematron... however I cant find anything related or an example on how to validate an xml against a Schematront .sch file. Anyone? I already found 1 or 2 very old classes that return errors... so if anyone knows…
smorhaim
  • 778
  • 1
  • 9
  • 24
4
votes
1 answer

Is there a way to pass a variable in schematron?

I want to use a variable to represent my schematron assertion and use it in my validation message. For example: User: '----' doesn't exist as a…
4
votes
2 answers

Using SAXON 9.5 (nuget) with Schematron

I am running this code: string path = AppDomain.CurrentDomain.BaseDirectory; // Uri schemaUri = new Uri(@"file:\\" + path + @"\sch\patient.sch"); Uri totransformEE = new Uri(@"file:\\" + path + @"\po\po-schema.sch"); …
jlo-gmail
  • 4,453
  • 3
  • 37
  • 64
4
votes
1 answer

Can external scripts be used inside Schematron rules?

Is there a way to call Javascript functions in a Schematron rules file? I'm pretty sure that the engine takes the rules file and generates an XSLT from it but was wondering if I can somehow include scripts in that rules file that will ultimately…
Fred Strauss
  • 1,435
  • 2
  • 13
  • 21
4
votes
1 answer

Validate XML with Schematron in PHP 5

I have a problem with validating XML with schematron. In my code I load the XML and XSL as DOMDocument objects and I try to transform: $domSche = new DOMDocument(); $domSche->loadXML($message); $domXSLSche = new…
Prolasky
  • 55
  • 5
3
votes
1 answer

Cannot generate a valid XSL stylesheet from a Schematron schema using a java XSLT processor

I am attempting to validate my instance documents with schematron and having trouble with Java XSLT processor implementations. When I try to generate an XSL from my schematron, even a simple one, I get different results from what I expect to get.…
predi
  • 5,528
  • 32
  • 60
3
votes
0 answers

How to use schematron validation in Visual Studio?

I would like to validate a XML file against a schematron file I've. Is it possible to do it via Visual Studio 2010? When I open XML file in Visual Studio, I am able to add XSD files which have schema defined but I would like to validate against…
user837208
  • 2,487
  • 7
  • 37
  • 54
3
votes
1 answer

How to check in xPath if a type is equal to a type or derived from the type

I'm working with xPath inside Schematron. I'm able to check that a type is equal to a target type. For example 'xsd:string eq xsd:string'.
3
votes
3 answers

How do I return Schematron validation results in a structured manner

I have created several Schematron assertations and they are all running fine against my XML instances. However, I would like to structure the output of my error messages in such a way, that I later can post-process them, with e.g., Java. The output…
Philipp
  • 538
  • 6
  • 14
3
votes
2 answers

In a Schematron rule, how do i access the parent element of the current element?

I am using ISO Schematron to validate an XML document. The rule I have set works as required, but I want to report the name of the parent element from the context of where my assertion is fired. A sample document might contain the XML…
Wee Shetland
  • 955
  • 8
  • 18
3
votes
0 answers

Can Schematron support parameters?

I am trying to pass in several parameters to a scheatron xlst transform, I can declare local variables and read from a file but that still means that I am either hard-coding or using a relative path to the execution location. Does anyone know of a…
3
votes
0 answers

Is there a way to use loops in Schematron?

I am new to Schematron, however I have searched and am coming up empty handed. I have an external file that identifies the required content sections. I can retrieve them and get a count on how many there are, however I have not figured out how to…
3
votes
0 answers

Validate an XSD with Schematron to see if any instance document would conform

I've used Schematron to validate XML documents before. However, I now have a new use case I'm wondering about. Does anyone know of any XSLT or Schematron Processor that can be used to validate an XSD (rather than an instance doc) in order to…
LTZJoe
  • 86
  • 6
3
votes
2 answers

Schematrion case-insensitive sqf:stringReplace

I have created a schematron rule that searches for a particular text given by a variable in a case-insensitive manner (provided by "i" flag):
proxx
  • 61
  • 3
1
2
3
16 17