Keep It Simple, Stupid | |
PerlMonks |
Validate XML with schemas specified inline (xsi:schemaLocation) (with libxml or anything different from Xerces)by jjmoka (Beadle) |
on Apr 21, 2021 at 21:00 UTC ( [id://11131552]=perlquestion: print w/replies, xml ) | Need Help?? |
jjmoka has asked for the wisdom of the Perl Monks concerning the following question:
I've been (successfully) using XML validation (against xsd/schemas specified as xsi:schemaLocation inside the XML itself) with Xerces via this wrapping validating class: XML::Validate which has 3 backends for validating, one being Xerces XML::Validate::Xerces Just a snippet of how such XML-docs are: <person xmlns="http://www.cafeconleche.org/namespaces/person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cafeconleche.org/namespaces/person http://www.elharo.com/person.xsd"> <name> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> ...I'm trying now to move out from Xerces (libxml or anything else) The libxml shipped backend (of that XML::Validate): XML::Validate::LibXML doesn't seem anyhow able to manage the validation against xsd/schema but only against dtd. It doesn't seem this class is going to be updated either, as it was not since 2006. Is there any perl "standard" way nowadays to validate XML with bultin xsd/schemas in xsi:schemaLocation ? I would have chosen XML::LibXML::Schema which seems still the "standard" way. It also didn't receive updates since a while and it states: Currently it supports only schema parsing and document validation.I would then assume it doesn't support the validation from just the XML (with the inline xsi:schemaLocation) All the examples I've found are a 2 steps process: 1. you must first know where the schema is (local or remote (if remote http only, not https)), to create an instance of XML::LibXML::Schema 2. feed this created instance with the XML-doc, to validate it. So the only way to use that with inline xsi:schemaLocation, would seem to extract first them out from the XML-doc and get the url, create a validator instance with that location and then validate the XML-doc. Am I missing a proper way to use this class, or am I missing any other better class ? Thank you very much to everyone.
Back to
Seekers of Perl Wisdom
|
|