XML::V...:LibXML(3pm)

πŸ“¦
version 1.025 Β· 2 versions
  • 1.025 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.025 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– XML::V...:LibXML πŸ’–

okay bestie, welcome to the manual page for XML::V...:LibXML, part of the User Contributed Perl Documentation collection. it's a 3pm page, which is perl-speak for "a module doc, babes". grab a strawberry πŸ“ and let's get into it.


✨ NAME ✨

XML::Validate::LibXML β€” literally just the interface to the LibXML validator, no cap πŸ¦‹


🌸 SYNOPSIS 🌸

the vibe in code form, keep it verbatim:

  my $validator = new XML::Validate::LibXML(%options);
  if ($doc = $validator->validate($xml)) {
    ... Do stuff with $doc ...
  } else {
    print "Document is invalid\n";
  }

πŸŽ€ DESCRIPTION πŸŽ€

so XML::Validate::LibXML is an interface to the LibXML validating parser, and the whole point of it is that you can use it together with the XML::Validate module. it's giving "team player", it's giving "I play nice with others" πŸ’…


πŸ‘‘ METHODS πŸ‘‘

new(%options)

returns you a brand new XML::Validate::LibXML instance, made with whatever options you passed in. (peep the OPTIONS section below, bestie, that's where the good stuff lives.)

validate($xml)

returns a true value if $xml could be successfully parsed, and undef otherwise.

returns a true (XML::LibXML::Document) if $xml could be successfully parsed, and undef otherwise.

last_dom()

hands you the DOM (XML::LibXML::Document) of the document that got validated last. the most recent one. the freshest one. periodt ✨

last_error()

returns a hash ref holding the error from the last validate call. rn this backend only fills in the message field of that hash, jsyk. and important: the error gets cleared at the beginning of every single validate call β€” so if you wanted it, catch it before the next one, bestie 😭

version()

returns the version of the XML::LibXML module that's installed on your system. cute, informative, iconic. 🫢


πŸ’… OPTIONS πŸ’…

XML::Validate::LibXML takes these options:

  • strict_validation β€” if this boolean value is true, the document gets validated during parsing. if it's not true, it'll only be checked for well-formedness, that's it. defaults to true. no cap.
  • base_uri β€” because the XML document arrives as a string, the validator has zero clue what the document's URI is πŸ™ˆ. so if your document contains any components referenced with relative URI's, you're gonna need to set this option to the document's URI, so the validator can go retrieve them correctly. it's giving "help me help you".

πŸ¦‹ ERROR REPORTING πŸ¦‹

when a call to validate fails to parse the document, you can grab that error using last_error.

on errors that are not related to the XML parsing, these methods will throw exceptions. so wrap your calls in eval to catch them, okay? protect your peace and protect your program 🧚


🌈 DEPENDENCIES 🌈

XML::LibXML β€” that's the one, that's the whole list.


πŸ’€ BUGS πŸ’€

last_error currently returns a hash ref with only the message field filled in. it would be nice to also fill the line and column fields. manifesting that for a future release, lowkey πŸ™


⭐ VERSION ⭐

$Revision: 1.20 $ on $Date: 2005/09/06 11:05:08 $ by $Author: johna $


πŸ’œ AUTHOR πŸ’œ

Nathan Carr, Colin Robertson

<cpan _at_ bbc _dot_ co _dot_ uk>


(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt


and that's the whole page, bestie πŸŽ€ this was rendered by perl v5.34.0 on 2022-06-28 for the XML::V...:LibXML(3pm) page. go forth and validate, you absolute main character πŸ’–βœ¨