Schematron is so simple that all of its basics fit in 20 pages! It is time to put this newfound knowledge into practice and get some real work done. The recipes that constitute this second part are derived from real world use cases. I hope that some of them will match cases that you have already encountered, or even better, that you need to solve right now. However, you will also run into cases that do not correspond to any of these recipes. If this happens, you should still be able to adapt the different techniques mentioned here. I invite you to go through these recipes, even if they solve issues that are different from those that you need to solve right now!
Avoiding Embedded Structures
In document-oriented applications such as XHTML, DocBook, TEI, DITA, and so on, it is often the case that some elements cannot be embedded within themselves. For instance, you probably want to forbid paragraphs that include a link within a link.
With a grammar-based schema language, the solution is to define two different content models: a content model for a paragraph and a content model for a link. These models are the same except that links are allowed in paragraphs but are forbidden within other links.
So far so good, but if you want to forbid bold within bold, you need to define four different content models: paragraph, link, bold, and bold in link, where both bold and link are forbidden. If you also want to forbid italic within italic, you need to define paragraph, link, bold, italic, ...