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
3
votes
2 answers

How to test for a non-existent element in Schematron

Is it just me or is it impossible to look for a non existent element via Schematron. I also don't seem to be able to find any documentation on this as well. Take the following rule:
user898465
  • 944
  • 1
  • 12
  • 23
3
votes
2 answers

XPath in Schematron: How to determine if an xmlns attribute is present on a node

I'm trying to match any instance of a specific element that lacks an xmlns attribute, but I'm having trouble getting a match with the syntax. My xml is as shown: I want to…
wolfmason
  • 399
  • 1
  • 13
3
votes
1 answer

Using Schematron to identify a space as first character in element

Is it possible to write a schematron rule/assertion that will identify a space(s) at the start of an element? I need a way to flag elements that begin with a space for possible removal of the space, but I don't want to forcibly remove such spaces…
wolfmason
  • 399
  • 1
  • 13
3
votes
0 answers

Validating XML file with XML::Schematron::LibXSLT

I want to verify XML file using XML::Schematron::LibXSLT here is code i tried which uses .sch schemafile and XML file as argument use XML::Schematron::LibXSLT; my $schema_file = $ARGV[0]; my $xml_file = $ARGV[1]; die "Usage: perl schematron.pl…
waghso
  • 623
  • 7
  • 23
3
votes
3 answers

Validating XML with Schematron

I am trying to validate an XML file with Schematron, which is more complicated than XSD. I googled a lot and the best thing that came up is this Microsoft website. But that only shows how to validate with XSD with NMatrix.Schematron which is not…
Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189
3
votes
1 answer

command line validator supporting relax ng Schemas with embedded iso Schematron

Are there any command line-validators that can cope with relax ng-Schemas with embedded iso schematron? I've got a couple of relax ng-schemas with embedded iso-schematron rules which I have to be able to validate on the command line. As it seems,…
Schweutsch
  • 31
  • 4
3
votes
0 answers

XML Validation: XSD or Schematron?

I need to tighten validation on a moderately complex schema (SAML Metadata) comprising approx. 10 XSD files giving 1000 lines of schema definition. The validation should primarily require optional elements and attributes, restrict node and attribute…
rhoerbe
  • 463
  • 1
  • 4
  • 17
3
votes
1 answer

Implementing schematron rules

I am new with schematron and I have the following problem. This is the snippet from xhtml file: