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

I'm working on a failed make test from XML::SAX.

The relevant code from t/16large.t is:

my $handler = XML::SAX::PurePerl::DebugHandler->new(); my $parser = XML::SAX::PurePerl->new(Handler => $handler); $parser->parse_uri("testfiles/xmltest.xml");

When it trys to parse_uri the xmltest.xml file it gets deep into the guts of it and then stops claiming:

Invalid character 0xa0 [Ln: 1373, Col: 4]

Anyone seen this before? Anyone have any suggestions?

Replies are listed 'Best First'.
Re: XML::SAX Failed Test
by mirod (Canon) on Apr 24, 2002 at 10:43 UTC

    First XML::SAX::PurePerl does not use XML::LibXML, so that's not the problem.

    What's the character line 1373 column 4? It should be an ASCII '|'. Your data is probably encoded in ISO-8859-1 (or ISO-8859-15 if it includes the Euro symbol). By default XML documents are encoded in UTF-8.

    Welcome to the wonderful world of encodings! :--(

    You have several options, dependng on your system:

    • define properly your data by using <?xml version="1.0" encoding="ISO-8859-1"?> at the beginning. The catch is that you will need perl 5.7.3 for XML::SAX::PurePerl to work with this encoding,
    • use another parser, that can parse data in ISO-8859-1: XML::SAX can use XML::LibXML as a SAX parser,install it and tell XML::SAX to use it instead of XML::SAX::PurePerl,
    • pre-process your data to convert it to UTF-8: use iconv --from-code=ISO-8859-1 --to-code=UTF-8 --output=xmltest_utf8.xml xmltest.xml and xmltest_utf8.xml will be OK,
Re: XML::SAX Failed Test
by Zaxo (Archbishop) on Apr 24, 2002 at 07:13 UTC

    I suspect you need a newer version of libxml2.so. Mine has 2.4.17, and there may be a newer one out by now. Development is very active for both the solib and the module. I recall running into a similar problem at one point.

    After Compline,
    Zaxo

Re: XML::SAX Failed Test
by Anonymous Monk on Apr 24, 2002 at 12:51 UTC
    I think i had this prob using perl 5.6.0 Try 5.6.1 or higher, and see if you still get the prob.