XML
  Home arrow XML arrow 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


    (Page 1 of 4 )

    If you use XML schema languages, you should consider Schematron. This powerful rule-based language lets you make distinctions which other languages find difficult or even impossible to handle. Best of all, you can use it in conjunction with other schema languages. This is the first part of a three-part series.

    XML schema languages

    XML schema languages are important because they allow multiple parties to exchange information in a standardized way. Any party, by reading the schema definition, will know what to expect in an XML document validated against the schema. A number of XML schema languages currently exist, created with different objectives in mind, with the newer languages attempting to remedy the faults of the older languages.

    XML Schema is the W3C-recommended schema language. In it, you can define exactly which elements and attributes can appear in an XML document, exactly what order they'll appear in, and exactly which types of data they can contain. This makes XML Schema a grammar-based schema language because it deals with the structure of things, just as grammar deals with the structure of things in spoken languages.

    Often, however, structure isn't enough, and different kinds of constraints need to be introduced. Pieces of data in an XML document often have special relationships which should be validated, for example. Consider an XML document that describes the residents of a given area. Each resident could be represented by a resident tag, and under each resident tag could be an age tag and an eligible_to_vote tag that would indicate whether or not the resident is eligible to vote in an election. Of course, ordinarily, more data would be described, but let's keep it simple for the purpose of this example. The markup might look something like this:


    <?xml version="1.0" encoding="utf-8"?>

    <residents>

    <resident>

    <age>37</age>

    <eligible_to_vote>yes</eligible_to_vote>

    </resident>

    <resident>

    <age>14</age>

    <eligible_to_vote>yes</eligible_to_vote>

    </resident>

    </residents>


    Notice, however, that there's something wrong. The second resident is only fourteen years old yet is eligible to vote. I know of no area where this is legal. As a result, the markup really isn't "valid" even though its structure might be valid according to a grammar-based schema language.

    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 4 Hosted by Hostway
    Stay green...Green IT