NAME

oEdtk::XML::Generic - generic XML reader and schema verifier

SYNOPSIS

use oEdtk::XML::Generic qw(xml_open xml_verif);

my $data = xml_open($fh);
xml_verif($file);    # dies when $file does not match its .xsd / .dtd

DESCRIPTION

Two generic helpers: xml_open turns an XML filehandle into the plain Perl data structure XML::Simple builds, and xml_verif validates a file against the .xsd or .dtd sitting next to it. Moved from oEUser::XML::Generic into the mainline at S21 of the fork-merge plan (decision D23); the old name stays available as a delegate.

FUNCTIONS

xml_open

my $data = xml_open($fh, $options);

Read $fh with XML::Simple and return the resulting structure. $options is merged over the default { suppressempty => '' }.

xml_verif

xml_verif($file);

Look for $file with its extension replaced by .xsd then .dtd, validate $file against the first one found and report success. It croaks when the document is invalid or when no schema file is found. Note that XML::LibXML::Schema::validate returns a false value on success and dies on failure, which is what the check relies on; see t/int/42_xml_readers.t.

AUTHOR

The oEdtk team.