| 1 |
=head1 NAME |
| 2 |
|
| 3 |
XML::LibXML::Schema - XML Schema Validation |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
use XML::LibXML; |
| 10 |
$doc = XML::LibXML->new->parse_file($url); |
| 11 |
|
| 12 |
$xmlschema = XML::LibXML::Schema->new( location => $filename_or_url ); |
| 13 |
$xmlschema = XML::LibXML::Schema->new( string => $xmlschemastring ); |
| 14 |
eval { $xmlschema->validate( $doc ); }; |
| 15 |
|
| 16 |
=head1 DESCRIPTION |
| 17 |
|
| 18 |
The XML::LibXML::Schema class is a tiny frontend to libxml2's XML Schema |
| 19 |
implementation. Currently it supports only schema parsing and document |
| 20 |
validation. As of 2.6.32, libxml2 only supports decimal types up to 24 digits |
| 21 |
(the standard requires at least 18). |
| 22 |
|
| 23 |
|
| 24 |
=head1 METHODS |
| 25 |
|
| 26 |
=over 4 |
| 27 |
|
| 28 |
=item new |
| 29 |
|
| 30 |
$xmlschema = XML::LibXML::Schema->new( location => $filename_or_url ); |
| 31 |
$xmlschema = XML::LibXML::Schema->new( string => $xmlschemastring ); |
| 32 |
|
| 33 |
The constructor of XML::LibXML::Schema may get called with either one of two |
| 34 |
parameters. The parameter tells the class from which source it should generate |
| 35 |
a validation schema. It is important, that each schema only have a single |
| 36 |
source. |
| 37 |
|
| 38 |
The location parameter allows one to parse a schema from the filesystem or a |
| 39 |
URL. |
| 40 |
|
| 41 |
The string parameter will parse the schema from the given XML string. |
| 42 |
|
| 43 |
Note that the constructor will die() if the schema does not meed the |
| 44 |
constraints of the XML Schema specification. |
| 45 |
|
| 46 |
|
| 47 |
=item validate |
| 48 |
|
| 49 |
eval { $xmlschema->validate( $doc ); }; |
| 50 |
|
| 51 |
This function allows one to validate a (parsed) document against the given XML |
| 52 |
Schema. The argument of this function should be a L<<<<<< XML::LibXML::Document >>>>>> object. If this function succeeds, it will return 0, otherwise it will die() |
| 53 |
and report the errors found. Because of this validate() should be always |
| 54 |
evaluated. |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
=back |
| 59 |
|
| 60 |
=head1 AUTHORS |
| 61 |
|
| 62 |
Matt Sergeant, |
| 63 |
Christian Glahn, |
| 64 |
Petr Pajas |
| 65 |
|
| 66 |
|
| 67 |
=head1 VERSION |
| 68 |
|
| 69 |
2.0134 |
| 70 |
|
| 71 |
=head1 COPYRIGHT |
| 72 |
|
| 73 |
2001-2007, AxKit.com Ltd. |
| 74 |
|
| 75 |
2002-2006, Christian Glahn. |
| 76 |
|
| 77 |
2006-2009, Petr Pajas. |
| 78 |
|
| 79 |
=cut |
| 80 |
|
| 81 |
|
| 82 |
=head1 LICENSE |
| 83 |
|
| 84 |
This program is free software; you can redistribute it and/or modify it under |
| 85 |
the same terms as Perl itself. |
| 86 |
|