I have xml schema definition file and xml file and i have to check based on the xml schema definition the xml elements were defined. If xml elements is wrongly defined i want to know the element details.
So, can anyone please refer the modules, sample codes, links based on this using perl.
Thanks in Advance.
Regards,
use XML::LibXML;
my $schema_file = 'po.xsd';
my $document = 'po.xml';
my $schema = XML::LibXML::Schema->new(location => $schema_file);
my $parser = XML::LibXML->new;
my $doc = $parser->parse_file($document);
eval { $schema->validate($doc) };
die $@ if $@;
print "$document validated successfully\n";
For some reason, this is not documented in the POD (which is why almost no one knows about XML:LibXML's schema validation powers!), but the XML::LibXML source comes with the documentation in docbook format plus a utility to generate the POD from that.
Hi Joost/astroboy,
Thanks for your comments. Joost, saying XML::Schema::Validator does not work with elementFormDefault="qualified" and it also not supported various tags as mentioned in the POD. But, I want to support all the valid xml tags and elements as supported by the tools.
The XML::LibXML is working fine. But, it's a system package and I do not want to install anything dependent on system packages. The application would run in an secure environment and there won't be many packages installed on it. So, if any perl modules in that validation found please help me.
Thanks in Advance.
Regards,
Gube
I'm afraid that at some point you're gonna have to bite the bullet and go for option three if you need validation
perlmonks.org content © perlmonks.org and astroboy, gube, Joost
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03