lib/scripts/yxml.pl
author huffman
Fri, 20 Jun 2008 19:59:00 +0200
changeset 27296 eec7a1889ca5
parent 26593 8375332b3c96
child 29145 b1c6f4563df7
permissions -rw-r--r--
moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale

#
# $Id$
# Author: Makarius
#
# yxml.pl - simple XML to YXML converter
#

use strict;
use XML::Parser;

binmode(STDOUT, ":utf8");

sub handle_start {
  print chr(5), chr(6), $_[1];
  for (my $i = 2; $i <= $#_; $i++) {
    print ($i % 2 == 0 ? chr(6) : "=");
    print $_[$i];
  }
  print chr(5);
}

sub handle_end {
  print chr(5), chr(6), chr(5);
}

sub handle_char {
  print $_[1];
}

my $parser = new XML::Parser(Handlers =>
  {Start => \&handle_start,
    End => \&handle_end,
    Char => \&handle_char});

$parser->parse(*STDIN) or die $!;