in reply to How to use xml schema in perl
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.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 ();
|
|---|