Problems with libxml, XML::LibXML and Perl

Discussion in 'XML' started by Ian Gregory, Jul 23, 2003.

  1. Ian Gregory

    Ian Gregory Guest

    Hi,

    One of our servers has recently been upgraded and as a result both
    libxml and XML::LibXML have been upgraded. The OS is OpenBSD 3.3.
    libxml has gone from version 2.4.18 to 2.5.7p1 and XML::LibXML from
    1.40 to 1.54

    However, since the upgrade, XML::LibXML seems to be affecting Perl's
    file handling in ways it shouldn't. The following example illustrates
    this:

    -----------------

    $cat test.pl
    #!/usr/bin/perl -w

    use strict;

    use XML::LibXML;

    my $xml_parser=XML::LibXML->new();

    #This breaks things in an interesting way
    my $style_doc=$xml_parser->parse_file('test.xml');

    print "1\n";
    open(FOO,">foo.txt") or die ("Can't open");
    print "2\n";
    print FOO "test\n" or die ("Can't print");
    print "3\n";
    close FOO or die ("Can't close: $!");
    print "4\n";

    $cat test.xsl
    <?xml version="1.0"?>
    <foo>
    <bar />
    </foo>


    $./test.pl
    1
    2
    3
    Can't close: Bad file descriptor at ./test.pl line 18.

    -----------------

    The file foo.txt is created but is empty. Commenting out the
    "$xml_parser->parse_file" line leads to the script giving the expected
    output (foo.txt contains "test" and 1234 is printed)

    I've looked through the relevant changelogs but I can't see anything
    which would lead to this problem. Has anyone else experienced this
    kind of problem?

    Thanks in advance!

    --
    Ian Gregory
    Replace "groups" with my first name in my email address to contact me
    directly
    Ian Gregory, Jul 23, 2003
    #1
    1. Advertising

  2. Ian Gregory

    cp Guest

    In article <>, Ian
    Gregory <> wrote:

    > $cat test.xsl
    > <?xml version="1.0"?>
    > <foo>
    > <bar />
    > </foo>
    >
    >
    > $./test.pl
    > 1
    > 2
    > 3
    > Can't close: Bad file descriptor at ./test.pl line 18.
    >
    > -----------------
    >
    > The file foo.txt is created but is empty. Commenting out the
    > "$xml_parser->parse_file" line leads to the script giving the expected
    > output (foo.txt contains "test" and 1234 is printed)
    >
    > I've looked through the relevant changelogs but I can't see anything
    > which would lead to this problem. Has anyone else experienced this
    > kind of problem?


    Worked fine for me:
    [Chris:~/scripts] cpryce% perl LibXML_test.pl
    1
    2
    3
    4
    [Chris:~/scripts] cpryce% cat foo.txt
    test

    Perhaps, on your operating system you need to make sure that you've
    flushed the buffer?

    Try setting $| = 1; before printing.

    --
    cp
    cp, Jul 25, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Iain
    Replies:
    2
    Views:
    675
  2. Olav
    Replies:
    3
    Views:
    4,240
  3. kellner
    Replies:
    0
    Views:
    871
    kellner
    Jul 23, 2006
  4. Iain
    Replies:
    1
    Views:
    153
    Martin Honnen
    Dec 15, 2003
  5. Replies:
    5
    Views:
    1,006
    Brian McCauley
    Nov 29, 2006
Loading...

Share This Page