[Thamesvalley-pm] Well-formed XML query and query on further transformation

Iain Emsley print.crimes at yatterings.com
Fri Apr 11 05:32:05 PDT 2008


I'm currently working on a text parser to work out the differences  
between manuscripts but have hit a snag. I'm trying to read a text  
file and output it as XML but I can't quite seem to get the  
well-formedness required for XSL Transformation. Any one got any ideas  
on a better way of doing this?

#!c:\perl\bin\perl.exe

use strict;
use warnings;

use XML::Writer;
use IO::File;

my $write;
my $read = "C:\\WebRoot\\dickens\\dicktest.txt";
my @outputxml;
my $output = new IO::File(">c:\\generate.xml");
my $count;

#my $writer = new XML::Writer(OUTPUT => $output, UNSAFE=>1);

open (IN, $read) || die "$file not found\n";
@outputxml = <IN>;
close (IN);
chomp @outputxml;

$writer->xmlDecl();
$writer ->startTag("text");
foreach $write ( @outputxml) {
	$count++;
	$writer ->startTag("lineno");
	$writer->characters($count);
	$writer->endTag("lineno");
	$writer ->startTag("line");
	$writer->characters($write);
	$writer->endTag("line");
	}
$writer->endTag("text");

$writer->end();
$output->close();

The stage after that is where I need to query a file (though it might  
move to a db table) to match line numbers so that if there is a  
difference, a div tag enabling a JavaScript box can be inserted. Is  
there a Perlish way of doing this or does it need to be done inside  
the XSL Transformation?

Any advice gratefully accepted as I'm trying to get some proof of  
concept code running by the end of the month.
MTIA,

Iain
--

Iain Emsley

Blog: www.yatterings.com
Mobile: 07942 259725


More information about the Thamesvalley-pm mailing list