"Rodent of Unusual Size" <[EMAIL PROTECTED]> writes:
> Here's one that is probably so easy that I'll turn bright
> red when it's explained to me..
>
> Why doesn't the following varf visibly when I feed it
> non-XML stuff? (Not to mention not validating real XML..)
>
> use HTML::Entities;
> use XML::Xerces;
> use XML::Xerces::DOMParse;
>
> foreach $file (@ARGV) {
> my($parser, $doc);
> $parser = XML::Xerces::DOMParser->new();
> $parser->setDoValidation(1);
> $parser->parse(XML::Xerces::LocalFileInputSource->new($file));
> }
Hey Ken,
Good question. At first glance your code seems fine. The one thing
that is off is the call to setDoValidation(). That's been depricated
for a while now. The proper method is setValidationScheme($scheme)
where scheme can be:
$XML::Xerces::DOMParser::Val_Always
$XML::Xerces::DOMParser::Val_Auto
$XML::Xerces::DOMParser::Val_Never
Attempting to use setValidationScheme() with the upcoming release will
actually generate a compile error.
Also, you're not setting an error handler, so how do you know that
your code is varfing?
Here's an example;
DB<2> use XML::Xerces
DB<3> $d = XML::Xerces::DOMParser->new
DB<5> $d->setValidationScheme(1)
DB<6> $d->setErrorHandler(XML::Xerces::PerlErrorHandler->new)
DB<7> $d->parse(XML::Xerces::MemBufInputSource->new('foobarbax'))
FATAL ERROR:
FILE: FAKE_SYSTEM_ID
LINE: 1
COLUMN: 1
MESSAGE: Invalid document structure
In your code I would expect that to show up as an abort, because of
the lack of an error handler.
Let me know if this doesn't do the trick.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]