XML::V...:Xerces(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::Validate::Xerces β€” the manual page, but make it cute

okay bestie, so this is XML::Validate::Xerces, straight outta the User Contributed Perl Documentation section of your friendly neighbourhood perl install. It's the lil interface that lets the XML::Validate module borrow the Xerces parser for a vibe check on your XML. buckle up, we're doing this πŸŽ€


✨ NAME ✨

XML::Validate::Xerces - Interface to Xerces validator


✨ SYNOPSIS ✨

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

✨ DESCRIPTION ✨

So like, XML::Validate::Xerces is an interface to the Xerces parser, and its whole personality is being usable with the XML::Validate module. that's it, that's the job πŸ’…


✨ METHODS ✨

  • new(%options) β€” hands you a brand new XML::Validate::Xerces instance, built with whatever options you passed. (peep the OPTIONS section below, it's all there 🫢)
  • validate($xml) β€” returns a true value if $xml could be successfully parsed, and undef otherwise. simple as ✨
  • last_dom() β€” returns the Xerces DOM object of the document that got validated most recently. like a lil souvenir of the last parse πŸ’–
  • last_error() β€” returns the error from the last validate call. it's a hash ref, and the fields are:
    • message
    • line
    • column
heads up bestie: the error gets cleared at the beginning of each validate call. so grab it while it's fresh, no procrastinating πŸ™ˆ
  • version() β€” returns the version of the XML::Xerces module that's installed. iconique, we love a version check πŸ‘‘

✨ OPTIONS ✨

XML::Validate::Xerces takes these options, periodt:

  • strict_validation β€” if this boolean is true, the document gets validated during parsing. otherwise it's only checked for well-formedness (which is lowkey a different thing). defaults to true. no cap.
  • base_uri β€” because the XML document is handed over as a string, the validator literally doesn't know the document's URI 😭. so if your document contains any components referenced using relative URI's, you need to set this option to the document's URI, so the validator can go retrieve them correctly. do not skip this, fr fr.

✨ ERROR REPORTING ✨

when a call to validate fails to parse the document, you can retrieve the error with last_error.

on errors that are not related to XML parsing, these methods will throw exceptions πŸ’€. so wrap your calls in eval to catch them, bestie. no exceptions β€” well, actually, yes exceptions, that's the whole point 🧚


✨ DEPENDENCIES ✨

  • XML::Xerces

✨ BUGS ✨

okay so this part is giving fragile, listen up:

  • XML::Xerces contains an INIT block that doesn't get run, because we load the module inside an eval. this causes a warning message to be printed πŸ™ˆ. so then we run the code in XML::Xerces ourselves β€” but this is fragile, because XML::Xerces might change on us. we need to keep an eye on this. literally watching it like πŸ‘€
  • XML::Xerces reacts badly to code that does use UNIVERSAL (see <http://issues.apache.org/bugzilla/show_bug.cgi?id=25788>). XML::Validate::Xerces inherits this bug, unfortunately. modules known to cause problems include Time::Piece and versions of XML::Twig prior to April 2005. so like, be careful out there 🫢

✨ VERSION ✨

$Revision: 1.21 $ on $Date: 2005/09/06 11:05:09 $ 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 generated for perl v5.34.0 on 2022-06-28, and honestly? iconic. go validate something and slay πŸ’…πŸ’–βœ¨