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
0
votes
1 answer
0
votes
1 answer

How to see xpath location of error when doing XSD or RelaxNG validation?

We're generating HTML preview of an XML schema (EAD 2002) and want to embed validation errors as hovers/tooltips in the respective HTML location. We've done it for some custom Schematron rules (which output SVRL that includes the xpath location of…
Vladimir Alexiev
  • 2,477
  • 1
  • 20
  • 31
0
votes
1 answer

"instance of" equivalent in Schematron/XPath

I have found that Saxon implementation of XPath 2.0 supports both 'instance of' and 'castable as' as valid ways of obtaining the type of a value, as explained in this website. This seems to be a Saxon specific syntax. Does a standard way of…
Yampeku
  • 583
  • 1
  • 4
  • 21
0
votes
1 answer

Schematron XPath : Can I split a string attribute acting like a list in a Schematron?

I'm trying to verify that all idRef of a list written in a single attribute are already declared ids. Here is an example :
Miken
  • 23
  • 4
0
votes
2 answers

Schematron validation and uniqueness

I'm trying to write some Schematron rules and one of them is supposed to check, if elements are unique in the scope of parent element. So I have an example xml structure: 1 2 3
Marcin Cylke
  • 2,100
  • 2
  • 21
  • 40
0
votes
1 answer

Schematron bad pattern with sibling

Hi I have XML like this: 2 1
0
votes
2 answers

Schematron validating count of element value

Assume I have an XML document defining: 1 2 2
Marc
  • 174
  • 4
  • 12
0
votes
2 answers

XML Schema - Only one of elements can have an attribute

I have a struggle with XSD schema. I want to put a restriction where only one of the element within a node can have the cetrain arttribute and don't affect the other one. Giving you an example of valid and invalid XML files would be better: Valid…
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
0
votes
1 answer

Schematron assert statement had been fired; where did that happen in the document?

I would like to highlight certain parts of XML documents after using multiple validation techniques. Locating XSD validation failures in the XML poses no problem, the erroneous lines can be tracked. However, some validation steps are done by…
Pydan
  • 57
  • 10
0
votes
0 answers

Xml validation with xsl

i have been trying to validate xml through xslt for couple of hours. i have following xsl form for xml validation. every time i try to validate xml, i get following warnings below and empty currencyid attributes in xml are ignored and xml validate…
Runomu
  • 411
  • 1
  • 8
  • 18
0
votes
2 answers

How can I replace special characters with Schematron

How can I replace special characters and spaces in an attribute? I tried various regular expressions but none of them worked as aspected.
Stefan Jung
  • 1,209
  • 11
  • 20
0
votes
2 answers

How to determine if there is text at a node with xpath/schematron

I'm looking for a way to write an xpath/schematron test to identify a specific node any time it contains any sort of non-white space, unwrapped text anywhere directly within the node (meaning possibly among, but not in a child element). So if my…
wolfmason
  • 399
  • 1
  • 13
0
votes
1 answer

line breaks and spaces in XML Schematron

I have a problem. I have linebreaks and spaces and tabs in XML. Like this: 1111\this is what it is used for, this could be a really long line or even multiple lines, just like what you are reading…
Bert Verhees
  • 1,057
  • 3
  • 14
  • 25
0
votes
2 answers

Xpath - how control every element value with others?

EXAMPLE: My XML: 1 1 2 1 2 1 A now, how to control that every "b" element has got only the…
MmM ...
  • 131
  • 1
  • 2
  • 14
0
votes
3 answers

Uri of Schematron

I'm actually trying to validate an xml file against a schematron one in Java. I hava these following statements: SchemaFactory factory = SchemaFactory.newInstance("http://www.ascc.net/xml/schematron"); but when i run the program, i get this…