ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
LibXML: Validating Schema using LibXML
by Johannes Kilian other posts by this author
Jul 26 2005 7:37AM messages near this date
view in the new Beta List Site
cgi app broken after upgrading XML::DOM and XML::Parser modules | Re: LibXML: Validating Schema using LibXML
& XSLT Hi there,

I want to validate a XML-File against a Schema.

As the xml::libxml:*:schema documentation suggests, the
validate-function should always be "evaluated":

'*This function allows to validate a document against the given XML
Schema. If this function succeeds, it will return 0, otherwise it will
|die()| and report the errors found. Because of this |validate()|
<http://pcjok2.vitronic.de/ASPNPerl/site/lib/XML/LibXML/Schema.html#item_validate> 
should be always evaluated.'

Considering this, I tried following:
---------------------------
use XML::LibXML;

my $xmlschema = XML::LibXML::Schema-> new( location => 'schema.xsd' );
my $parser=XML::LibXML-> new;
my $doc=$parser-> parse_file( 'invalid.xml' );
eval {
  $xmlschema-> validate( $doc );
};
print "File failed validation: $@" if $@;
------------------------------------

But validate() just dies inside, without being catched by the
eval{}-construct.
Whats wrong here?


Thanks

Johannes
**
Attachments:
jok.vcf
unknown1
unknown2

Thread:
Johannes Kilian
Petr Pajas
Johannes Kilian
Petr Pajas
Johannes Kilian

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved