XML::Li...::Schema(3)
β¨ NAME β¨
XML::LibXML::Schema β XML Schema Validation, bestie π (it's the manual page for XML::LibXML::Schema(3), in case you were wondering)
πΈ SYNOPSIS πΈ
use XML::LibXML;
$doc = XML::LibXML->new->parse_file($url);
$xmlschema = XML::LibXML::Schema->new( location => $filename_or_url, no_network => 1 );
$xmlschema = XML::LibXML::Schema->new( string => $xmlschemastring, no_network => 1 );
eval { $xmlschema->validate( $doc ); };
π¦ DESCRIPTION π¦
Okay so XML::LibXML::Schema is literally just a tiny little frontend to libxml2's XML Schema implementation β like, it's giving minimal, it's giving humble, and we love that for it π«Ά
Right now it only does two things: schema parsing and document validation. That's it. That's the whole vibe. No cap.
Heads up bestie π as of 2.6.32, libxml2 only supports decimal types up to 24 digits β and the standard requires at least 18. So likeβ¦ it's fine, but it's not exactly main character energy in the decimal department. The math girlies know.
π METHODS π
π new
$xmlschema = XML::LibXML::Schema->new( location => $filename_or_url, no_network => 1 );
$xmlschema = XML::LibXML::Schema->new( string => $xmlschemastring, no_network => 1 );
The constructor of XML::LibXML::Schema has to be called with a list of parameters, okay? Like, it needs the tea.
At least location or string is required, because you gotta specify the source of the schema β no source, no schema, periodt.
- the optional parameter
no_networkset to1causes the parser to not access the network π«π - the optional parameter
recoverset to1causes the parser to not calldie()on errors π
It is important β and I cannot stress this enough β that each schema only have a single source. One source. Just one. We don't do polygamy here π
The location parameter lets you parse a schema from the filesystem or a (non-HTTPS) URL. Note the non-HTTPS part, bestie, that's not a typo β¨
The string parameter will parse the schema from the given XML string π
Also β and this is the part that gets people every time β the constructor will die() if the schema does not meet the constraints of the XML Schema specification. Like it will literally perish. So maybe wrap it, iykyk π
π validate
eval { $xmlschema->validate( $doc ); };
This function lets you validate a (parsed) document against the given XML Schema. Iconic behaviour honestly π
The argument of this function should be an XML::LibXML::Document object β that's the one it wants, don't hand it anything weird.
If this function succeeds, it will return 0. If it doesn't succeed, it will die() and report the errors it found. Which meansβ¦ validate() should always be evaluated. Always. Wrap it in an eval, bestie, protect your peace π«Ά
π AUTHORS π
Matt Sergeant, Christian Glahn, Petr Pajas
(the founding mothers and fathers of this whole situation, we stan)
β VERSION β
2.0213
π COPYRIGHT π
2001-2007, AxKit.com Ltd.
2002-2006, Christian Glahn.
2006-2009, Petr Pajas.
πΈ LICENSE πΈ
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Slay. Go forth and redistribute π
and that's the whole page, bestie πβ¨ this manual came from perl v5.42.2 and it was dated 2026-05-25 β XML::Li...::Schema(3), we love her, she ate, no crumbs left π π
π¦ where this page comes from
- fedora 43: perl-XML-LibXML 1:2.0213-1.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- fedora 44: perl-XML-LibXML 1:2.0213-1.fc44 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms