Home arrow XML arrow Page 2 - More Schematron Features

More Schematron Features

In my last two articles, I covered the basics of Schematron—enough of it to create a basic schema with assertions, rules and patterns. However, there is more to Schematron than was covered in those articles, and some of Schematron's other features are very useful and worth mentioning. In this article, we'll take a look at more of Schematron's features, delving deeper into the Schematron schema language.

Author Info:
By: Peyton McCullough
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
January 22, 2009
  1. · More Schematron Features
  2. · More on assertions
  3. · Declaring variables with the let element
  4. · Phases
  5. · Diagnostics

print this article

More Schematron Features - More on assertions
(Page 2 of 5 )

At the assertion level of Schematron, basic assertion functionality is provided by the assert element. An assertion made using this element can either be met or unmet, and if unmet, then validation fails. That's not all that can be done on the assertion level, though.

Going back to the assert element, a message is given if the assertion test evaluates to false. So, if something is not found, then the message goes out. There is a similar element that works differently, though. The report element also features an assertion test, but, in this case, if the assertion test evaluates to true (in other words, if something is found), then the message is given. The report element, then, can be seen as the opposite of the assert element.

For example, consider an XML document that deals with animals. Inside of the document is a snake element. Other animals may have legs that are represented using a leg element, but snakes, obviously, do not have legs. We can ensure that this is the case using the report element. If a snake element is found to contain a leg element, then a message needs to be displayed:

<report test="leg">The snake has a leg.</report>

The following XML would cause the above report to give its message:


Removing the leg element would fix the problem.

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials