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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.