XML
  Home arrow XML arrow Page 2 - Using Schematron
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Using Schematron
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-01-07

    Table of Contents:
  • Using Schematron
  • Schematron, a rule-based schema language
  • Making assertions
  • Rules

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Schematron - Schematron, a rule-based schema language


    (Page 2 of 4 )

    This is where Schematron comes in. Not all schema languages are grammar-based. Schematron is, instead, a rule-based language. In XML Schema, you define precisely the structure of an XML document, explicitly stating what is allowed in the document. By contrast, in Schematron, you define a set of patterns that will be looked for in an XML document, with each pattern containing one or more rules, and each rule containing assertions (we'll discuss exactly what all this means later).

    You can use XPath expressions to define what to check for in a given XML document. This allows you to deal with much more than just the structure of an XML document. For example, in the XML document described earlier, we could have set constraints on the relationship between the age and eligible_to_vote elements. We could have said, "If the resident's age is below 18, then the resident should not be able to vote." Or, in the context of the document, "If the text of the age element is less than 18, then the text of the eligible_to_vote element should be 'no'." This is an example of an assertion.

    However, there is nothing wrong with using XML Schema or any other grammar-based language, and Schematron does not seek to replace any such languages. In fact, rather than having to choose between Schematron and, for example, XML Schema, it's possible to use Schematron in conjunction with XML Schema. In the XML document we looked at earlier, we could have defined the structure with XML Schema, and we could have defined the relationship between age and eligibility to vote in Schematron. This makes for a very powerful and easy-to-use tool set. Note, however, that just because Schematron is powerful, it isn't difficult to work with. It's actually very simple, with only a few core elements defined.

    It's not hard to validate a document against a Schematron schema definition, either. Several implementations exist, but the "skeleton" implementation uses XSLT. So a document can be validated using any XML transformer, such as Saxon. This also allows the output to be given in a variety of formats.

    More XML Articles
    More By Peyton McCullough


     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek