![]() |
![]()
| ![]() |
![]()
NAMEXML::Schematron::LibXSLT - Perl extension for validating XML with XPath/XSLT expressions. SYNOPSISuse XML::Schematron; my $pseudotron = XML::Schematron->new_with_traits( traits => ['LibXSLT'], 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::LibXSLT->new(schema => 'my_schema.xml'); my @messages = $pseudotron->verify('my_doc.xml'); OR, just get the generated xsl: my $pseudotron = XML::Schematron::LibXSLT->new(schema => 'my_schema.xml'); my $xsl = $pseudotron->dump_xsl; # returns the internal XSLT stylesheet. DESCRIPTIONXML::Schematron::LibXSLT 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: <?xml version="1.0" ?> <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) < 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
CONFORMANCEInternally, XML::Schematron::LibXSLT uses the Gnome Project's XSLT proccessor via XML::LibXSLT, the best XSLT library available to the Perl World at the moment. For those platforms on which libxslt is not available, please see the documentation for XML::Schematron::XPath (also in this distribution) for alternatives. AUTHORKip Hampton, khampton@totalcinema.com COPYRIGHTCopyright (c) 2000-2010 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 ALSOFor information about Schematron, sample schemas, and tutorials to help you write your own schmemas, please visit the Schematron homepage at: <https://www.schematron.com/> For information about how to install libxslt and the necessary XML::LibXSLT Perl module, please see <http://xmlsoft.org/XSLT/> and CPAN, repectively. For detailed information about the XPath syntax, please see the W3C XPath Specification at: <http://www.w3.org/TR/xpath.html>
|