Subject: | XML validation interfaces need cleanup |
Trying to validate pool of XML files that uses a combination of schema systems is cumbersome with the current interface. XML::LibXML::DTD objects don't allow a XML object to be thrown at it to validate while the XML::LibXML::Schema is the opposite way:
if( $dtd_validate ) {
$schema_obj = XML::LibXML::Dtd->new( '', $dtd_file ) or die "Failed to create DTD object: $!";
eval{ $xml_doc->validate( $schema_obj ) };
}
elsif( $xsd_validate ) {
$schema_obj = XML::LibXML::Schema->new( location => $xsd_file ) or die "Failed to create XML Schema object: $!";
eval{ $schema_obj->validate( $xml_doc ) };
}
An improvement would be to add a validate method to XML::LibXML::DTD and update XML::LibXML::Document to support passing in Schema objects to the validate method.