in reply to How to use xml schema in perl

Hi,

Dunno about schema generation. It seems like you do not want to generate the XSD itself but rather use it as part of a validation scheme.

A good validator is found in XML::Xerces module. But beware, you'll have to first compile Xerces-C library as a back-end. Then, you can use the following code sample for validation purposes:

use strict; use XML::Xerces; XML::Xerces::XMLPlatformUtils::Initialize (); my $parser = XML::Xerces::SAXParser->new; # SAXParser or XercesDOMPa +rser my $options = { setDoNamespaces => 1, setDoSchema => 1, setErrorHandler => XML::Xerces::PerlErrorHandler-> +new, setExitOnFirstFatalError => 0, setExternalSchemaLocation => 'http://www.spiritconsortium.or +g/XMLSchema/SPIRIT/1.2 /data/101/users/xavier_data/soc/BFD/Schema-1.2 +/index.xsd', setValidationConstraintFatal => 0, setValidationSchemaFullChecking => 1, setValidationScheme => $XML::Xerces::AbstractDOMParser +::Val_Always, }; $parser->$_ ( $options->{$_} ) for keys %$options; eval { $parser->parse ( shift ) }; XML::Xerces::error ( $@ ) if $@; XML::Xerces::XMLPlatformUtils::Terminate ();
I'm using here cheesy setExternalSchemaLocation scheme because in my example, SPIRIT Schema URL is dead and I had to install the XSD files locally.

Hope this helps,

Cheers,

Xavier