Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

'not a blessed SV reference' from XML::LibXML::RelaxNG::validate()

by RoUS (Initiate)
on Dec 19, 2007 at 13:57 UTC ( #657872=perlquestion: print w/replies, xml ) Need Help??

RoUS has asked for the wisdom of the Perl Monks concerning the following question:

A very simple script, almost out of the documentation:

#! /usr/bin/perl -w use strict; use XML::LibXML; my $doc = new XML::LibXML; $doc->parse_file('stsdef.xml'); my $rng = new XML::LibXML::RelaxNG(location => 'stsdef.rng'); $rng->validate($doc);

At first it complained about syntax errors in the RNG file, but once I got those cleared up I got this instead: XML::LibXML::RelaxNG::validate() -- doc is not a blessed SV reference at rng.pl line 9.

That's not a message I've had any luck finding a meaningful explanation for. Is there some prerequisite step I'm missing here?

Thanks!

Replies are listed 'Best First'.
Re: 'not a blessed SV reference' from XML::LibXML::RelaxNG::validate()
by robin (Chaplain) on Dec 19, 2007 at 14:46 UTC
    The error message is almost comically bad, but I think the problem is that you need to pass the return value of the parse_file method into the validate method:

    my $doc = XML::LibXML->new()->parse_file('stsdef.xml'); my $rng = new XML::LibXML::RelaxNG(location => 'stsdef.rng'); $rng->validate($doc);
Re: 'not a blessed SV reference' from XML::LibXML::RelaxNG::validate()
by ForgotPasswordAgain (Priest) on Dec 19, 2007 at 14:24 UTC
    It means the doc argument isn't an object, which is bizarre since you used it to call parse_file. You need to either use the debugger or print ref($doc) and ref($rng), use Data::Dumper, try to see what's going on. Since it's XS, it could get trickier..
Re: 'not a blessed SV reference' from XML::LibXML::RelaxNG::validate()
by RoUS (Initiate) on Dec 19, 2007 at 14:58 UTC

    D'oh! That appears to be it. Now I'm getting validation errors on the XML rather than on the RNG, so it appears to be an advance.

    'Comically bad' LOL!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://657872]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2022-09-29 04:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?