Home | Login | Blog | Forum | Download | RSS Feed | Ajax | Hello-World | J2EE | BPM | EJB | FileNet | Hibernate | ORM | IBM | ILOG | Interview | FAQs |

Java | Apache | JVM | Others | BRMS | Oracle | Pega | SOA | Sun-Certification | Web-Service | websphere | XML |
 

JAVA DEVELOPER SITE - COMPLETE JAVA TUTORIALS

Schema­tron: What is Schema­tron & how it is used ?


Share
 
 

Useful Java Links


       


Schematron

 

§  Schematron is useful whenever you wish to apply and check against rules for the contents of XML documents. Used for business rule validation.

§  A Schematron schema is made up of elements in the  http://www.ascc.net/xml/schematron namespace.

§   Root element has a local name of schema. Schema element should have a descriptive title element.

§  An XML document to be validated with the Schematron rules is a candidate instance or document.

§  Each rule contains a set of individual checks represented using assert or report elements. Rules are organized using pattern elements that contain collections of related rule elements. Rules and patterns can also have descriptive title elements.

§  A Schematron processor operates by examining in document order each node in the candidate instance. For each element, it checks all the patterns, and executes rules that are appropriate for that element. It executes no more than one rule in each pattern.

§   Each rule has a context attribute that determines which elements will trigger that rule.

§  When a rule is fired, the Schematron processor checks for assertions and  reports declared in the body of the rule. An assertion is an XPath expression that you expect to evaluate to true using the rule's context in a valid document. An assert element has a test attribute with the XPath expression; the body of the element is a brief message that expresses the condition that is expected to be true.  assert test allows you to express validation constraints.

§   report is processed very similarly to assert except that the report message is triggered when the boolean value of the test attribute is true, rather than false.  . report instruction that is intended to allow you to trigger more general reporting tasks.

§  Schematron is used for various purposes, some are as follows :-

·         Validating the presence of elements

·         Validating that elements are where expected

·         Validating relative positioning of elements

·         Validating a sequence of elements

·         Validating for a certain number of elements

·         Validating presence and value of attributes

·         Simple validation of element content

·         Validating exclusivity of elements

 

§  Sample program to show the power of  Schematron.:-

 

            Below is sample XML file need to validated

__________________________________________________ 

 

book.xml

 

<?xml version="1.0"?>
<catalog>
   <book id="bok101">
      <author>Gambardella, Matthew</author>
      <title>SCJP</title>
      <genre>Computer</genre>
      <price>495</price>
      <publish_date>2010-10-01</publish_date>
      <description>Sun certified Java programming reference .</description>
   </book>
   <book id="bok102">
      <author>Ralls, Kim</author>
      <title>XML Reference</title>
      <genre>Fantasy</genre>
      <price>595</price>
      <publish_date>2008-12-16</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
</catalog>
 ___________________________________________________
Sample  Schematron for book.xml
 ___________________________________________________

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

<schema xmlns="http://www.ascc.net/xml/schematron">

<title>Schematron for Book catalog</title>

<pattern name="Document root and presence of elements ">

<rule context="/">

<assert test="catalog">Root element should be "doc".</assert>

</rule>

<assert test="book">

The "doc" element must have a "prologue" child.

</assert>

</pattern>

<pattern name="relative position of element">

<rule context="/book/author">

<assert test="not(preceding-sibling::title)">

No "title" may occur before the "author".

</assert>

</rule>

</pattern>

 <pattern name="Minimum number of books in catalog">

<rule context="catalog">

<assert test="count(book) > 1">

At least two books are required in catalog.

</assert>

</rule>

</pattern>

<pattern name="Author attributes">

<rule context="/book">

<assert test="@id">

book must have id attribute.

</assert>

</rule>

</pattern>

</schema> 

 ___________________________________________________



Download Latest Java/J2EE eBooks, SCJP Dumps, SCWCD Dumps, Pega Tutorial, IBM WebSphere BPM tutorials and many more


If you need any urgent assistance on schematron-tutorials-source-code-samples, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.

You can also subscribe to our newsletters on schematron-tutorials-source-code-samples, to receive updates on schematron-tutorials-source-code-samples,via email.Enter you email below:

Enter your email address:

Delivered by FeedBurner



Keyword Tags: schematron-tutorials-source-code-samples tutorial,schematron-tutorials-source-code-samples in java,Concepts of schematron-tutorials-source-code-samples,Java,J2EE,Interview Questions,schematron-tutorials-source-code-samples Examples


Comments:


Post Your Comment:

*

Yes, I would like to recieve email notifications on my reply.

Popular Posts:

 
Popular Downloads

SCJP 1.6 Dumps
JSP Interview Questions
Struts Interview Questions
Hibernate Interview Questions
SCWCD Dumps
SCBCD Dumps

Java/J2EE Tutorial
JMS Tutorials
seam richfaces tutorial
richfaces live demo
jquery example demo
JQuery Tutorial and Source Code
JSF Tutorial
XSL Tutorial
J2EE JMS
CORBA Applications
Java CERTIFICATION
SCJP 1.5
SCJP 1.6
SCWCD 1.5
SCBCD
Mis
Ajax autosuggest autocomplete from database
Struts forms and validation with webflow
Java Apache POI Examples
JDBC Tutorial
Oracle 9i & 10g
MYSQL Tutorial
php Tutorial
JQuery Examples
Upload Java File
JAXB Examples
PL-SQL Tutorial
Dojo AJAX
EJB Examples
Java IDE
Eclipse
NetBeans
IBM Rational Weblogic Workshop
Downloads
SCJP 1.6 Dumps
SCJP 1.5 DUMP
SCJP Material
SCWCD
Java Security
SCBCD Dumps
External Links
SUN Java
JOracle
IBM
PHP Certification
Technical Interview Questions
Amazon Interview Questions
Google Interview Questions
Microsoft Interview Questions
IBM Interview Questions
Yahoo Interview Questions
All Tutorials
php mysql tutorial
SCJP 1.5/1.6
SCWCD 1.5/1.6
Polymorphism
Thread Tutorial
Generics & Exceptions
Spring Struts Hibernate
Java Collections
MAP
SET
LIST
VECTOR
Advanced Java
Stateless Session Bean
Introduction to EJB
Stateful Session Bean
Java Design Patterns
HOME | FORUM | ABOUT | BLOGS | CONTACT-US