Home arrow XML arrow Page 4 - More Schematron Features
XML

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
TABLE OF CONTENTS:
  1. · More Schematron Features
  2. · More on assertions
  3. · Declaring variables with the let element
  4. · Phases
  5. · Diagnostics

print this article
SEARCH DEVARTICLES

More Schematron Features - Phases
(Page 4 of 5 )

Assertions can be grouped into rules, and rules can be grouped into patterns. In a similar way, patterns can be grouped into what are called phases. However, phases are different from rules and patterns in that a single pattern can belong to more than one phase. This is because a phase is declared differently from rules and patterns. Instead of containing the patterns themselves, a phase is populated with patterns using the active element, which represents a pattern active within a phase.

Phases allow for different “versions” of a schema. When the document is validated, the user may be able to select which phase to use. When a phase is chosen, then only the active patterns within that phase will be used to validate the document.

Creating a phase is easy. You simply need to use the phase element and set the id attribute in order to give the phase a unique identifier. Below, we create a phase by the name of “phase1”:


<phase id="phase1">
    ...
</phase>


In order to add a pattern to a phase, the active element is used. The only attribute of the active element is pattern, which is set to the identifier of the pattern you wish to add. Below, we add a pattern named “pattern1” to the phase:


<phase id="phase1">
    <active pattern="pattern1"/>
</phase>


If this phase is used for validation, only pattern1 will be used to validate the document because it is the only active pattern within the phase. All other patterns are inactive.

The names “#ALL” and “#DEFAULT” cannot be used to name a phase. The former is used to indicate that all phases are active. This is the default behavior if no particular phase is specified. The latter is used to indicate that the default phase is active. You can set the default phase of a schema by setting the defaultPhase attribute of the schema element:


<schema xmlns="http://purl.oclc.org/dsdl/schematron" defaultPhase="phase1">


By default, phase1 will be used for validating a document using the schema.


blog comments powered by Disqus
XML ARTICLES

- 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 
Support 

Developer Shed Affiliates

 




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