XML::Schematron::Sablotron - Perl extension for validating XML with XPath/XSLT expressions.


NAME

XML::Schematron::Sablotron - Perl extension for validating XML with XPath/XSLT expressions.


SYNOPSIS

  use XML::Schematron::Sabotron;
  my $pseudotron = XML::Schematron::Sablotron->new(schema => 'my_schema.xml');
  my $messages = $pseudotron->verify('my_doc.xml');
  if ($messages) {
      # we got warnings or errors during validation...
      ...
  }
  OR, in an array context:
  my $pseudotron = XML::Schematron::Sablotron->new(schema => 'my_schema.xml');
  my @messages = $pseudotron->verify('my_doc.xml');
  OR, just get the generated xsl:
  my $pseudotron = XML::Schematron::Sablotron->new(schema => 'my_schema.xml');
  my $xsl = $pseudotron->dump_xsl; # returns the internal XSLT stylesheet.


DESCRIPTION

XML::Schematron::Sablotron serves as a simple validator for XML based on Rick JELLIFFE's Schematron XSLT script. A Schematron schema defines a set of rules in the XPath language that are used to examine the contents of an XML document tree.

A simplified example:

 <schema>
  <pattern>
   <rule context="page">
    <assert test="count(*)=count(title|body)">The page element may only contain title or body elements.</assert> 
    <assert test="@name">A page element must contain a name attribute.</assert> 
    <report test="string-length(@name) &lt; 5">A page element name attribute must be at least 5 characters long.</report> 
   </rule>
  </pattern>
 </schema>

Note that an 'assert' rule will return if the result of the test expression is not true, while a 'report' rule will return only if the test expression evalutes to true.


METHODS

new()

The 'new' constructor accepts the following "named" arguments:


CONFORMANCE

Internally, XML::Schematron::Sablotron uses the Sablotron XSLT proccessor and, while this proccessor is not 100% compliant with the XSLT spec at the time of this writing, it is evolving quickly and is very near completion. It is therefore possible that you might use a completely valid XSLT expression within one of your schema's tests that will cause this module to die unexpectedly.

For those platforms on which Sablotron is not available, please see the documentation for XML::Schematron::XPath (also in this distribution) for an alternative.


AUTHOR

Kip Hampton, khampton@totalcinema.com


COPYRIGHT

Copyright (c) 2000 Kip Hampton. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


SEE ALSO

For information about Schematron, sample schemas, and tutorials to help you write your own schmemas, please visit the Schematron homepage at: http://www.ascc.net/xml/resource/schematron/

For information about how to install Sablotron and the necessary XML::Sablotron Perl module, please see the Ginger Alliance homepage at: http://www.gingerall.com/

For detailed information about the XPath syntax, please see the W3C XPath Specification at: http://www.w3.org/TR/xpath.html

 XML::Schematron::Sablotron - Perl extension for validating XML with XPath/XSLT expressions.